Reputation: 561
I have a link in a Rails view such that when it's clicked on, I want it to call a particular method but NOT leave the page. I can get it to call the method but it always looks for a non-existent template.
I was told something like this would be possible with :remote => true, but it seems to completely ignore it. In the view (create.html.erb), it looks something like this:
<%= link_to 'Do something', foo_bar_index_path(:param1 => "value", :param2 => "value"), :remote => true %>
I have a defined route in routes.rb:
resources :bar do
collection do
get 'foo'
end
end
In the 'bar' controller, it does call the "foo" method:
def foo
# it does the stuff that's here
end
Then it gives me the following error:
Missing template bar/foo, application/foo with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in: * "/myrailspath/rails-root/app/views"
How can I change this to still call the method but not leave the page?
Upvotes: 0
Views: 92
Reputation: 5111
Just check you have these two lines in your application.js
//= require jquery
//= require jquery_ujs
Upvotes: 1