On 10/16/05, Henrik Ormåsen
<henrik.ormasen-ncF+TE9kgVaJWJjT0n2wSQ@public.gmane.org>
wrote:> Newbie question:
>
> From a _form.rhtml file I have:
> <%= render(:partial => ''item'', :collection =>
@items) %>
>
> In _item.rhtml I have:
> <% @tullt = h(item.body) %>
> <%= @itemdb = Group.find(:all,
> :conditions => "id =
''#{@tullt}''").map {|u| [u.name] }
> %>
> <%= @tullt %
>
> I think it would be better to put this code in a controller for this
> partial. I made the following item_controller.rb file for this:
>
> class ItemController < ApplicationController
> def index
> @tullt = h(item.body)
> @itemdb = Group.find(:all,
> :conditions => "id =
''#{@tullt}''").map {|u|
> [u.name] }
> end
> end
>
> But this doesn''t work (I guess for som obvious reason, I just
haven''t
> the knowledge of).
>
> - Henrik
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
You use something like this to pass the data reference to the partial...
<%= render(:partial => ''item'', :collection =>
@items), :locals=>{
"item_db" => @item_db } %>
And note you now reference item_db (a local) rather then @item_db.
Nick
--
Nicholas Van Weerdenburg