Reputation: 1635
while setting up a simple Rails app, I met an issue i never had before: the destroy link will not work.
now, my code is:
<td><%= link_to 'Destroy', post, :confirm => 'Are you sure?', :method => :delete %></td>
rather basic, right?
When i click on delete, I get redirected to Show... quite puzzling.
My schema is:
t.string "title"
t.text "content"
t.string "category"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
What am I doing wrong??
Upvotes: 0
Views: 178
Reputation: 10412
You need to include the jQuery for Rails gem in your Gemfile
gem 'jquery-rails'
Then you have to run bundle install
and restart the server. This is because even if you have included in your layout.html.erb the jQuery framework you need the adapter for jQuery to use the unobstrusive scripting.
Upvotes: 4
Reputation: 3312
Make sure that you have JS enabled, and included in application.html.haml
.
You can also try button_to
instead of link_to
.
Upvotes: 2