Forum: Ruby on Rails templates and partials

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
patrick (Guest)
on 2005-12-02 03:18
(Received via mailing list)
i´m having something like this:

<%= render(:partial => 'interview', :object => @interviews)%>

now, within the view, i´d like to pass the id-parameter to select a
like this (although this code is probably wrong):

<%= render(:partial => 'interview', :object => @interviews, :id =>

basically, i need the view to tell the controller which interview to
any idea how to achieve this?
cuong.tran (Guest)
on 2005-12-02 03:26
(Received via mailing list)
Use :locals:

<%= render(:partial => 'interview', :locals => { :id => 1237 })%>

Check the docs on ActionController::Base
patrick (Guest)
on 2005-12-02 03:42
(Received via mailing list)
how can i access the id (local) within the controller to choose the
cuong.tran (Guest)
on 2005-12-02 04:55
(Received via mailing list)
What do you mean?  You retrieve the right object from your controller
and pass that object to your partial.
patrick (Guest)
on 2005-12-02 12:14
(Received via mailing list)
as mentioned before:
basically, i need the view to tell the controller which interview to

well, maybe that´s not possible. maybe i need components.
pertl (Guest)
on 2005-12-02 12:26
(Received via mailing list)
As far as I understand:

First the controller is executed by rails
Then the view is rendered
And that's it

So there will be no way to again execute the controller after
the view has been rendered. This means, no communication from view to
the controller is possible. Only from controller to view. And that's how
should be. If the decision in the view depends on some user action I
suggest using Ajax. Otherwise I would rethink your problem and solve it
in the controller where logic is supposed to be.

On Fri, 02 Dec 2005 11:12:13 +0100, patrick k
patrick (Guest)
on 2005-12-02 12:30
(Received via mailing list)
i already thought it might (and should) be that way.
guess i have to re-think my problem.

thanks for your answer.
This topic is locked and can not be replied to.