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) -- Posted via http://www.ruby-forum.com/.
Any ideas? -- Posted via http://www.ruby-forum.com/.
Jordan Arentsen wrote:> Any ideas?-- Posted via http://www.ruby-forum.com/.
On Wednesday, May 17, 2006, at 6:35 AM, Jordan Arentsen wrote:>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) > > >-- >Posted via http://www.ruby-forum.com/. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/railsAssuming that ":promo" is a field of the @business model try this: @business.errors.add(:promo, "Your error message") -- Posted with http://DevLists.com. Sign up and save your mailbox.
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? -- Posted via http://www.ruby-forum.com/.
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. -- Posted via http://www.ruby-forum.com/.
bump -- Posted via http://www.ruby-forum.com/.
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? On 17/05/2006, at 2:35 PM, Jordan Arentsen wrote:> 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) > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails