{"action":"closed","issue":{"url":"https://api.github.com/repos/paulelliott/fabrication/issues/274","repository_url":"https://api.github.com/repos/paulelliott/fabrication","labels_url":"https://api.github.com/repos/paulelliott/fabrication/issues/274/labels{/name}","comments_url":"https://api.github.com/repos/paulelliott/fabrication/issues/274/comments","events_url":"https://api.github.com/repos/paulelliott/fabrication/issues/274/events","html_url":"https://github.com/paulelliott/fabrication/issues/274","id":148226086,"number":274,"title":"Possible to create a random_fabricator?","user":{"login":"swrobel","id":157270,"avatar_url":"https://avatars.githubusercontent.com/u/157270?v=3","gravatar_id":"","url":"https://api.github.com/users/swrobel","html_url":"https://github.com/swrobel","followers_url":"https://api.github.com/users/swrobel/followers","following_url":"https://api.github.com/users/swrobel/following{/other_user}","gists_url":"https://api.github.com/users/swrobel/gists{/gist_id}","starred_url":"https://api.github.com/users/swrobel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swrobel/subscriptions","organizations_url":"https://api.github.com/users/swrobel/orgs","repos_url":"https://api.github.com/users/swrobel/repos","events_url":"https://api.github.com/users/swrobel/events{/privacy}","received_events_url":"https://api.github.com/users/swrobel/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-14T01:35:46Z","updated_at":"2016-04-14T01:50:59Z","closed_at":"2016-04-14T01:50:59Z","body":"I have several STI models where I'd like to be able to randomly fabricate one of them. Here's a simplified example:\r\n\r\n```ruby\r\nFabricator(:question) do\r\n  label do\r\n    [\r\n      \"How would you describe your policy on #{Faker::Hacker.noun.pluralize}?\",\r\n      \"How many #{Faker::Hacker.noun.pluralize} do you operate?\",\r\n      \"Where is the backup for #{Faker::Hacker.noun.pluralize} located?\",\r\n      \"Provide details about your use of #{Faker::Hacker.abbreviation}.\",\r\n      \"Describe your process for #{Faker::Hacker.ingverb}.\",\r\n      \"Provide details about your use of #{Faker::Hacker.adjective} technology.\",\r\n    ].sample\r\n  end\r\nend\r\n\r\nFabricator(:text_question, from: :question) do\r\n  type 'TextQuestion'\r\nend\r\n\r\nFabricator(:select_question, from: :question) do\r\n  type { %w(SingleSelectQuestion MultiSelectQuestion).sample }\r\n  options %w(yes no maybe probably unknown)\r\nend\r\n\r\nFabricator(:single_select_question, from: :select_question) do\r\n  type 'SingleSelectQuestion'\r\nend\r\n\r\nFabricator(:multi_select_question, from: :select_question) do\r\n  type 'MultiSelectQuestion'\r\nend\r\n\r\nFabricator(:random_question, from: [:text_question, :single_select_question, :multi_select_question].sample) do\r\nend\r\n```\r\n\r\nThe part that doesn't work is the dynamic from, which seems to be evaluated at load-time, and not call-time. I've tried wrapping it in a block and a proc, to no avail. Any helpful suggestions?\r\n\r\nIf possible, I'd like to submit a documentation PR, but I've tried everything I can think of."}}