config/routes.rb
:
map.stories 'stories/:id', :controller => 'books', :action => 'show'
:
<%= link_to book.name, stories_path(book) %>
, book.name , . , book .
:id, SEO to_param .
:
def to_param
"#{id}-#{name.gsub(/\s/, '_').gsub(/[^\w-]/, '').downcase}"
end
Also, make sure you replace namewith the attribute that the book model actually has.
source
share