Displaying 1 result from an estimated 1 matches for "destroy_your_own".
2006 Nov 17
4
before_destroy and sessions
(Semi-newbie.) I want to ensure a user''s able to destroy only his own
objects. I''ve set session info at login:
session[:user_id] = user.id
Now I try this in the model of my deletable objects:
before_destroy :destroy_your_own
def destroy_your_own
raise "Can''t delete that!" unless session[:user_id] == self.user.id
end
which snags EVERY attempted destroy. What am I doing wrong? Better
ideas?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
Yo...