Rails undefined method ReactJS
<p>I am getting an error on my application <code>undefined method 'preference' for #&lt;User:0x007fb3cc1c3b80&gt;</code>. Following were my <code>accounts</code> controller:</p>

<pre><code>class AccountsController &lt; ApplicationController

    before_action :authenticate_user!

    def edit
        #render html: 'Edit your account'
        render component: 'AccountsEdit', props: {
            preference: PreferenceSerializer.new(current_user.preference)
        }, tag: 'div'
    end

    def update
        @preference = current_user.preference
        if @preference.update_attributes(preference_params)
            render json: { data: 'SUCCESS!' }
        else
            render json: { data: 'FAIL!' }
        end
    end

    private 
        def preference_params
            params.require(:preference).permit(:display_name, :notify_on_answer, :daily_digest)
        end


end
</code></pre>

<p>And my User and Preference model:</p>

<pre><code>class User &lt; ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable
end

class Preference &lt; ActiveRecord::Base
    belongs_to :user
end
</code></pre>

<p>Seems all look alright, but i keep getting the same error. Am i missing something here? Thanks!!</p>