Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redirect not working when site has a path #173

Closed
pietere opened this issue Apr 5, 2012 · 1 comment
Closed

redirect not working when site has a path #173

pietere opened this issue Apr 5, 2012 · 1 comment

Comments

@pietere
Copy link

pietere commented Apr 5, 2012

Hi,

I did set up a site with path: "en/site"

>> Cms::Site.first.path
  Cms::Site Load (0.3ms)  SELECT `cms_sites`.* FROM `cms_sites` LIMIT 1
=> "en/site"

Now, when I look at the full_path of the first page of that site, I get "/" back

>> Cms::Site.first.pages.first.full_path
  Cms::Site Load (0.3ms)  SELECT `cms_sites`.* FROM `cms_sites` LIMIT 1
  Cms::Page Load (0.4ms)  SELECT `cms_pages`.* FROM `cms_pages` WHERE `cms_pages`.`site_id` = 1 ORDER BY cms_pages.position LIMIT 1
=> "/"
>> 

Also, when I make this page redirect to it's first child page, it redirects to

/first-child
in stead of
/en/site/first-child

>> Cms::Site.first.pages.first.children.first.full_path
  Cms::Site Load (0.3ms)  SELECT `cms_sites`.* FROM `cms_sites` LIMIT 1
  Cms::Page Load (0.4ms)  SELECT `cms_pages`.* FROM `cms_pages` WHERE `cms_pages`.`site_id` = 1 ORDER BY cms_pages.position LIMIT 1
  Cms::Page Load (0.3ms)  SELECT `cms_pages`.* FROM `cms_pages` WHERE `cms_pages`.`parent_id` = 1 ORDER BY cms_pages.position LIMIT 1
=> "/first-child"
>> 

Conclusion: could it be that the site path is not taken into account for building the page full_path (which makes the redirect not work properly)?

@toreyheinz
Copy link

Right it looks like the page model does not consider the Site path when generating a url

def assign_full_path
  self.full_path = self.parent ? "#{self.parent.full_path}/#{self.slug}".squeeze('/') : '/'
end
# Full url for a page
def url
  "http://#{self.site.hostname}#{self.full_path}"
end

danimashu added a commit to pietere/comfortable-mexican-sofa that referenced this issue Apr 12, 2012
GBH pushed a commit that referenced this issue May 3, 2012
building the right url for pages taking care of site path #173
@GBH GBH closed this as completed May 3, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants