title: Unpermitted parameters: :email, :address
body: <p>I need a button such that when I click it, the name attribute must be be updated in user table and an address must be saved in address table. address table belongs to user table. Now my error is that when I click submit button i am not able to save the address but my name gets updated in the user table. Can anyone help with it?</p>
  
  <p>Controller Code </p>
  
  <pre><code>class ProfileController &lt; ApplicationController
    before_action :set_user, only: %i[index update_profile]
  
    def index; end
  
    def create
        @address = Address.new(address_params)
        respond_to do |format|
          puts'-=-==-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-='
          if @address.save
            format.html { redirect_to profile_index_path, notice: 'Address was successfully created.' }
          else
            format.html { render :new }
          end
        end
      end
  
    def update_profile
      respond_to do |format|
        if @user.update(user_params)
          format.html { redirect_to profile_index_path, notice: 'Profile was successfully updated.' }
        else
          format.html { render :index }
        end
      end
    end
  
  private
  
    def set_user
      @user = User.find(current_user.id)
      @user.address || @user.build_address
    end
  
    def user_params
      params.require(:user).permit(:name, address_attributes: %i[area state country])
    end
  
    def address_params
       params.require(:address).permit(address: %i[area state country])
     end
  end
  </code></pre>
  
  <p>Model </p>
  
  <p>address.rb</p>
  
  <pre><code>class Address &lt; ApplicationRecord
    belongs_to :user
  end
  </code></pre>
  
  <p>user.rb</p>
  
  <pre><code>class User &lt; ApplicationRecord
    # Include default devise modules. Others available are:
    # :confirmable, :lockable, :timeoutable and :omniauthable
    devise :database_authenticatable, :registerable,
           :recoverable, :rememberable, :trackable, :validatable
  
    has_one :address, dependent: :destroy
  
    validates :name, presence: true
    def admin?
      true
    end
  end
  </code></pre>
  
  <p>View Code </p>
  
  <pre><code>&lt;%= form_for(@user, url: { action: 'update_profile' }, html: { class: 'm-form m-form--fit m-form--label-align-right' } ) do |f| %&gt;
    &lt;% if @user.errors.any? %&gt;
      &lt;h4&gt;&lt;%= pluralize(@user.errors.count, "error") %&gt;
        prohibited this profile from being saved:&lt;/h4&gt;
      &lt;ul&gt;
        &lt;% @user.errors.full_messages.each do |message| %&gt;
          &lt;li&gt;&lt;%= message %&gt;&lt;/li&gt;
        &lt;% end %&gt;
      &lt;/ul&gt;
    &lt;% end %&gt;
    &lt;div class="form-group m-form__group row"&gt;
      &lt;label for="name" class="col-2 col-form-label"&gt;
        Name
      &lt;/label&gt;
      &lt;div class="col-7"&gt;
        &lt;%= f.text_field :name, class: 'form-control m-input', placeholder: 'Full Name' %&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="m-form__seperator m-form__seperator--dashed m-form__seperator--space-2x"&gt;&lt;/div&gt;
    &lt;%= f.fields_for @user.address do |a| %&gt;
  
    &lt;div class="form-group m-form__group row"&gt;
      &lt;label for="example-text-input" class="col-2 col-form-label"&gt;
        Address
      &lt;/label&gt;
      &lt;div class="col-7"&gt;
        &lt;%= a.text_field :area, class: 'form-control m-input', placeholder: 'Address' %&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="form-group m-form__group row"&gt;
      &lt;label for="example-text-input" class="col-2 col-form-label"&gt;
        City
      &lt;/label&gt;
      &lt;div class="col-7"&gt;
        &lt;%= a.text_field :city, class: 'form-control m-input', placeholder: 'City' %&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="form-group m-form__group row"&gt;
      &lt;label for="example-text-input" class="col-2 col-form-label"&gt;
        State
      &lt;/label&gt;
      &lt;div class="col-7"&gt;
        &lt;%= a.text_field :state, class: 'form-control m-input', placeholder: 'State' %&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  &lt;%= f.submit 'Save Changes', class: 'btn btn-accent m-btn m-btn--air m-btn--custom' %&gt;
  &amp;nbsp;&amp;nbsp;
  &lt;%= link_to 'Back', root_path, class: 'btn btn-secondary m-btn m-btn--air m-btn--custom' %&gt;
  </code></pre>
  
  <p>routes.rb</p>
  
  <pre><code>resources :profile do
      collection do
        patch 'update_profile'
        get 'update_profile'
      end
    end
  </code></pre>
  
  <p>Terminal log </p>
  
  <pre><code>Started PATCH "/profile/update_profile" for 127.0.0.1 at 2018-05-07 12:33:15 +0530
  Processing by ProfileController#update_profile as HTML
    Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"AJZaELC5GwhOsBCKRZMQMpKySMxNpIIHgNpFBuS1KbBFSs61ByG7RAxVXV8Rd7QXaQ7Htzgyty4Z1uclocXOhQ==", "user"=&gt;{"name"=&gt;"Karthi", "email"=&gt;"suriya@gmail.com", "address"=&gt;{"area"=&gt;"L1, 54th St. &amp; 9th Ave. Ashok Nagar", "city"=&gt;"Chennai", "state"=&gt;"Tamil Nadu", "country"=&gt;"India", "postcode"=&gt;"600083"}}, "commit"=&gt;"Save Changes"}
    User Load (0.3ms)  SELECT  `users`.* FROM `users` WHERE `users`.`id` = 7 ORDER BY `users`.`id` ASC LIMIT 1
    User Load (0.3ms)  SELECT  `users`.* FROM `users` WHERE `users`.`id` = 7 LIMIT 1
    Address Load (0.3ms)  SELECT  `addresses`.* FROM `addresses` WHERE `addresses`.`user_id` = 7 LIMIT 1
  Unpermitted parameter: :address
     (0.1ms)  BEGIN
     (0.2ms)  COMMIT
  Redirected to http://localhost:3000/profile
  Completed 302 Found in 7ms (ActiveRecord: 1.2ms)
  
  
  Started GET "/profile" for 127.0.0.1 at 2018-05-07 12:33:15 +0530
  Processing by ProfileController#index as HTML
    User Load (0.3ms)  SELECT  `users`.* FROM `users` WHERE `users`.`id` = 7 ORDER BY `users`.`id` ASC LIMIT 1
    User Load (0.2ms)  SELECT  `users`.* FROM `users` WHERE `users`.`id` = 7 LIMIT 1
    Address Load (0.2ms)  SELECT  `addresses`.* FROM `addresses` WHERE `addresses`.`user_id` = 7 LIMIT 1
    Rendering profile/index.html.erb within layouts/application
    Rendered profile/_profile_card.html.erb (0.3ms)
    Rendered profile/_profile_detail.html.erb (1.7ms)
    Rendered profile/index.html.erb within layouts/application (3.4ms)
    Rendered layouts/_web_font.html.erb (0.3ms)
    Rendered layouts/_google_analytics.html.erb (0.2ms)
    Rendered layouts/_header.html.erb (1.8ms)
    Rendered layouts/_alerts.html.erb (0.4ms)
  Completed 200 OK in 32ms (Views: 28.7ms | ActiveRecord: 0.7ms)
  </code></pre>