Forum: Ruby on Rails file_column plugin and instance variables

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.
Jon S. (Guest)
on 2006-01-17 08:20
(Received via mailing list)
To make file_column work I have to copy my local variable back to an
instance variables like this:

<% for product in @products
    @product = product %>
  <div class="catalogentry">
    <%= image_tag url_for_file_column('product', 'image_url') %></p>

This is needed because file_column specifically looks for the instance
version of the variable.

  def url_for_file_column(object, method, subdir=nil)
    case object
    when String, Symbol
      object = instance_variable_get("@#{object.to_s}")

Is this normal or is there some way to fix this in file_column?

Jon S.
Bill P. (Guest)
on 2006-01-17 08:35
(Received via mailing list)
Check out the Wiki page for a better explanation/solution.

On Jan 16, 2006, at 9:41 PM, Jon S. wrote:

> removed_email_address@domain.invalid
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid

- Bill
Kyle M. (Guest)
on 2006-01-18 03:52
(Received via mailing list)
On 1/16/06, Bill P. <removed_email_address@domain.invalid> wrote:
> > <% for product in @products
> >       object = instance_variable_get("@#{object.to_s}")
> >
IIRC, file_column trunk cheats and lets you pass in the object itself:

<%=url_for_file_column product, "image" %>

Also, you could just do what I do and:

<% for @product in @products %>

Kyle M.
Chief Technologist
E Factor Media // FN Interactive
This topic is locked and can not be replied to.