i've now added validation failure messages like this...

  def self.find_nil_and_save(name)
    resorts = Resort.find(:all, :conditions => {name => nil})
    resorts.each do |resort|
      puts resort.name + " #{name} is empty. Enter a value..."
      new_value = gets.chomp
      puts resort.name + " Thanks, you entered #{new_value}"
      resort.update_attributes(name => new_value)
      # puts resort.name + " updated.. #{name} is now 
#{resort.{name}.to_s}"
      if resort.save
        puts resort.name + " updated.."
      else
        puts resort.name + " not updated.."
        resort.errors.each { |attr,msg| puts "#{attr} - #{msg}" }
      end
    end
  end


which is nice.. but i'd like to refactor

if validation fails it should allow the user to reenter details for that 
resort

also, the whole thing should be wrapped in an "exit" option, at the 
moment i do ctrl+c ! to break out of it.

how do i do that?

bb
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to