Rails 4.0 with Devise. Nested attributes Unpermited parameters

config/routes.rb Create your own registration controller like so … (see Devise documentation for the details of overriding controllers here …) … which is more elegant way as opposed to doing it via the ApplicationController devise_for :users, controllers: {registrations: ‘users/registrations’} app/controllers/users/registrations_controller.rb Override the new method to create a Profile associated with the User model as below … Read more

Getting fields_for and accepts_nested_attributes_for to work with a belongs_to relationship

I’m a few months too late, but I was looking to solve this error and my situation was that I could not change the relationship to ‘face the other way’. The answer really is quite simple, you have to do this in your new action: @account.build_owner The reason why the form did not display using … Read more

accepts_nested_attributes_for with belongs_to polymorphic

I’ve also had a problem with the “ArgumentError: Cannot build association model_name. Are you trying to build a polymorphic one-to-one association?” And I found a better solution for this kind of problem. You can use native method. Lets look to the nested_attributes implementation, inside Rails3: elsif !reject_new_record?(association_name, attributes) method = “build_#{association_name}” if respond_to?(method) send(method, attributes.except(*UNASSIGNABLE_KEYS)) … Read more

Rails – Strong Parameters – Nested Objects

As odd as it sound when you want to permit nested attributes you do specify the attributes of nested object within an array. In your case it would be Update as suggested by @RafaelOliveira params.require(:measurement) .permit(:name, :groundtruth => [:type, :coordinates => []]) On the other hand if you want nested of multiple objects then you … Read more