Question:
Why rails added dot before name, in URL?
Exemple:
exemple.com/.category1
exemple.com/.category2
Code :
models/blog.rb
class Blog < ActiveRecord::Base
attr_accessible :name, :title
end
routes.rb
Exemple::Application.routes.draw do
resource :blogs
root :to => "blog#index"
end
views/layouts/application.html.erb
<% Blog.all.each do |category| %>
<%= link_to category.title, root_path(category.name) %>
<% end %>
Rails named routes accept some optional parameters. One of them is
(.:format). The full signature ofroot_path.root_path("xml")is the same asroot_path(:format => "xml")which will resolve to"/.xml"or in your caseexample.com/.category1.