I just recently started using the file_column plugin. I have an easy time getting it to upload files, but I can seem to get it to work on the view. I get the error "undefined method `image_relative_path''". I read the documentation and at one point it says to "require [rails_file_column.rb] file from your ''config/environment.rb'' (after rails has been loaded) to integrate the file_column extension into rails." Considering that I''ve followed pretty much every other step (I think), I figure that this may be my problem. My question is what is the proper syntax to require a file in the environment.rb file? Another thing that doesn''t have to much to do with the environment.rb is that ever since I started using the file_column plugin I''ve been getting this "Loaded suite dispatch.cgi Started Finished in 0.00018 seconds. 0 tests, 0 assertions, 0 failures, 0 errors" at the bottom of my page..Anyway to make this not show up? Thanks. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
HI Steve, 2007/2/18, Steve Klinko <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> I read the documentation and at one point it says to "require > [rails_file_column.rb] file from your ''config/environment.rb'' (after > rails has been loaded) to integrate the file_column extension into > rails."Did you put the plugin under /vendor/plugins/? Then you needn''t any requirements of this Plugin in your environment. Im my view, I have something like <%= image_tag url_for_file_column("product", "image"), {:class => "produktbild" } %> HTH, Beate --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Beate Paland wrote:> HI Steve, > > 2007/2/18, Steve Klinko <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>: >> I read the documentation and at one point it says to "require >> [rails_file_column.rb] file from your ''config/environment.rb'' (after >> rails has been loaded) to integrate the file_column extension into >> rails." > > Did you put the plugin under /vendor/plugins/? Then you needn''t any > requirements of this Plugin in your environment. > > Im my view, I have something like > > <%= image_tag url_for_file_column("product", "image"), {:class => > "produktbild" } %> > > HTH, > BeateI did install it in /vendor/plugins/, and in the view I put the equivalent to your <%= image_tag url_for_file_column("product", "image") %> however I''m not sure what the :class is for, unless it refers to the CSS class? Anyways this is the code for the view: <table cellpadding="5" cellspacing="0"> <% odd_or_even = 0 for product in @products odd_or_even = 1 - odd_or_even %> <tr valign="top" class="ListLine<%= odd_or_even %>"> <td> <%= image_tag url_for_file_column("product", "image_url") %> </td> <td width="60%"> <span class="ListTitle"><%= h(product.name) %></span><br /> <%= h(truncate(product.description, 80)) %> </td> <td align="right"> <strong>$<%= sprintf("%0.2f", product.price) %></strong><br /> <p class="products"><%= product.rebate %>% off!</p> <p>Offer Ends: <%= product.end_date.strftime("%d-%m-%y") %></p><br /> </td> <td class="ListActions"> <%= link_to ''Show'', :action => ''show'', :id => product %><br /> <%= link_to ''Edit'', :action => ''edit'', :id => product %><br /> <%= link_to ''Delete'', {:action => ''destroy'', :id => product}, :confirm => ''Are you sure you want to delete this Product?'', :post => true %> </td> </tr> <% end %> </table> I''ll get this as an error: "You have a nil object when you didn''t expect it! The error occured while evaluating nil.image_url_relative_path" Thanks again. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
i had the same problem when i first tried file_column. i figured it out by reading through ''file_column_helper.rb'' that is installed with the plugin in the lib directory. here''s what i found: object = instance_variable_get("@#{object.to_s}") basically it gets a reference to the _INSTANCE_ variable that is being referred to by the first string you pass to url_for_file_column. this means that in your case you need a variable named "@product" that holds a reference to the product you''re trying to display the image of. For instance, just try adding this to the top of your template and see what happens. <% @product = product %> a cleaner solution would probably be to set this instance variable somewhere inside the controller that renders your template code. hope that helps, -jcs --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I encounter the same problem. What I did is change <%= image_tag url_for_file_column("product", "image_url") %> to <%= image_tag url_for_file_column(product, "image_url") %> and it works. This is inspired by Jason S.''s post above, in ''file_column_helper.rb'', it will check if the first parameter is a string or symbol, and tries to get the object from it. Since in your case, product is already an obj, you can just pass it in directly. -Michael Claim: I don''t read gmail. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---