Alex Colbert
Alex Colbert

Reputation: 19

Bug when attempting to rake db:reset

I am attempting to setup an admin account for my first rails app.

This is the code I used to create the admin account:

admin = User.new(
name: 'Admin User', 
email: '[email protected]',
password: 'helloworld',
password_confirmation: 'helloworld')
admin.skip_confirmation! 
admin.save 
admin.update_attribute(:role, 'admin')

Here is the code in question that is failing in Sublime:

50.times do
Post.create!(
user:   users.sample,
topic: topics.sample.
title:  Faker::Lorem.sentence
body:   Faker::Lorem.paragraph
)
end

In terminal I am receiving this error message:

rake aborted!

SyntaxError: /Users/Alex/Desktop/code/Bloccit/db/seeds.rb:39: syntax error, unexpected ':', expecting ')'
 title:  Faker::Lorem.sentence
       ^
/Users/Alex/Desktop/code/Bloccit/db/seeds.rb:40: syntax error, unexpected ':', expecting keyword_end
 body:   Faker::Lorem.paragraph
      ^
/Users/Alex/Desktop/code/Bloccit/db/seeds.rb:41: syntax error, unexpected ')', expecting  keyword_end

When I added the admin account, it appeared to add fine but after continuing on with my assignment I needed to log in with the admin account. After attempting it, it states the login information was incorrect. So I wanted to reset the DB to start over and this is where I am at now. Please help.

Upvotes: 2

Views: 46

Answers (1)

Arup Rakshit
Arup Rakshit

Reputation: 118299

You missed comma separators after topic: topics.sample and title: Faker::Lorem.sentence.

50.times do
  Post.create!(
               user:   users.sample,
               topic: topics.sample, # <~~ Here
               title:  Faker::Lorem.sentence, # <~~ Here
               body:   Faker::Lorem.paragraph
              )
end

Upvotes: 1

Related Questions