Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add ability to delete bookmarklets

  • Loading branch information...
commit c166de8ea6f7be01e8b3c7bf6592c808413576df 1 parent cfcfd5a
@nakajima authored
View
10 app/controllers/bookmarklets_controller.rb
@@ -77,7 +77,15 @@ def update
# DELETE /bookmarklets/1
# DELETE /bookmarklets/1.xml
def destroy
- redirect_to Bookmarklet.find(params[:id])
+ if session[:owns].include?(params[:id])
+ @bookmarklet = Bookmarklet.find(params[:id])
+ @bookmarklet.destroy
+ flash[:notice] = 'Your bookmark has been deleted.'
+ redirect_to '/'
+ else
+ flash[:notice] = 'No dice. Try again.'
+ redirect_to :action => 'login'
+ end
end
private
View
4 app/views/bookmarklets/edit.html.erb
@@ -49,6 +49,8 @@
</div>
<p class="last">
- <%= f.submit 'Save Bookmarklet', :disable_with => "Saving Bookmarklet..." %> or <%= link_to 'Back', @bookmarklet %>
+ <%= f.submit 'Save Bookmarklet', :disable_with => "Saving Bookmarklet..." %>
+ or <%= link_to 'Back', @bookmarklet %>
+ or <%= link_to 'Delete', @bookmarklet, :method => :delete, :confirm => "Click OK to delete this bookmarklet forever." %>
</p>
<% end %>
Please sign in to comment.
Something went wrong with that request. Please try again.