I have a couple of simple models that are associated like so:
MODELS
class Task < ActiveRecord::Base
belongs_to :user
validates :name, :presen
When you use the newer validates :name
format, you can put multiple validations in one line rather than having to have multiple lines for each type of validation. Because of this, when Rails hits your :message
parameter, it thinks it's a validation method rather than a message associated with :presence
. Try this instead:
validates :name, :presence => {:message => 'Name cannot be blank, Task not saved'}
Also, depending on how you display your errors, this error may actually show up as 'Name Name cannot be....'; if so, you'll want to set the message to just 'cannot be blank, Task not saved'.