I'm having a similar problem to someone earlier on the board, but the
solutions posted aren't working for me, so I figured I wouldn't hijack
the thread and started a new one:
I have an application that allows users to post updates, when they go to
the homepage I want the users details and a list of their updates to
show, however I'm having trouble with the find parameters.
Currently the model states that:
user has_many: updates
update belongs_to:user
I think this is correct (and the right pluralisation)?
the controller for the index page looks like this:
def index
@user = User.find(params[:id])
@updates = Update.find(params[:id]).updates
end
as explained in a previous thread
(You have a nil object - Rails - Ruby-Forum)
I've also tried the different permutations of
@updates = Update.find(:all, :conditions =>["user_id = ?",
params[:user_id]])
When visiting the page I get this messageL
undefined method `updates' for #<Update:0xb7582750>
Have I missed something rediculously obvious? this seems like it should
be a fairly trivial thing to get working but I'm pretty new to the whole
rails experience...
I'm having a similar problem to someone earlier on the board, but the
solutions posted aren't working for me, so I figured I wouldn't hijack
the thread and started a new one:
I have an application that allows users to post updates, when they
go to
the homepage I want the users details and a list of their updates to
show, however I'm having trouble with the find parameters.
Currently the model states that:
user has_many: updates
update belongs_to:user
I think this is correct (and the right pluralisation)?
the controller for the index page looks like this:
def index
@user = User.find(params[:id])
@updates = Update.find(params[:id]).updates
I think you just wanted to write @user.updates assuming that
params[:id] is the id of a user.