How can I amend the routing from http://localhost:3000/profiles/1
to http://localhost:3000/myusername
?
I have a Profile model with the following table:
def self.up
create_table :profiles do |t|
t.string :username
t.text :interest
t.timestamps
end
end
And my routes.rb
file:
resources :profiles
I have looked at similar answers dealing with to_param, devise or nested loops or even an example in Rails 2.3, but i couldn't find a way that works.
What changes should I make to the profile/view/show.html.erb
, routes.rb
and model/profile.rb
(if any) to amend the routing from http://localhost:3000/profiles/1
to http://localhost:3000/username
? I'm learning from the basics, hence I rather not use any gems or plugins.