upmin / upmin-admin-ruby

Framework for creating powerful admin backends with minimal effort in Ruby on Rails.
MIT License
754 stars 66 forks source link

undefined method `each' for nil:NilClass when creating model with no manually-filled attributes #149

Closed esaborit4code closed 9 years ago

esaborit4code commented 9 years ago

I have a table with only id, created_at and updated_at, so the form I get rendered looks like this: image

As all of the fields are automatically set on creation, I don't have any field to fill manually.

Then, when I submit to create a new record, in line 32 of model_controller.rb, the variable args is set to nil, so, in line 34 I get a undefined method `each' for nil:NilClass error.

It can be fixed just by replacing line 32 with:

args = params[@klass.underscore_name] || []

I haven't submitted any PR as I don't have enough time and Upmin's codebase knowledge to write proper tests to demonstrate the case.

I hope this issue is helpful enough.

Thanks.

esaborit4code commented 9 years ago

Thanks @jdurand!