title: How to update a record from index in rails
body: <p>I was trying to update a User record (only the "closed" named column) from the user index's view. This is what I tried. But, it is not working. I used Devise gem to generate views and controllers. But, whatever, How can I update a records one particular value, directly from index(without going to edit's view). It would be very helpful, if someone would help me.</p>
  
  <pre><code>&lt;% @users.each do |user| %&gt;
                  &lt;tr&gt;
                    &lt;td&gt; &lt;%= user.last_name %&gt;&lt;/td&gt;
                    &lt;td&gt; &lt;%= user.telephone %&gt;&lt;/td&gt;
                    &lt;td&gt; &lt;%= form_for user do |f| %&gt;
                      &lt;% if user.closed %&gt;
                        &lt;%= f.hidden_field :closed, value: false %&gt;
                        &lt;%= f.submit "Activate" %&gt;
                        &lt;% else %&gt;
                          &lt;%= f.hidden_field :closed, value: true %&gt;
                          &lt;%= f.submit "Deactivate" %&gt;
                        &lt;% end %&gt;
                    &lt;% end %&gt; &lt;/td&gt;
                        &lt;%= link_to 'Remove', user_destroy_path(user), method: :delete, data: { confirm: 'Are you sure?' } %&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                &lt;% end %&gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>def user_index
      if current_user.admin?
        if params[:user_search].present?
          @users = User.search_user(params[:user_search]).super_admin
        else
          @users = User.super_admin
        end
      else
        if params[:user_search].present?
          @users = User.search_user(params[:user_search]).admin
        else
          @users = User.admin
        end
      end
      respond_to do |format|
        format.html
        format.csv { send_data User.to_csv, type: 'text/csv', filename: "users.csv" }
      end
    end
  </code></pre>
  
  <p>here is my controller. Actually there is also something done to search the users</p>