Skip to content

Instantly share code, notes, and snippets.

@TheAshwanik
Created October 6, 2013 21:59
Show Gist options
  • Save TheAshwanik/6859666 to your computer and use it in GitHub Desktop.
Save TheAshwanik/6859666 to your computer and use it in GitHub Desktop.
#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