how do you render a js.erb file with a link?
Let's say you have a link like this:
<%= link_to "Add Topics", ???, :remote => true, :id => 'edit_topics开发者_C百科_link' %>
What do you put where the ??? is to render a js.erb file in the same directory?
You should have an action in your controller which responds_to with format.js
and the route for it.
def action
...
respond_to do |format|
format.js {}
end
end
the in routes
resources :something do
member do
get or post :action, :as => :blah
end
end
Then if you run rake routes
you will see something like blah_something_path
which you can use in link_to
精彩评论