Commit 113a9619

mo k <mo@mokhan.ca>
2012-03-22 02:43:00
add delete creation link.
1 parent f66c93a
Changed files (2)
app
models
views
creations
app/models/user.rb
@@ -19,4 +19,8 @@ class User < ActiveRecord::Base
   def already_likes(creation)
     Favorite.where("user_id = ? AND creation_id = ?", self.id, creation.id).exists?
   end
+
+  def owns(creation)
+    creation.user == self
+  end
 end
app/views/creations/show.html.erb
@@ -6,8 +6,9 @@
   <h1>
     <%= @creation.name %> 
     <small>
-      <% if @creation.user == current_user %>
+      <% if current_user.owns(@creation) %>
         <%= link_to '(edit)', edit_creation_path(@creation) %> 
+        <%= link_to '(delete)', creation_path(@creation),:confirm => "Are you sure", :method => :delete %> 
       <% end %>
       submitted by <%= link_to @creation.user.name, profile_path(@creation.user) %> 
   </small>