[英]error on running “rails db:seed” after installing ActiveAdmin gem and running “rails g active_admin:install” and “rails db:migrate”
這是我第一次使用ActiveAdmin gem時,我有一個示例應用程序僅由User表組成(這是直到現在的注冊登錄注冊系統),要首先安裝ActiveAdmin gem,我將其添加到我的gemfile中
source 'https://rubygems.org'
ruby "2.5.1"
gem 'rails', '5.1.4'
gem 'activeadmin', '~> 1.3'
gem 'devise', '~> 4.4', '>= 4.4.3'
gem 'bootstrap-sass', '3.3.7'
gem 'bcrypt', '3.1.12'
gem 'faker', '1.7.3'
gem 'puma', '3.9.1'
gem 'sass-rails', '5.0.6'
gem 'uglifier', '3.2.0'
gem 'coffee-rails', '4.2.2'
gem 'jquery-rails', '4.3.1'
gem 'turbolinks', '5.0.1'
gem 'jbuilder', '2.7.0'
gem 'carrierwave', '~> 0.11.2'
group :development, :test do
gem 'sqlite3', '1.3.13'
gem 'byebug', '9.0.6', platform: :mri
end
group :development do
gem 'web-console', '3.5.1'
gem 'listen', '3.1.5'
gem 'spring', '2.0.2'
gem 'spring-watcher-listen', '2.0.1'
end
group :test do
gem 'rails-controller-testing', '1.0.2'
gem 'minitest', '5.10.3'
gem 'minitest-reporters', '1.1.14'
gem 'guard', '2.13.0'
gem 'guard-minitest', '2.4.4'
end
group :production do
gem 'pg', '0.18.4'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
然后我跑了
rails g active_admin:install
安裝活動管理員,然后我運行以遷移更改
rails db:migrate
現在我在運行時出現錯誤
rails db:seed
錯誤是
rails aborted!
SyntaxError: /home/elta3lab/Rails/amazon/db/seeds.rb:25: syntax error, unexpected end-of-input, expecting keyword_end
...ord') if Rails.env.development?
... ^
/home/elta3lab/Rails/amazon/bin/rails:9:in `require'
/home/elta3lab/Rails/amazon/bin/rails:9:in `<top (required)>'
/home/elta3lab/Rails/amazon/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => db:seed
(See full trace by running task with --trace)
知道這就是我的db / seeds.rb文件的內容
User.create!(name: "Ahmed Mohamed Fouad",
email: "ahmedfouad@gmail.com",
password: "12345678",
password_confirmation: "12345678",
activated: true,
activated_at: Time.zone.now)
User.create!(name: "Ahmed Fouad",
email: "elta3lab@gmail.com",
password: "12345678",
password_confirmation: "12345678",
activated: true,
activated_at: Time.zone.now)
99.times do |n|
name = Faker::Name.name
email = "example-#{n+1}@railstutorial.org"
password = "password"
User.create!(name: name,
email: email,
password: password,
password_confirmation: password,
activated: true,
activated_at: Time.zone.now)
endAdminUser.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password') if Rails.env.development?
我覺得這是一個非常簡單的問題,但是我搜索了太長時間卻一無所獲。
試試這個,它看起來像周圍的最后只是一個不平衡的語法end
,
User.create!(name: "Ahmed Mohamed Fouad",
email: "ahmedfouad@gmail.com",
password: "12345678",
password_confirmation: "12345678",
activated: true,
activated_at: Time.zone.now)
User.create!(name: "Ahmed Fouad",
email: "elta3lab@gmail.com",
password: "12345678",
password_confirmation: "12345678",
activated: true,
activated_at: Time.zone.now)
99.times do |n|
name = Faker::Name.name
email = "example-#{n+1}@railstutorial.org"
password = "password"
User.create!(name: name,
email: email,
password: password,
password_confirmation: password,
activated: true,
activated_at: Time.zone.now)
end
AdminUser.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password') if Rails.env.development?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.