# Url\_for\_file\_column within if within a partial

**URL:** <https://www.ruby-forum.com/t/url-for-file-column-within-if-within-a-partial/148606>\
**Category:** Rails\
**Created:** [September 15, 2008, 3:43pm UTC](https://www.ruby-forum.com/t/url-for-file-column-within-if-within-a-partial/148606 "2008-09-15T15:43:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike343](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mike343](https://www.ruby-forum.com/u/mike343)\
**Post date:** [September 15, 2008, 3:43pm UTC](https://www.ruby-forum.com/t/url-for-file-column-within-if-within-a-partial/148606/1 "2008-09-15T15:43:29Z")

</div>

I have a partial that has the following code:

\<% if product.prd\_big\_image.nil? %\>  
 ![Image](https://test.ruby-forum.com/images/empty.jpg)  
\<% else %\>  
\<%= image\_tag url\_for\_file\_column(:product, :prd\_big\_image,  
“normal”) %\>  
\<% end %\>

and get the following error

You have a nil object when you didn’t expect it!  
The error occurred while evaluating nil.prd\_big\_image\_relative\_path

If I run the code in a normal html.erb (not a partial) it works fine,  
just has issues within the partial

any ideas?

---

<div class="post-metadata">

**Author:** ![mike343](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mike343](https://www.ruby-forum.com/u/mike343)\
**Post date:** [September 16, 2008, 6:06am UTC](https://www.ruby-forum.com/t/url-for-file-column-within-if-within-a-partial/148606/2 "2008-09-16T06:06:48Z")

</div>

Michael Moulsdale wrote:

> You have a nil object when you didn’t expect it!  
> The error occurred while evaluating nil.prd\_big\_image\_relative\_path
> 
> If I run the code in a normal html.erb (not a partial) it works fine,  
> just has issues within the partial
> 
> any ideas?

You need to assign @product = product somewhere in the partial.

–  
Rails Wheels - Find Plugins, List & Sell Plugins -  
[http://railswheels.com](http://railswheels.com)
