私はプロジェクトを壊したと思います。 :(私は数多くの変更を加えましたが、そのうちの1つはリソースを入れ替えて入れ子にしていました(浅い:真)。私はDBをもう一度シードしようとしていて、TypeErrorを取得しています。 。私はStackOverflowの通過見てきたし、一人は、同様の問題が、ノーの答えを持っていた私は、インターネット上の他の場所に動作します答えを見つけることができますネストされたリソースを持つシードDB:シンボルの整数への暗黙的な変換なし
マイroutesファイル:
Goalie::Application.routes.draw do
resources :users, shallow: true do
resources :goals
resources :steps
resources :habits
end
マイスキーマルックスを。
ActiveRecord::Schema.define(:version => 20161121101351) do
create_table "users", :force => true do |t|
t.integer "user_id"
t.string "firstname"
t.string "lastname"
t.string "username"
t.string "password"
t.string "userEmail"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "goals", :force => true do |t|
t.integer "goal_id"
t.string "name"
t.string "description"
t.date "deadline"
t.boolean "completed"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "steps", :force => true do |t|
t.integer "step_id"
t.string "name"
t.string "description"
t.boolean "completed"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "habits", :force => true do |t|
t.integer "habit_id"
t.string "name"
t.string "description"
t.boolean "frequency"
t.integer "frequencytime"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
end
seed.rbファイルは次のようになります。
params = { :user =>
{
:user_id => '1',
:firstname => 'Salaman',
:lastname=> 'Rushdie',
:username=> 'bigboss',
:password=> 'admin',
:userEmail=> '[email protected]',
:goals_attributes => {
:goal_id => '1',
:name => 'Lose weight',
:description => 'Lose 30lb',
:deadline => '25/12/2016',
:completed => false,
:steps_attributes => {
:step_id => '1',
:name => 'Work out',
:description => 'Exercise to achieve weight loss goal',
:completed => false,
:habits_attributes => {
:habit_id => '1',
:name => 'Gym',
:description => 'Go to the gym 5 times a week',
:frequency => 'true',
:frequencytime => '5',
}
}
}
}
}
User.create!(params[:user])
そして、私はDBをシードしようとすると、私はこのメッセージが表示されます。
$ rake db:seed --trace
** Invoke db:seed (first_time)
** Execute db:seed
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:abort_if_pending_migrations
rake aborted!
TypeError: no implicit conversion of Symbol into Integer
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activerecord-3.2.8/lib/acti
ve_record/nested_attributes.rb:396:in `[]'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activerecord-3.2.8/lib/acti
ve_record/nested_attributes.rb:396:in `block in assign_nested_attributes_for_col
lection_association'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activerecord-3.2.8/lib/acti
ve_record/nested_attributes.rb:396:in `map'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activerecord-3.2.8/lib/acti
ve_record/nested_attributes.rb:396:in `assign_nested_attributes_for_collection_a
ssociation'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activerecord-3.2.8/lib/acti
ve_record/nested_attributes.rb:288:in `goals_attributes='
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activerecord-3.2.8/lib/acti
ve_record/attribute_assignment.rb:94:in `block in assign_attributes'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activerecord-3.2.8/lib/acti
ve_record/attribute_assignment.rb:93:in `each'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activerecord-3.2.8/lib/acti
ve_record/attribute_assignment.rb:93:in `assign_attributes'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activerecord-3.2.8/lib/acti
ve_record/base.rb:498:in `initialize'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activerecord-3.2.8/lib/acti
ve_record/persistence.rb:44:in `new'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activerecord-3.2.8/lib/acti
ve_record/persistence.rb:44:in `create'
c:/users/cat/Goalie/db/seeds.rb:39:in `<top (required)>'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-3.2.8/lib/act
ive_support/dependencies.rb:245:in `load'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-3.2.8/lib/act
ive_support/dependencies.rb:245:in `block in load'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-3.2.8/lib/act
ive_support/dependencies.rb:236:in `load_dependency'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-3.2.8/lib/act
ive_support/dependencies.rb:245:in `load'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-3.2.8/lib/rails/en
gine.rb:520:in `load_seed'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activerecord-3.2.8/lib/acti
ve_record/railties/databases.rake:309:in `block (2 levels) in <top (required)>'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-11.3.0/lib/rake/task.r
b:248:in `call'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-11.3.0/lib/rake/task.r
b:248:in `block in execute'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-11.3.0/lib/rake/task.r
b:243:in `each'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-11.3.0/lib/rake/task.r
b:243:in `execute'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-11.3.0/lib/rake/task.r
b:187:in `block in invoke_with_call_chain'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-11.3.0/lib/rake/task.r
b:180:in `invoke_with_call_chain'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-11.3.0/lib/rake/task.r
b:173:in `invoke'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-11.3.0/lib/rake/applic
ation.rb:152:in `invoke_task'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-11.3.0/lib/rake/applic
ation.rb:108:in `block (2 levels) in top_level'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-11.3.0/lib/rake/applic
ation.rb:108:in `each'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-11.3.0/lib/rake/applic
ation.rb:108:in `block in top_level'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-11.3.0/lib/rake/applic
ation.rb:117:in `run_with_threads'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-11.3.0/lib/rake/applic
ation.rb:102:in `top_level'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-11.3.0/lib/rake/applic
ation.rb:80:in `block in run'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-11.3.0/lib/rake/applic
ation.rb:178:in `standard_exception_handling'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-11.3.0/lib/rake/applic
ation.rb:77:in `run'
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-11.3.0/exe/rake:27:in
`<top (required)>'
c:/RailsInstaller/Ruby2.1.0/bin/rake:23:in `load'
c:/RailsInstaller/Ruby2.1.0/bin/rake:23:in `<main>'
Tasks: TOP => db:seed
はあなたが必要な場合があります他の情報がありますなら、私に教えてください。私は毛を引き出してコードを見つめ続けます。 :)
猫