ruby on rails 3.2 - Missing required Parameter:post for new controller action -


i have controller called publish added existing posts_controller.rb when access http://localhost:3000/posts/15/publish returs missing required parameter:post in browser.

i'm not sure missing. point missing piece of puzzle? thank in advance

posts_controller.rb

  # publish /post/1/publish   def publish      @post = post.find(params[:id])      @post.publish = true      @post.published_at = time.now.utc      respond_to |format|        if @post.update_attributes(post_params)          format.html         else          format.html { redirect_to posts_url, notice: 'something went wrong. try again.' }        #  format.json { render json: @post.errors, status: :unprocessable_entity }        end      end      end 

publish.html.erb

  <h1>published post</h1> 

routes.rb

  match 'posts/:id/publish' => 'posts#publish' , :as => :publish   match 'posts/:id/unpublish' => 'posts#unpublish', :as => :unpublish   resources :posts 

i'm using strong_parameters & permitted parameters explicitly defined in posts_controller.rb

 def post_params       params.require(:post).permit(:id, :rental_type, :rent_amt, :street_address, :city, :state, :description, :pet_friendly, :duration, :occupancy, :zip, {:roommate_preference => []}, :latitude, :longitude, :start_date, :publish, :published_at, :user_id)     end 

log:

started "/posts/15/publish" 127.0.0.1 @ 2013-05-19 02:07:29 -0700 creating scope :page. overwriting existing method post.page. processing postscontroller#publish html   parameters: {"id"=>"15"}   post load (15.2ms)  select "posts".* "posts" "posts"."id" = $1 limit 1  [["id", "15"]]   rendered text template (0.0ms) completed 400 bad request in 603ms (views: 62.5ms | activerecord: 382.7ms) 

i've figured out changed @post.update_attributes(post_params) @post.update_attributes(params[:post])


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -