Skip to content

Instantly share code, notes, and snippets.

@maasha
Last active December 16, 2015 02:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save maasha/5362806 to your computer and use it in GitHub Desktop.
rake routes
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
delete link in view:
<% unless current_user.admin? %>
<!-- <p><%= link_to "Delete Profile", @user, method: :delete, data: { confirm: "Confirm delete" } %></p> -->
<p><%= button_to "Delete Profile", { :action => "delete", :id => @user.id }, :confirm => "Confirm delete", :method => :delete %></p>
<% end %>
controller:
def destroy
User.find(params[:id]).destroy
flash[:success] = "User destroyed."
redirect_to root_url
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment