Well, started to learn rails and of course started by writing a service with personal blogs (something like livejournal). I have posts scaffold and user model (thanks to Devise). Now I'm trying to show all posts by certain user with something like /username/posts in url but really can't understand how to make this rails-way. Already made nested resources in routes
resources :users do
resources :posts
end
and connected user and post models with
has_many :posts
and
belongs_to :user
Should I create controller for user or not? Is there any proper way for this?
P.S. Thanks for the answer. Trying to study rails but almost every tutorial I found ends with scaffolding and that's not very helpful.
Edit 1: Thanks to the "match" idea I solved half of the problem. The other (unsolved) half is selecting posts written by certain user
Edit 2: Added
@user = User.where(:username => params[:username])
@posts = @user.posts
To controller, but I have "undefined method `posts'" error in posts controller.