title: Allow users to edit their profile fields in rails 4
body: <p>I have a new question.</p>
  <p><strong>What I want to do?</strong></p>
  <p>I've created the profile for each player, now I want to allow users to edit their profile.</p>
  <p>Part of this profile takes the <code>devise</code> table, with a second table called <code>profiles</code>.</p>
  <p><em>Devise:</em> Captures username, password and email</p>
  <p><em>Profiles:</em> Captures Personal Information</p>
  <p><strong>Schema of Profiles</strong></p>
  <pre><code>  create_table &quot;profiles&quot;, force: :cascade do |t|
      t.text   &quot;about&quot;
      t.string &quot;fb&quot;
      t.string &quot;skype&quot;
      t.string &quot;birthday&quot;
      t.string &quot;twitter&quot;
      t.string &quot;steam&quot;
      t.string &quot;gender&quot;
      t.string &quot;occupation&quot;
      t.string &quot;location&quot;
      t.string &quot;interest&quot;
    end
  </code></pre>
  <p><strong>My profile_controller.rb (Updated)</strong></p>
  <pre><code>class ProfileController &lt; ApplicationController
      def index
        @profile = Player.all
      end
  
      def show
          @profile = Player.find_by(nick: params[:nick])
      end
  
      def edit
          # use this to populate a form in your view
           @profile = Player.find_by(nick: params[:nick])
      end
  
      def update
         @profile = Player.find_by(nick: params[:nick])
      if @profile.update_attributes(profiles_params)
           redirect_to(:action =&gt; &quot;show&quot;, :profile =&gt; @profile.nick)
      else
         render(&quot;index&quot;)
      end
        end
  
    private
      def profiles_params
        params.require(:profiles).permit(:about, :skype)
      end
  end
  </code></pre>
  <p><strong>Rake routes</strong></p>
  <pre><code>profiles GET    /profiles(.:format)              profiles#index
           GET    /profiles/:nick/edit(.:format)   profiles#edit
           GET    /profiles/:nick(.:format)        profiles#show
           PATCH  /profiles/:nick(.:format)        profiles#update
           PUT    /profiles/:nick(.:format)        profiles#update
  </code></pre>
  <p><strong>Routes.rb</strong></p>
  <pre><code>  devise_for :players
  
    resources :profile, param: :nick
    resources :profiles, only: [:index, :show, :edit, :update], param: :nick
  </code></pre>
  <p><strong>Notes:</strong></p>
  <ol>
  <li>I have a profile controller</li>
  <li>I have these pages:
  <ul>
  <li><code>show.html.erb</code></li>
  <li><code>index.html.erb</code></li>
  </ul>
  </li>
  </ol>
  <h2><strong>Now my question is:</strong></h2>
  <p>*How should I make the edit page for each users profile,
  considering that each user edits their own profile?</p>
  <p>Once a user edits a field, I want this to be reflected on the page <code>show.html.erb</code>. How can I achieve this?*</p>
  <p>** show.html.erb **</p>
  <pre><code>&lt;div id=&quot;myTabContent&quot; class=&quot;tab-content&quot;&gt;
    &lt;div class=&quot;tab-pane fade active in&quot; id=&quot;info&quot;&gt;
       &lt;p&gt;&lt;div class=&quot;form-group&quot;&gt;
          &lt;label for=&quot;textArea&quot; class=&quot;col-lg-2 control-label&quot;&gt;About  &lt;%= @profile.nick %&gt;&lt;/label&gt;
       &lt;div class=&quot;col-lg-10&quot;&gt;
       &lt;pre style=&quot;padding-bottom: 200px;&quot;&gt;&lt;%= @profiles.about %&gt;(THIS IS THE ERROR)&lt;/pre&gt;
      &lt;span class=&quot;help-block&quot;&gt;In Progress&lt;/span&gt;
     &lt;/div&gt;
    &lt;/div&gt;&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  <p>** edit.html.erb (Not _edit, because missing template)**</p>
  <pre><code>&lt;strong&gt;Testing About&lt;/strong&gt;
              &lt;%= form_for :profiles do |f| %&gt;
              &lt;%= f.label :about %&gt;
              &lt;%= f.text_field :about %&gt;
              &lt;div class=&quot;btn btn-primary&quot;&gt;
                  &lt;a href=&quot;http://localhost:3000/profile/&lt;%= @profile.nick %&gt;&quot;&gt;
                      &lt;%= f.submit &quot;Update Profile&quot;, :class =&gt; 'btn btn-primary' %&gt;&lt;/a&gt;
                  &lt;/div&gt;
                  &lt;% end %&gt;
  
                  &lt;% end %&gt;
                  &lt;p&gt;I am editing for&lt;/p&gt; 
                  &lt;%= @profile.nick %&gt;
  </code></pre>
  <p><em>Thanks in advance</em></p>