如何修改http://localhost:3000/profiles/1
到http://localhost:3000/myusername
的路由?
我有一个包含下表的配置文件模型:
def self.up
create_table :profiles do |t|
t.string :username
t.text :interest
t.timestamps
end
end
和我的routes.rb
文件:
resources :profiles
我看过类似的关于to_param、devise或nested loops甚至an example in Rails 2.3的答案,但我找不到一种可行的方法。
我应该对profile/view/show.html.erb
、routes.rb
和model/profile.rb
(如果有)进行哪些更改,以修改从http://localhost:3000/profiles/1
到http://localhost:3000/username
的路由?我正在学习基础知识,因此我不想使用任何gem或插件。
https://stackoverflow.com/questions/6056444
复制相似问题