# Config/environment.rb

**URL:** <https://www.ruby-forum.com/t/config-environment-rb/85954>\
**Category:** Rails\
**Created:** [February 18, 2007, 3:21am UTC](https://www.ruby-forum.com/t/config-environment-rb/85954 "2007-02-18T03:21:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hatless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/848f3c/32.png) [@hatless](https://www.ruby-forum.com/u/hatless)\
**Post date:** [February 18, 2007, 3:21am UTC](https://www.ruby-forum.com/t/config-environment-rb/85954/1 "2007-02-18T03:21:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![hatless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/848f3c/32.png) [@hatless](https://www.ruby-forum.com/u/hatless)\
**Post date:** [February 19, 2007, 11:47am UTC](https://www.ruby-forum.com/t/config-environment-rb/85954/2 "2007-02-19T11:47:17Z")

</div>

HI Steve,

2007/2/18, Steve K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> 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

---

<div class="post-metadata">

**Author:** ![hatless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/848f3c/32.png) [@hatless](https://www.ruby-forum.com/u/hatless)\
**Post date:** [February 19, 2007, 8:08pm UTC](https://www.ruby-forum.com/t/config-environment-rb/85954/3 "2007-02-19T20:08:33Z")

</div>

Beate P. wrote:

> HI Steve,
> 
> 2007/2/18, Steve K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
> 
> > 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

I 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:

\<% odd\_or\_even = 0 for product in @products odd\_or\_even = 1 - odd\_or\_even %\> \<% end %\>

| \<%= image\_tag url\_for\_file\_column("product", "image\_url") %\> | \<%= h(product.name) %\>  
 \<%= h(truncate(product.description, 80)) %\> | **$\<%= sprintf("%0.2f", product.price) %\>**  

\<%= product.rebate %\>% off!

Offer Ends: \<%= product.end\_date.strftime("%d-%m-%y") %\>

  
 | \<%= link\_to 'Show', :action =\> 'show', :id =\> product %\>  
 \<%= link\_to 'Edit', :action =\> 'edit', :id =\> product %\>  
 \<%= link\_to 'Delete', {:action =\> 'destroy', :id =\> product}, :confirm =\> 'Are you sure you want to delete this Product?', :post =\> true %\> |

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.

---

<div class="post-metadata">

**Author:** ![hatless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/848f3c/32.png) [@hatless](https://www.ruby-forum.com/u/hatless)\
**Post date:** [April 9, 2007, 7:25am UTC](https://www.ruby-forum.com/t/config-environment-rb/85954/4 "2007-04-09T07:25:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![hatless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/848f3c/32.png) [@hatless](https://www.ruby-forum.com/u/hatless)\
**Post date:** [April 6, 2007, 1:20am UTC](https://www.ruby-forum.com/t/config-environment-rb/85954/5 "2007-04-06T01:20:56Z")

</div>

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
