这是我第一次使用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?
我觉得这是一个非常简单的问题,但我搜索的时间太长而一无所获。
答案 0 :(得分:1)
试试这个,看起来只是围绕最后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?