Forum: Ruby on Rails Errors are not being added

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C73d8c07965a0aa9929043454e5eab2f?d=identicon&s=25 Jordan Arentsen (Guest)
on 2006-05-17 06:35
In the following code, I'm trying to add an error ':promo', but this
error doesn't seem to add when I debug it. Does anyone have any idea why
this isn't working for me?

@business = Business.new(params[:business])
@business.errors.add(:promo)
C73d8c07965a0aa9929043454e5eab2f?d=identicon&s=25 Jordan Arentsen (Guest)
on 2006-05-17 07:12
Any ideas?
C73d8c07965a0aa9929043454e5eab2f?d=identicon&s=25 Jordan Arentsen (Guest)
on 2006-05-17 14:39
Jordan Arentsen wrote:
> Any ideas?
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 Richard Williams (Guest)
on 2006-05-17 15:00
(Received via mailing list)
On Wednesday, May 17, 2006, at 6:35 AM, Jordan Arentsen wrote:
>_______________________________________________
>Rails mailing list
>Rails@lists.rubyonrails.org
>http://lists.rubyonrails.org/mailman/listinfo/rails


Assuming that ":promo" is a field of the @business model try this:

  @business.errors.add(:promo, "Your error message")
C73d8c07965a0aa9929043454e5eab2f?d=identicon&s=25 Jordan Arentsen (Guest)
on 2006-05-17 15:18
Richard Williams wrote:
> On Wednesday, May 17, 2006, at 6:35 AM, Jordan Arentsen wrote:
>>_______________________________________________
>>Rails mailing list
>>Rails@lists.rubyonrails.org
>>http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
> Assuming that ":promo" is a field of the @business model try this:
>
>   @business.errors.add(:promo, "Your error message")

So the error added must be a field of the @business model?
C73d8c07965a0aa9929043454e5eab2f?d=identicon&s=25 Jordan Arentsen (Guest)
on 2006-05-17 15:21
Richard Williams wrote:
> On Wednesday, May 17, 2006, at 6:35 AM, Jordan Arentsen wrote:
>>_______________________________________________
>>Rails mailing list
>>Rails@lists.rubyonrails.org
>>http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
> Assuming that ":promo" is a field of the @business model try this:
>
>   @business.errors.add(:promo, "Your error message")

I tried this and it didn't work.
C73d8c07965a0aa9929043454e5eab2f?d=identicon&s=25 Jordan Arentsen (Guest)
on 2006-05-17 20:10
bump
C9c7a65848f13e2b1a226bbe43bc3672?d=identicon&s=25 Pete Yandell (pete)
on 2006-05-18 07:34
(Received via mailing list)
You need to provide some more context. How are you determining that
this doesn't work? Can you post the complete code for your method,
rather than just two lines?
This topic is locked and can not be replied to.