开发者

Controller doesn't equal to model name in Rails

开发者 https://www.devze.com 2022-12-26 15:07 出处:网络
I\'ve model called BlogPost and controller called BlogPostsController that has all basic CRUD methods for BlogPost.

I've model called BlogPost and controller called BlogPostsController that has all basic CRUD methods for BlogPost.

I'm trying to understand how I can route users to have URL like /blog/post-name instead of /blog_posts/post-name and "di开发者_C百科sable" in general URL /blog_posts. Should I rename my controller or should I change routes (and how)?


Update your routes and add the :as option to your blog post resource route

map.resources :blog_posts, :as => 'blogs'
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号