Skip to content

Instantly share code, notes, and snippets.

@mkhairi
Last active October 10, 2016 02:51
Show Gist options
  • Save mkhairi/eee1bf67f4dbb51acc65db74ead87af9 to your computer and use it in GitHub Desktop.
Save mkhairi/eee1bf67f4dbb51acc65db74ead87af9 to your computer and use it in GitHub Desktop.
#respond remote true redirect
def create
@post = Post.new(post_params)
respond_to do |format|
if @post.save
format.js { redirect_to post_comments_path(@post), turbolinks: false}
#or
#redirect_to post_comments_path(@post), status: 303, turbolinks: false
else
format.html { render :new }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment