title: update field from a link_to in rails 4
body: <p>I just need a link_to link that automatically updates a value.
  I have done the following:</p>
  
  <p>1) Added the field i want to update into the post_controller permit list:</p>
  
  <pre><code>#post_controller.rb
  def post_params
        params.require(:post).permit(:title, :description, :file, :user_id, :category_id, :revisor_id, :visible)
      end
  </code></pre>
  
  <p>2) Added the link_to link in the view:</p>
  
  <pre><code>&lt;td&gt;&lt;%= link_to 'Publish', post_path(post, visible: true), method: :put %&gt;&lt;/td&gt;
  </code></pre>
  
  <p>any idea what im doing wrong?</p>
  
  <pre><code>#routes.rb
  resources :posts do
      get 'revisions', on: :collection
    end
  </code></pre>
  
  <p>the error i'm getting is:</p>
  
  <pre><code>param is missing or the value is empty: post
  </code></pre>
  
  <p>Here is the controller:</p>
  
  <pre><code>#posts_controller.rb
  class PostsController &lt; ApplicationController
    before_action :set_post, only: [:show, :edit, :update, :destroy]
  
    # GET /posts
    # GET /posts.json
    def index
      @posts = Post.all
    end
  
    def revisions
      @posts = Post.where(revisor_id: current_user.id)
    end
  
    # GET /posts/1
    # GET /posts/1.json
    def show
    end
  
    # GET /posts/new
    def new
      @post = Post.new
    end
  
    # GET /posts/1/edit
    def edit
    end
  
    # POST /posts
    # POST /posts.json
    def create
      @post = Post.new(post_params)
      @post.visible = true
      @post.user_id = current_user.id
      @petition = Petition.new(user_id: current_user.id, category_id: @post.category_id, status: "New")
      @petition.save
      respond_to do |format|
        if @post.save
          format.html { redirect_to @post, notice: 'Post was successfully created.' }
          format.json { render :show, status: :created, location: @post }
        else
          format.html { render :new }
          format.json { render json: @post.errors, status: :unprocessable_entity }
        end
      end
    end
  
    # PATCH/PUT /posts/1
    # PATCH/PUT /posts/1.json
    def update
      respond_to do |format|
        if @post.update(post_params)
          format.html { redirect_to @post, notice: 'Post was successfully updated.' }
          format.json { render :show, status: :ok, location: @post }
        else
          format.html { render :edit }
          format.json { render json: @post.errors, status: :unprocessable_entity }
        end
      end
    end
  
    # DELETE /posts/1
    # DELETE /posts/1.json
    def destroy
      @post.destroy
      respond_to do |format|
        format.html { redirect_to posts_url, notice: 'Post was successfully destroyed.' }
        format.json { head :no_content }
      end
    end
  
    private
      # Use callbacks to share common setup or constraints between actions.
      def set_post
        @post = Post.find(params[:id])
      end
  
      # Never trust parameters from the scary internet, only allow the white list through.
      def post_params
        params.require(:post).permit(:title, :description, :file, :user_id, :category_id, :revisor_id, :visible)
      end
  end
  </code></pre>
  
  <p>Here is the view:</p>
  
  <pre><code>#revisions.html.erb
  &lt;h1&gt;Pending for revision&lt;/h1&gt;
  &lt;table&gt;
    &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Title&lt;/th&gt;
      &lt;th&gt;Description&lt;/th&gt;
      &lt;th&gt;User&lt;/th&gt;
      &lt;th&gt;Category&lt;/th&gt;
      &lt;th&gt;Revisor&lt;/th&gt;
      &lt;th colspan="3"&gt;&lt;/th&gt;
    &lt;/tr&gt;
    &lt;/thead&gt;
  
    &lt;tbody&gt;
    &lt;% @posts.pending_posts.each do |post| %&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;%= post.title %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= post.description %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= post.user_id %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= post.category_id %&gt;&lt;/td&gt;
          &lt;% if !post.revisor_id %&gt;
              &lt;td&gt; No asignado &lt;/td&gt;
          &lt;% else %&gt;
              &lt;td&gt;&lt;%= post.revisor_id %&gt;&lt;/td&gt;
          &lt;% end %&gt;
          &lt;td&gt;&lt;%= link_to 'Publish', post_path(post, visible: true), method: :put %&gt;&lt;/td&gt;
          &lt;!--&lt;td&gt;&lt;%#= link_to 'Edit', edit_petition_path(petition) %&gt;&lt;/td&gt;--&gt;
          &lt;!--&lt;td&gt;&lt;%#= link_to 'Destroy', petition, method: :delete, data: { confirm: 'Are you sure?' } %&gt;&lt;/td&gt;--&gt;
        &lt;/tr&gt;
    &lt;% end %&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Here is the model:</p>
  
  <pre><code>#post.rb
  class Post &lt; ActiveRecord::Base
    belongs_to :category
    belongs_to :user
    has_one :petition
  
    scope :my_revisions, -&gt;(user){ where("posts.user_id = ?", user.id)}
    scope :visible_posts, -&gt; {where(visible: true)}
    scope :pending_posts, -&gt; {where(visible: false)}
  end
  </code></pre>
  
  <p>SERVER LOG:</p>
  
  <pre><code>Started PUT "/posts/12?visible=true" for 127.0.0.1 at 2014-07-16 10:07:31 +0100
  Processing by PostsController#update as HTML
    Parameters: {"authenticity_token"=&gt;"authenticitytoken=", "visible"=&gt;"true", "id"=&gt;"12"}
    Post Load (0.2ms)  SELECT  "posts".* FROM "posts"  WHERE "posts"."id" = ? LIMIT 1  [["id", 12]]
  Completed 400 Bad Request in 2ms
  
  ActionController::ParameterMissing (param is missing or the value is empty: post):
    app/controllers/posts_controller.rb:79:in `post_params'
    app/controllers/posts_controller.rb:51:in `block in update'
    app/controllers/posts_controller.rb:50:in `update'
  
  
    Rendered /home/kbs23/.rvm/gems/ruby-2.1.0@global/gems/actionpack-4.1.2/lib/action_dispatch/middleware/templates/rescues/_source.erb (0.6ms)
    Rendered /home/kbs23/.rvm/gems/ruby-2.1.0@global/gems/actionpack-4.1.2/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.5ms)
    Rendered /home/kbs23/.rvm/gems/ruby-2.1.0@global/gems/actionpack-4.1.2/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.0ms)
    Rendered /home/kbs23/.rvm/gems/ruby-2.1.0@global/gems/actionpack-4.1.2/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (13.7ms)
  </code></pre>
  
  <p>Here are my routes:</p>
  
  <pre><code>#rake routes
           revisions_posts GET    /posts/revisions(.:format)     posts#revisions
                     posts GET    /posts(.:format)               posts#index
                           POST   /posts(.:format)               posts#create
                  new_post GET    /posts/new(.:format)           posts#new
                 edit_post GET    /posts/:id/edit(.:format)      posts#edit
                      post GET    /posts/:id(.:format)           posts#show
                           PATCH  /posts/:id(.:format)           posts#update
                           PUT    /posts/:id(.:format)           posts#update
                           DELETE /posts/:id(.:format)           posts#destroy
  </code></pre>