I''ve seen reference to an ''add'' method, as in Model.add. When and why would I want to use it? Is it related to Model.collection.build? Thanks, David -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070916/b9e5c97a/attachment.html
Can you be more specific? Where have you seen such references? What did they say? Is this even an rspec question? If it''s about Rails models, try the rails list. But if you do, be more specific :) On 9/16/07, David James <davidj503 at gmail.com> wrote:> I''ve seen reference to an ''add'' method, as in Model.add. When and why would > I want to use it? Is it related to Model.collection.build? > > Thanks, > David > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On 16 Sep 2007, at 06:12, David James wrote:> I''ve seen reference to an ''add'' method, as in Model.add. When and > why would I want to use it? Is it related to Model.collection.build?Perhaps you''re thinking of http://api.rubyonrails.org/classes/ ActiveRecord/Errors.html#M000960. You can use it to explicitly add a validation error to an attribute of an ActiveRecord instance. Cheers, -Tom
I wish I was more specific, indeed. :) While scouring the Web for examples of mocking ActiveRecord associations (see other thread), I saw the add method -- but couldn''t figure out what it did. That made me wonder if it was perhaps some special construct in RSpec (perhaps for helping with associations, I didn''t really know). To investigate, I did a code search in the rspec on rails plugin... and saw reference to an add method there (but I wasn''t clear what it did). At that point, I was confused, (obviously!) so just wanted to rule out some possibilities. Your reply helped me put me on the right path. Thanks! -David On 9/16/07, David Chelimsky <dchelimsky at gmail.com> wrote:> > Can you be more specific? Where have you seen such references? What > did they say? Is this even an rspec question? If it''s about Rails > models, try the rails list. But if you do, be more specific :)-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070916/7e823401/attachment.html