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

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

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'

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

Colin

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 Law wrote: