Skip to content

Instantly share code, notes, and snippets.

@chuckbergeron
Created December 21, 2011 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuckbergeron/1507167 to your computer and use it in GitHub Desktop.
Save chuckbergeron/1507167 to your computer and use it in GitHub Desktop.
# Faker stuff for dev
if Rails.env.development?
require "faker"
%w[ Event Recipe ].each { |const| Object.const_get( const ).delete_all }
# Standard MEEZ Events
20.times do
e = Event.create( {
:name => Faker::Name.name,
:body => "<p>#{Faker::Lorem.paragraph}</p>",
:start_date => Time.now,
:end_date => Time.now,
:display_times => rand( 2 ),
:ongoing => rand( 2 ),
:tba => rand( 2 ),
:style => Event::STYLES[rand(Event::STYLES.size)][1].to_s,
:location => Event::LOCATIONS[rand(Event::LOCATIONS.size)][1].to_s,
:status => "approved"
} )
end
# User-submitted events
20.times do
e = Event.create( {
:frontend => true,
:name => Faker::Name.name,
:body => "<p>#{Faker::Lorem.paragraph}</p>",
:start_date => Time.now,
:end_date => Time.now,
:display_times => rand( 2 ),
:ongoing => rand( 2 ),
:tba => rand( 2 ),
:users_name => Faker::Name.name,
:users_phone => Faker::PhoneNumber.phone_number,
:users_email => Faker::Internet.email,
:users_info => Faker::Lorem.paragraph,
:status => Event::STATES[rand(Event::STATES.size)][1].to_s
} )
end
# Recipes
40.times do
r = Recipe.create( {
:created_at => Time.random,
:name => Faker::Name.name,
:body => "<p>#{Faker::Lorem.paragraph}</p>",
:ingredients => "<ul><li>#{Faker::Lorem.words.each(&:capitalize!).join(" ")}</li><li>#{Faker::Lorem.words.each(&:capitalize!).join(" ")}</li><li>#{Faker::Lorem.words.each(&:capitalize!).join(" ")}</li><li>#{Faker::Lorem.words.each(&:capitalize!).join(" ")}</li></ul>",
:directions => "<p>#{Faker::Lorem.paragraph}</p>"
} )
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment