[Rails] Validation question
carl
carl at carldr.com
Wed Mar 2 11:46:46 GMT 2005
Hi all,
I have something like this :
user has_many lists
list has_many items
I want to validate that the currently logged-in user is the owner of the list
an item is being added to. I can do it in "item/create" by doing something like :
class item
def create
@list = List.new( @params[ "list" ][ "id" ] )
if @session[ "user" ].lists.include? list
## OK
else
## Not OK
end
end
end
and it works well enough.
However, is this considered the best way of doing this? I think that using
validate() or one of the callback methods would be a neater way of doing it.
Any suggestions?
Regards,
Carl.
More information about the Rails
mailing list