Rails fabricator - how to get value from association field? -



Rails fabricator - how to get value from association field? -

let's have model user has many notes. each note has field user_name. notes fabricator this:

fabricator(:note, class_name: note) user content faker::lorem.paragraph(1) user_name user.full_name end

what i'm trying set user_name value full_name method user exists. i'm getting next error:

undefined method `full_name' #<fabrication::schematic::attribute:0x0000000a279c50>

any help appreciated.

found out in documentation there attributes hash can use:

fabricator(:note, class_name: note) user content faker::lorem.paragraph(1) user_name { |attrs| attrs[:user].full_name } end

ruby-on-rails ruby-on-rails-4 fabrication-gem

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -