# NoMethodError (private method \`chomp' called for nil:NilClas

**URL:** <https://www.ruby-forum.com/t/nomethoderror-private-method-chomp-called-for-nil-nilclas/185783>\
**Category:** Rails\
**Created:** [March 26, 2010, 12:45am UTC](https://www.ruby-forum.com/t/nomethoderror-private-method-chomp-called-for-nil-nilclas/185783 "2010-03-26T00:45:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jefflin23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jefflin23](https://www.ruby-forum.com/u/jefflin23)\
**Post date:** [March 26, 2010, 12:45am UTC](https://www.ruby-forum.com/t/nomethoderror-private-method-chomp-called-for-nil-nilclas/185783/1 "2010-03-26T00:45:52Z")

</div>

Hi:

I am using Rails 2.3.5 with paperclip, mime-types and uploadify. So far  
the application is working in development environment. But when I  
switched to the production environment, it produced the following error.

NoMethodError (private method `chomp' called for nil:NilClass): /usr/lib/ruby/gems/1.8/gems/mime-types-1.16/lib/mime/types.rb:665:in`type\_for’  
/usr/lib/ruby/gems/1.8/gems/mime-types-1.16/lib/mime/types.rb:730:in  
`type_for' app/controllers/assets_controller.rb:180:in`new\_asset\_from\_params’  
haml (2.2.22) rails/./lib/sass/plugin/rails.rb:20:in `process' app/middleware/flash_session_cookie_middleware.rb:15:in`call’

It seems that the error has something to do with Mime-types. But I could  
not work it out. Does anyone have the similar issue or possible  
suggestions?

Thanks

---

<div class="post-metadata">

**Author:** ![jefflin23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jefflin23](https://www.ruby-forum.com/u/jefflin23)\
**Post date:** [March 26, 2010, 9:56am UTC](https://www.ruby-forum.com/t/nomethoderror-private-method-chomp-called-for-nil-nilclas/185783/2 "2010-03-26T09:56:58Z")

</div>

On 25 March 2010 23:45, Jefflin H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> `type_for' app/controllers/assets_controller.rb:180:in `new\_asset\_from\_params’

So what is this line (and a few around it)?

Colin

---

<div class="post-metadata">

**Author:** ![jefflin23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jefflin23](https://www.ruby-forum.com/u/jefflin23)\
**Post date:** [March 27, 2010, 3:51am UTC](https://www.ruby-forum.com/t/nomethoderror-private-method-chomp-called-for-nil-nilclas/185783/3 "2010-03-27T03:51:18Z")

</div>

Hi:

new\_asset\_from\_params is used to create the Asset object based on the  
parameters from URL. This method as been assigned as a before\_filter.

And after extended logging of the code, I finally figured out the  
problem. The problem was caused my own doing really.

It turns out that I have made a copy of the assets\_controller.rb as  
‘Copy of assets\_controller.rb’ under the controllers directory before.  
Under the development environment, everything works. But under  
production environment, it seems that rails loads both controllers and  
executed the new\_asset\_from\_params twice. The first time, everything was  
working fine. But at the second time, it caused the error. After I  
removed the copy of the assets\_controller, the application works without  
any issue.

So thanks for reading the issue I had. But if anyone can share some  
light on why the behaviors are different between production and  
development environment in my case, that will be very helpful for my  
understanding.

regards

Jefflin

Colin L. wrote:

> On 25 March 2010 23:45, Jefflin H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > `type_for' ï¿½app/controllers/assets_controller.rb:180:in `new\_asset\_from\_params’
> 
> So what is this line (and a few around it)?
> 
> Colin
