title: Rails routing to update a model without passing an :id
body: <p>I have a pretty basic 'User' model, control &amp; views for a Rails app.  I am trying to add a 'profile' section where the user can update their user info after logging in (and storing their user_id as a session variable).</p>
  
  <p>I have scaffolded a basic 'profile' model, controller and views (_form, index and edit all using simple_form).  The model is empty and the views are pretty much a copy of the user views except I have moved the 'show' format to the profile index view.  In my controller I pretty much copied the user controller, deleted the new, create, show and destroy actions.</p>
  
  <p>Here is what I have:</p>
  
  <pre><code>class ProfileController &lt; ApplicationController
    def index
      @profile = User.find(session[:user_id])
    end
  
    def edit
      @profile = User.find(session[:user_id])
    end
  
    def update
      @profile = User.find(session[:user_id])
  
      respond_to do |format|
        if @profile.update_attributes(params[:profile])
          redirect_to @profile, notice: 'Profile was successfully updated.'
        else
          render action: "edit"
        end
      end
    end
  
   end
  </code></pre>
  
  <p>I tried both of these routes formats:</p>
  
  <pre><code>  match "profile" =&gt; "profile#index"  
    match "profile/edit" =&gt; "profile#edit"
    match "profile/update" =&gt; "profile#update"
  </code></pre>
  
  <p>and </p>
  
  <pre><code>  controller :profile do
      put 'profile/update' =&gt; :update
      get 'profile' =&gt; :index
      get 'profile/edit' =&gt; :edit
    end
  </code></pre>
  
  <p>When I load ~/profile/edit/ the form renders properly and my fields populate.  I am using simple_form and here is the start of my _form.html.erb file:</p>
  
  <p><code>&lt;%= simple_form_for @profile, :url =&gt; url_for(:action =&gt; 'update', :controller =&gt; 'profile'), :html =&gt; { :id =&gt; "edit_profile", :class =&gt; 'form-horizontal' }, :method =&gt; 'put' do |f| %&gt;</code></p>
  
  <p>but simple_form still passes <code>for="user_***"</code> to all the field inputs.</p>
  
  <p>I updated <code>@profile.update_attributes(params[:profile])</code> to <code>@profile.update_attributes(params[:user])</code> thinking that was the issue.  When I click 'Update User' (still references the User model). The form reloads to ~/profile/update but nothing happens.</p>
  
  <p>I am pretty sure I am missing an obvious routing / model issue here but I can't seem to figure this out on my own.</p>