{"action":"opened","issue":{"url":"https://api.github.com/repos/plataformatec/devise/issues/4037","repository_url":"https://api.github.com/repos/plataformatec/devise","labels_url":"https://api.github.com/repos/plataformatec/devise/issues/4037/labels{/name}","comments_url":"https://api.github.com/repos/plataformatec/devise/issues/4037/comments","events_url":"https://api.github.com/repos/plataformatec/devise/issues/4037/events","html_url":"https://github.com/plataformatec/devise/issues/4037","id":147958615,"number":4037,"title":"Registration Form with Nested Models","user":{"login":"harshamv","id":249592,"avatar_url":"https://avatars.githubusercontent.com/u/249592?v=3","gravatar_id":"","url":"https://api.github.com/users/harshamv","html_url":"https://github.com/harshamv","followers_url":"https://api.github.com/users/harshamv/followers","following_url":"https://api.github.com/users/harshamv/following{/other_user}","gists_url":"https://api.github.com/users/harshamv/gists{/gist_id}","starred_url":"https://api.github.com/users/harshamv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harshamv/subscriptions","organizations_url":"https://api.github.com/users/harshamv/orgs","repos_url":"https://api.github.com/users/harshamv/repos","events_url":"https://api.github.com/users/harshamv/events{/privacy}","received_events_url":"https://api.github.com/users/harshamv/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-13T06:21:58Z","updated_at":"2016-04-13T06:21:58Z","closed_at":null,"body":"I have the following models\r\n\r\n    members(id, name, company_id)\r\n    companies(id, name, ...)\r\n\r\nNow when i signup using devise model - `members` i want to create a record in the `companies` model and update `company_id` in the `members` model.\r\n\r\nCan i build the company in the signup for like below\r\n\r\n    class Brands::Members::RegistrationsController < Devise::RegistrationsController\r\n      before_action :configure_sign_up_params, only: [:create]\r\n    # before_action :configure_account_update_params, only: [:update]\r\n    \r\n      # GET /resource/sign_up\r\n      def new\r\n        build_resource({})\r\n        resource.build_company\r\n        respond_with self.resource\r\n      end\r\n    end\r\n\r\n**Members Model**\r\n\r\n    class Member < ActiveRecord::Base\r\n      # Include default devise modules. Others available are:\r\n      # :confirmable, :lockable, :timeoutable and :omniauthable\r\n      devise :database_authenticatable, :registerable,\r\n             :recoverable, :rememberable, :trackable, :validatable\r\n    \r\n      acts_as_paranoid\r\n      attr_accessor :company_name\r\n    \r\n      # Associations\r\n      belongs_to :company\r\n    \r\n      accepts_nested_attributes_for :company\r\n    end\r\n\r\n\r\n**Company Model**\r\n\r\n    class Company < ActiveRecord::Base\r\n      extend FriendlyId\r\n      # friendly_id :name, use: :slugged\r\n      acts_as_paranoid\r\n    \r\n      @company_type = %w(agency brand)\r\n    \r\n      # Associations\r\n      has_many :members, dependent: :destroy\r\n      has_many :brands, dependent: :destroy\r\n    end\r\n\r\nSignup Form\r\n\r\n    <h2>Sign up</h2>\r\n    \r\n    <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>\r\n      <%= devise_error_messages! %>\r\n    \r\n      <div class=\"field\">\r\n        <%= f.label :name %><br />\r\n        <%= f.text_field :name, autofocus: true, value: 'Harha MV' %>\r\n      </div>\r\n    \r\n      <div class=\"field\">\r\n        <%= f.label :email %><br />\r\n        <%= f.email_field :email, value: 'harsha@mink7.com' %>\r\n      </div>\r\n    \r\n      <div class=\"field\">\r\n        <%= f.label :password %>\r\n        <% if @minimum_password_length %>\r\n        <em>(<%= @minimum_password_length %> characters minimum)</em>\r\n        <% end %><br />\r\n        <%= f.password_field :password, autocomplete: \"off\", value: 'harsha' %>\r\n      </div>\r\n    \r\n      <h4>Enter your company details</h4>\r\n      <%= f.fields_for :company do |fc| %>\r\n        <div class=\"field\">\r\n          <%= fc.label :name %><br />\r\n          <%= fc.text_field :name, value: 'Mink7' %>\r\n        </div>\r\n    \r\n      <% end %>\r\n    \r\n      <div class=\"actions\">\r\n        <%= f.submit \"Sign up\" %>\r\n      </div>\r\n    <% end %>\r\n    \r\n    <%= render \"brands/members/shared/links\" %>\r\n\r\n\r\n***Error***\r\n\r\n\r\n    NoMethodError at /members\r\n    \r\n    undefined method `' for #<Company:0x007f99fc7e5638>\r\n    \r\n    method_missing\r\n    activemodel (4.2.5.2) lib/active_model/attribute_methods.rb\r\n    \r\n        def method_missing(method, *args, &block)\r\n          if respond_to_without_attributes?(method, true)\r\n            super\r\n          else\r\n            match = match_attribute_method?(method.to_s)\r\n            match ? attribute_missing(match, *args, &block) : super\r\n          end\r\n        end\r\n\r\n\r\n"}}