ActiveRecord 'destroy' method returns a boolean value in Ruby on Rails? -


i using ruby on rails 3 , know type of return have following code:

@user.destroy 

i need handle cases on success , fault in someway this:

if @user.destroy   puts "true" else   puts "false" end 

is possible? if so, how?

you should try you're asking before asking. you've got there work fine.

if destroy works, return object (which pass true in if statement) , if not, return false or raise exception, depending on why failed.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -