ruby on rails - undefined method `valid?' testing with FactoryGirl -


I am the simplest test at the following class (inside model folder):

  Class Offer Attr_accessor: Title ,: Payout ,: Thumbnail Def initial (title, payment, thumbnail) @ title = title @ payout = payout @ thumbnail = thumbnail ending end  

this is not it 'Offer' DB table Objects created outside this square are never saved in a database.

Then I test using rspec:

  Offer a description "There is a valid factory" Hopefully (Factory Gear Cachelet (offer :)) should be authorized End ... end  

and factorial:

  FactoryGear.Define factory: Offer Skip_create title {Faker :: Name.name} payout { Faker :: Number.number (2)} Thumbnail {Faker :: Internet.url} initialize_with {new (title, payout, thumbnail)} end and  

and I get the following error:

  & gt; Undefined method `valid? '# & Lt; For Proposal: 0x00000002b78958 & gt;    

Because your offer category activacikord :: base , you can not find anything that comes with it (like legalization). Is valid? is a method that is provided through the activecuroaded modules, not directly by Ruby, so this will not be available on the original Ruby class.

If you take care of everyone, then you can include the ActiveModel :: Validations module in your class and it will give you the same value as valid -with validates_presence_of , etc.: <: >

  ActiveModel in the class offering: validation ... end  
< P> You can only include ActiveModal such as ActiveRecord's naming and conversion benefits (plus verification) to get some other things.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -