Partials and instance variables for file_column

Hi,

Sebastian K. of the file_column-Plugin wrote once:

“is the photo object inside a local variable or an instance variable
(e.g. photo or @photo)? url_for_file_column only works with instance
variables, like all other active record form helpers. Could this be
the problem?”

So I’m using file_column in a partial, e.g.

<%= render (:partial => “product”, :collection => @products) %>

my partial (_product.rhtml) looks like this:

<%= link_to product.titel, :action => 'detail', :id => product.id %>

<%= link_to (image_tag url_for_file_column("product", "image"), {:width => '150', :height => '181', :style => ""}), { :action => 'detail', :id => product.id }, {:title => "Detailansicht" } %>

<%= product.preis %>

But in my partial I have the local variable “product”, not the
instance variable @product, so file_column doesn’t work. I now have a

<% @product = product %>
in the top of my partial, but I think there must be a more railish way.
But how?

Thanks,
Beate

On 1/19/06, Beate P. [email protected] wrote:

Rails mailing list [email protected] http://lists.rubyonrails.org/mailman/listinfo/rails

url_for_file_column now lets you cheat and pass the object itself
where most rails fields only accept the string name of the object.
i.e.

url_for_file_column “instance_var”, “field”
url_for_file_column @instance_var, “field”
url_for_file_column local_var, “field”

are all valid.


Kyle M.
Chief Technologist
E Factor Media // FN Interactive
[email protected]
1-866-263-3261