I have the following Devise registration form (with irrelevant markup omitted):
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { id: "payment-form" }) do |f| %>
<%= f.fields_for resource.paid_account do |pa| %>
<%= pa.collection_select :account_plan_id, @account_plans, :id, :name_with_price %>
<% end %>
<% end %>
This form spits out the following HTML:
<select id="user_paid_account_account_plan_id" name="user[paid_account][account_plan_id]">
<option value="2">Lite ($10.00/mo)</option>
<option value="3">Professional ($20.00/mo)</option>
<option value="4">Plus ($30.00/mo)</option>
</select>
I then have the following code in my ApplicationController
:
class ApplicationController < ActionController::Base
before_filter :configure_permitted_parameters, if: :devise_controller?
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) do |u|
u.permit(
:email,
:password,
:paid_account => :account_plan_id # <-- THIS IS PROBABLY WRONG
)
end
end
end
When I submit my form I get "PaidAccount(#2163736620) expected, got ActionController::Parameters(#2173083140)".
I've also tried the following which doesn't give an error, but it also doesn't create a record:
u.permit(
:email,
:password,
:paid_account => []
)
What am I doing wrong?