plataformatec/devise — Issue #1519: ArgumentError in RegistrationsController#create 
Author: tcpipmen
Created: 2011-12-23 19:09:54+00:00
State: open

I'm trying to use nested form in devise User model. first_name and last_name fields from person model appeared on new registration form as I nested them, but then when submit, I'm getting "wrong number of arguments (2 for 1)" and does not do anything. Please help. Thanks so much

class User < ActiveRecord::Base
has_one :person
accepts_nested_attributes_for :person
attr_accessible :email, :password, :password_confirmation, :username, :login, :remember_me, :person_attributes

end

class Person ActiveRecord::Base
after_initialize :init_person
belongs_to :user

def init_person
if self.person.nil? then
self.person = Person.new
end
end

end

<%= semantic_form_for resource, :as => resource_name,:url => registration_path(resource_name) do |f| %>

<%= f.inputs do %>
<%= f.input :username %>
<%= f.input :email , :as => :email %>
<%= f.input :password , :as => :password %>
<%= f.input :password_confirmation , :as => :password %>

<%= f.semantic_fields_for :person do |person| %>
<%= person.inputs :first_name, :last_name %>
<% end %>
<% end %>

<%= f.buttons do %>
<%= button_submit_tag "Register" %>
<% end %>
<% end %>