views:

38

answers:

1

Hello,

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 "disable" in general URL /blog_posts. Should I rename my controller or should I change routes (and how)?

+4  A: 

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

map.resources :blog_posts, :as => 'blogs'
Corey
I think he wants `/blog`, so :as => 'blog' -- although the plural form is more conventional Rails...
zetetic
@zetetic; yeah, I thought about that too, maybe 'posts' is a better resource name
Corey
I needed "/blog/posts" :) So I created namespace in routes: map.namespace :blog do |blog|, and inside blog.resources :posts, :controller => 'blog_posts' do |blog_posts| ...
Vitaly