When I tried replacing @post.update with @post.save , as in my code below, it still worked, and it returned true, but the values โโwere not updated.
def create @post = Post.new(post_params) if @post.save redirect_to posts_path, notice: 'Post was successfully created.' else render action: 'new' end end def update respond_to do |format| if @post.update(post_params) format.html { redirect_to @post, notice: 'Post was successfully updated.' } format.json { head :no_content } else format.html { render action: 'new' } format.json { render json: @post.errors, status: :unprocessable_entity } end end end
Below are my rake routes:
$ rake routes 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
Why didn't he update or rewrite my record?
Will using different HTTP requests for the same methods affect them? Can we use PUT , GET , PATCH and DELETE to save when passing with the appropriate syntax?
The question is about guides 4 guides, the first guide .
source share