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}")
end
Is this normal or is there some way to fix this in file_column?
--
Jon Smirl
jonsmirl@gmail.com
Check out the Wiki page for a better explanation/solution. http://wiki.rubyonrails.com/rails/pages/HowToUseFileColumn On Jan 16, 2006, at 9:41 PM, Jon Smirl wrote:> 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}") > end > > Is this normal or is there some way to fix this in file_column? > > -- > Jon Smirl > jonsmirl@gmail.com > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >- Bill
On 1/16/06, Bill Pennington <bill@norcalkayakanglers.com> wrote:> Check out the Wiki page for a better explanation/solution. > > http://wiki.rubyonrails.com/rails/pages/HowToUseFileColumn > > > On Jan 16, 2006, at 9:41 PM, Jon Smirl wrote: > > > 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}") > > end > > > > Is this normal or is there some way to fix this in file_column? > > > > -- > > Jon Smirl > > jonsmirl@gmail.com > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > - Bill > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >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 Maxwell Chief Technologist E Factor Media // FN Interactive kyle@efactormedia.com 1-866-263-3261