{"action":"closed","issue":{"url":"https://api.github.com/repos/paulelliott/fabrication/issues/277","repository_url":"https://api.github.com/repos/paulelliott/fabrication","labels_url":"https://api.github.com/repos/paulelliott/fabrication/issues/277/labels{/name}","comments_url":"https://api.github.com/repos/paulelliott/fabrication/issues/277/comments","events_url":"https://api.github.com/repos/paulelliott/fabrication/issues/277/events","html_url":"https://github.com/paulelliott/fabrication/issues/277","id":148900818,"number":277,"title":"How to accept terms (non-attribute field) in Fabrication?","user":{"login":"oasisweng","id":1996213,"avatar_url":"https://avatars.githubusercontent.com/u/1996213?v=3","gravatar_id":"","url":"https://api.github.com/users/oasisweng","html_url":"https://github.com/oasisweng","followers_url":"https://api.github.com/users/oasisweng/followers","following_url":"https://api.github.com/users/oasisweng/following{/other_user}","gists_url":"https://api.github.com/users/oasisweng/gists{/gist_id}","starred_url":"https://api.github.com/users/oasisweng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oasisweng/subscriptions","organizations_url":"https://api.github.com/users/oasisweng/orgs","repos_url":"https://api.github.com/users/oasisweng/repos","events_url":"https://api.github.com/users/oasisweng/events{/privacy}","received_events_url":"https://api.github.com/users/oasisweng/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-16T23:02:03Z","updated_at":"2016-04-16T23:06:16Z","closed_at":"2016-04-16T23:06:16Z","body":"I want to fabricate my Staff model that has a virtual variable `terms` to ensure users to accept terms and conditions when they sign up. However, `terms` is not a column for Staff table. I know I can use `if` to make `terms` check a conditional validation. But it will give me `Terms must be accepted` error if I don't.\r\n\r\n**What should I do, in this case, to assign a value to a virtual variable such as `terms` to allow Fabricate(:staff) to pass the `validate_acceptance_of` test?**\r\n\r\n\r\nMy `Staff.rb` looks like this:\r\n\r\n```\r\nclass Staff < ActiveRecord::Base\r\n  # Virtual Variable\r\n  attr_accessor :terms\r\n  ...\r\n  validates_acceptance_of     :terms\r\nend\r\n```\r\n\r\nI made a Staff fabrication like this:\r\n\r\n```\r\nFabricator(:staff) do\r\n  profile { }\r\n  work_no { }\r\n  position {}\r\n  phone_no {}\r\n  password {}\r\n  before_validation {\r\n    |staff, transients| \r\n    staff.terms = true \r\n  }\r\n  \r\nend\r\n```\r\n\r\nWhen I call `Fabricate(:staff)` from rails console, it gives me this error:\r\n\r\n```\r\nActiveRecord::RecordInvalid: Validation failed: Terms must be accepted\r\n```\r\n\r\n"}}