Ruby on Rails Wednesday, March 30, 2011

It doesn't matter all that much. If it has a stronger affinity for one
of the controllers, then put it in that controller's view folder, and
then in the other spot where you need to reference it, just put the
leading /modelname/partialname on the render argument.

So you have

views
bars
index.html.erb
foos
_foo.html.erb
index.html.erb

and you want to re-use the foo partial to make a list of foos in the
bars/index view, you would just do this:

render :partial => '/foos/foo', :collection => @foos

in your bars index, assuming you had gathered a collection of foos in
your bars_controller inside the index method.

Walter

On Mar 30, 2011, at 6:03 PM, Albert Català wrote:

> Hello, I'm new in Rails and much more in MVC, and I'm absolutly lost.
>
> The question is more clearly this:
>
> If I have a partial, than uses a controller/method (called X) for
> requery itself via JS, and this partial is viewed in two screens ( two
> controllers, menu and sarch). where do you place this code (X), In
> which
> controller and views, and js.rjs?
>
> where can i see an example?
>
> thanks you.
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-
> talk@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
> .
>

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment