thoughtbot / ios-on-rails

A guide to building a Rails API and iOS app
Other
76 stars 6 forks source link

create some seed data in seeds.rb #102

Closed josephecombs closed 9 years ago

josephecombs commented 9 years ago

Every table should have some seed data placed in seeds.rb to allow us to quickly inspect the rails api endpoint(s)

josephecombs commented 9 years ago

I recommend the faker gem to accomplish this: https://github.com/stympy/faker

jessieay commented 9 years ago

Good idea! I am on vacation this week but pull requests are welcome! :)

— Sent from Mailbox

On Tue, Dec 30, 2014 at 2:37 PM, Joseph Combs notifications@github.com wrote:

Every table should have some seed data placed in seeds.rb to allow us to quickly inspect the rails api endpoint(s)

Reply to this email directly or view it on GitHub: https://github.com/thoughtbot/ios-on-rails/issues/102

josephecombs commented 9 years ago

I've never actually created a new branch in a 3rd party's repo so you'll have to bear with me if I am doing something inept:

1.) Created a branch locally (I named it iss102 to correspond to this issue number) 2.) Made changes to seeds.rb to implement faker 3.) Committed those changes in the iss102 branch 4.) "git push origin iss102" results in: "remote: Repository not found. fatal: repository 'https://github.com/thoughtbot/ios-on-rails.git/' not found" 5.) This seems like a permissions issue. I attempted to create the branch "iss102" in the top level by following this tutorial: https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/ but was not allowed to create a branch if the existing branch name did not exist.

In any event, here is the solution to this issue: a.) add "gem 'faker'" to gemfile b.) add this code to the currently empty seeds.rb:

create seed events

10.times do |i| Event.create({ name: Faker::Name.name, ended_at: Faker::Time.forward(14, :evening), started_at: Faker::Time.backward(14, :morning), user_id: i + 1, address: Faker::Address.street_address, lat: Faker::Address.latitude, lon: Faker::Address.longitude }) end

create seed users

10.times do |i| User.create({ device_token: Faker::Number.number(10).to_s, }) end

create seed attendances

10.times do |i| Attendance.create({ event_id: i + 1, user_id: i + 1 }) end

jessieay commented 9 years ago

Hi Joseph! I believe that readers do not have commit abilities in this repo, but you can still make a pull request by forking it. If you fork, clone your fork, and make the changes in your version (on master or any branch) you should see a "pull request" button on your fork which will lead you through the steps of submitting a PR to the original repo. 

Hope this helps! I can send more detailed instructions if this is confusing. Happy new year!!!

— Sent from Mailbox

On Wed, Dec 31, 2014 at 6:04 PM, Joseph Combs notifications@github.com wrote:

I've never actually created a new branch in a 3rd party's repo so you'll have to bear with me if I am doing something inept: 1.) Created a branch locally (I named it iss102 to correspond to this issue number) 2.) Made changes to seeds.rb to implement faker 3.) Committed those changes in the iss102 branch 4.) "git push origin iss102" results in: "remote: Repository not found. fatal: repository 'https://github.com/thoughtbot/ios-on-rails.git/' not found" 5.) This seems like a permissions issue. I attempted to create the branch "iss102" in the top level by following this tutorial: https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/ In any event, here is the soltion to this issue: a.) add "gem 'faker'" to gemfile b.) add this code to the currently empty seeds.rb:

create seed events

10.times do |i| Event.create({ name: Faker::Name.name, ended_at: Faker::Time.forward(14, :evening), started_at: Faker::Time.backward(14, :morning), user_id: i + 1, address: Faker::Address.street_address, lat: Faker::Address.latitude, lon: Faker::Address.longitude }) end

create seed users

10.times do |i| User.create({ device_token: Faker::Number.number(10).to_s, }) end

create seed attendances

10.times do |i| Attendance.create({ event_id: i + 1, user_id: i + 1 })

end

Reply to this email directly or view it on GitHub: https://github.com/thoughtbot/ios-on-rails/issues/102#issuecomment-68479976

josephecombs commented 9 years ago

Thanks for the help, I figured it out! The pull request is there now.

On Wed, Dec 31, 2014 at 8:42 PM, Jessie A. Young notifications@github.com wrote:

Hi Joseph! I believe that readers do not have commit abilities in this repo, but you can still make a pull request by forking it. If you fork, clone your fork, and make the changes in your version (on master or any branch) you should see a "pull request" button on your fork which will lead you through the steps of submitting a PR to the original repo.

Hope this helps! I can send more detailed instructions if this is confusing. Happy new year!!!

— Sent from Mailbox

On Wed, Dec 31, 2014 at 6:04 PM, Joseph Combs notifications@github.com wrote:

I've never actually created a new branch in a 3rd party's repo so you'll have to bear with me if I am doing something inept: 1.) Created a branch locally (I named it iss102 to correspond to this issue number) 2.) Made changes to seeds.rb to implement faker 3.) Committed those changes in the iss102 branch 4.) "git push origin iss102" results in: "remote: Repository not found. fatal: repository 'https://github.com/thoughtbot/ios-on-rails.git/' not found" 5.) This seems like a permissions issue. I attempted to create the branch "iss102" in the top level by following this tutorial: https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/ In any event, here is the soltion to this issue: a.) add "gem 'faker'" to gemfile b.) add this code to the currently empty seeds.rb:

create seed events

10.times do |i| Event.create({ name: Faker::Name.name, ended_at: Faker::Time.forward(14, :evening), started_at: Faker::Time.backward(14, :morning), user_id: i + 1, address: Faker::Address.street_address, lat: Faker::Address.latitude, lon: Faker::Address.longitude }) end

create seed users

10.times do |i| User.create({ device_token: Faker::Number.number(10).to_s, }) end

create seed attendances

10.times do |i| Attendance.create({ event_id: i + 1, user_id: i + 1 })

end

Reply to this email directly or view it on GitHub:

https://github.com/thoughtbot/ios-on-rails/issues/102#issuecomment-68479976

— Reply to this email directly or view it on GitHub https://github.com/thoughtbot/ios-on-rails/issues/102#issuecomment-68480322 .

jessieay commented 9 years ago

Closing this since we have the PR to discuss :)