Created
October 6, 2013 21:59
-
-
Save TheAshwanik/6859666 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#in your view | |
<%= form_for @post, remote: true do |f| %> | |
#form inputs | |
<% end %> | |
#then in your controller | |
def do_something | |
@post = Post.find(params[:id]) | |
end | |
#in your views/posts/ create a file named do_something.js.erb (replace 'do_something' with the name of your controller's action) | |
#this is an erb embedded javascript file where you can handle your response. | |
<% if @post %> | |
console.log('≤%= @post.title %>'); | |
<% else %> | |
console.log('No post found'); | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment