I have a web application with users and their documents. Each user can have many documents: user.rb: has_many :documents document.rb: belongs_to :user document_controller.rb: def index @documents = Document.find(:all) end I am using the restful_authentication plugin. Here is my question: How do I get the controller to only show documents that belongs to each user? Right now it shows all the documents for all the users. I am using the latest version of Rails.
on 2008-10-20 01:06
on 2008-10-20 01:56
@current_user.documents rather Document.find(:all). Cheers, Walter McGinnis
on 2008-10-20 01:57
Oh, I should say that I'm not sure what the actual user variable is when using restful_authentication, but that is the concept you want to go for. Cheers, Walter
on 2008-10-20 16:44
@user.documents Cheers, Sazima On Oct 19, 7:06 pm, David S. <firstname.lastname@example.org>