Class: Alchemy::Page::UrlPath
- Inherits:
 - 
      Object
      
        
- Object
 - Alchemy::Page::UrlPath
 
 
- Defined in:
 - app/models/alchemy/page/url_path.rb
 
Overview
The url_path for this page
Use this to build relative links to this page
It takes several circumstances into account:
- 
It returns just a slash for language root pages of the default langauge
 - 
It returns a url path with a leading slash for regular pages
 - 
It returns a url path with a leading slash and language code prefix for pages not having the default language
 - 
It returns a url path with a leading slash and the language code for language root pages of a non-default language
 
Examples
Using Rails’ link_to helper
link_to page.url
  Instance Method Summary collapse
- #call ⇒ Object
 - 
  
    
      #initialize(page)  ⇒ UrlPath 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of UrlPath.
 
Constructor Details
#initialize(page) ⇒ UrlPath
Returns a new instance of UrlPath.
      23 24 25 26 27  | 
    
      # File 'app/models/alchemy/page/url_path.rb', line 23 def initialize(page) @page = page @language = @page.language @site = @language.site end  | 
  
Instance Method Details
#call ⇒ Object
      29 30 31 32 33 34 35 36 37  | 
    
      # File 'app/models/alchemy/page/url_path.rb', line 29 def call if @page.language_root? language_root_path elsif @site.languages.count(&:public?) > 1 page_path_with_language_prefix else page_path_with_leading_slash end end  |