factory girl - Rails association.create and association.create! returns nil -


I'm just throwing it out because I can not really understand it when I call for example User.articles.create! {Title: 'blah'} Zero is returned but the object is formed. I have not seen anything like this before and wondered what else has anyone else?

I have tried Rail 3.2.13 and 3.2.12 and they both do the same thing.

Edit

Create and create both in active records! Ends in this method which is to return the record or throw exceptions. High Definition>

def create_record (attributes, options, raise = false, & amp; block) ActiveRecord :: Increase RecordNotSaved, "You can not call until the parents are saved" End if attributes.is_a? (Array) attributes.collect {| Attr | Create_record (atr, options, review, end block)} and transaction edit-to-target (build_record (options). Record | Yield (record) if block_guwing? Insert_record (record, correct, extend) End End End End

If I'm not wrong Duplicate the real thing that you are working through your predefined factory, the user # article can not return what you think is called when it is called on a factory.

Change

  user.articles.create! {Title: 'blah'}   

to

  ((article, user: user, title: 'bla')   

The association should implement the company through the interface of the factory girl.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

jsp - Google line chart x-axis shrinks on transition -

java - Reaching JTextField in a DocumentListener -