Reputation: 656
I've got
<%= link_to 'Destroy', project, :method => :delete, :data => { :confirm => 'Are you sure?' } %>
but when I click on "Destroy" in view, it shows me the project (routes me to /project/:id
)
# routes.rb
resources :users
resources :projects do
resources :issues
end
resources :issues
resources :sessions
root :to => "users#index"
match "/auth/:provider/callback" => "sessions#create"
match "/signout" => "sessions#destroy", :as => :signout
# projects_controller.rb
def destroy
@project = Project.find(params[:id])
@project.destroy
respond_to do |format|
format.html { redirect_to projects_url }
format.json { head :no_content }
end
end
But "Edit" works well. Do you know, where is the problem?
and there is an aplication.html.erb
#aplication.html.erb
<!DOCTYPE html>
<html>
<head>
<title>Project manager</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<% if current_user %>
Welcome <%= current_user.username %>
<%= link_to "Signout", signout_path %>
<% else %>
<%= link_to "Sign in with twitter", "/auth/twitter" %>
<% end %>
<%= yield %>
</body>
</html>
and finally aplication.js
#aplication.js
= require jquery
//
= require jquery_ujs
//
= require_tree .
//
= require prototype_nested_form
//
= require jquery_nested_form
= require bootstrap
PS: server restart doesnt help
Upvotes: 0
Views: 1128
Reputation: 656
I've solved it. I don't know why, but when I deleted these two lines
#aplication.js
= require jquery
= require jquery_ujs
everything works fine.
Upvotes: 1
Reputation: 6036
try this
<%= link_to 'Destroy', project, :method => :delete, :confirm => 'Are you sure?' %>
See the doc : http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to
Update
destroy link
has delete method
so that url should look like show
but show action
have get method
when you check rake routes
you can see that.
both destroy and show method display the same url but method is different. for show it's a get and for destroy it's a delete method.
Upvotes: 0