How can I link to a static page correctly?

I followed railscast when creating and displaying static pages using the page model, and my code is as follows:

Page Model

has name, constant and description fields.

Routes

get "log_in" => "sessions#new", :as => "log_in"
get "log_out" => "sessions#destroy", :as => "log_out"
get "sign_up" => "users#new", :as => "sign_up"
root :to => "users#new"

resources :pages

match ':permalink', :controller => 'pages', :action => 'show'

_footer.html.erb

<div class="footer">
  <div class="footer_container">
    <%= link_to 'About Us', root_path('about') %>
  </div>
</div>

go to / localhost: 3000 / about displays the page correctly, but the link in the footer wants to direct to /localhost{000/.about and actually refers to the new user page.

How can I get a link to directly view and display the page?

Thanks for any help he really appreciates!

+3
source share
1 answer

root_path # new, , routes.rb. , : , :

match ':permalink', :controller => 'pages', :action => 'show', :as => 'my_page'

- :

<%= link_to 'About Us', my_page_path('about') %>
+3

All Articles