Partials and instance variables for file_column


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 => %>

<%= link_to (image_tag url_for_file_column("product", "image"), {:width => '150', :height => '181', :style => ""}), { :action => 'detail', :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?


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

Rails mailing list [email protected]

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.

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]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs