I need to modify the error messages of devise. I want to change the message "is Invalid" to "Es inválido" . The problem is that I have to go to change these messages in the gem. Can I overwrite these messages in the model User

Rails console

1.9.3-p547 :014 &gt; user.save
 =&gt; false 
1.9.3-p547 :015 &gt; user.errors
 =&gt; {:email=&gt;["is invalid"], :password=&gt;["is too short (minimum is 6 characters)"]} 
1.9.3-p547 :016 &gt; 


User model

class User &lt; ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :token_authenticatable, :confirmable, :lockable and :timeoutable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me
end



Question: dynamic call of functions and generator function (python)
Answer: When you cann a generator function, it only returns an iterator. You should
try to call the generator's next method to execute the body of generator function.
Try this:

class foo:
   def f0(self, s):
      print s

   def f1(self, s):
      print "not " + s
      yield 1

   def run(self):
      handlers={0 : self.f0, 1 : self.f1}
      for _, func in handlers.iteritems():
          res = func('good')
          if hasattr(res, 'next'):
              next(res)

bar = foo()
bar.run()