我真的需要将数据部署到我的heroku应用程序,但我不明白它为什么不能正常工作。我已经阅读了文档,并且我已经在seeds.rb文件中播种了我的数据库,如下所示:
user = User.create(band_name: "The Rubies", email: "therubies@gmail.com", user_name: "therubies1000", password: "password", password_confirmation: "password")
MusicVideo.create([
{song_title: "Ruby Gems"
venue: "The Gypsy Lounge"
location: "Boston"
description: "First time in Boston"
url_id: "http://vimeo.com/75032263"
name: "hiphop"
user: user},
{song_title: "Ruby Blood Love"
venue: "The Masquerade"
location: "Atlanta"
description: "5th circuit tour at the Masquerade"
url_id: "http://vimeo.com/28020056"
name: "alternative"
user: user},
{song_title: "Ruby vs. Python"
venue: "Launch Academy"
location: "Boston"
description: "A love song about Ruby"
url_id: "http://vimeo.com/67825649"
name: "hiphop"
user: user},
{song_title: "Farewell Launch Academy"
venue: "Los Locos Tavern"
location: "New York City"
description: "My heartfelt farewell balad for Launch Academy"
url_id: "http://vimeo.com/60347451"
name: "country"
user: user},
{song_title: "Solar Molecules"
venue: "Miami Central"
location: "Miami"
description: "Our band's first single"
url_id: "http://vimeo.com/61605196"
name: "pop"
user: user},
{song_title: "Lovely Miss Ruby!"
venue: "2120 nightclub"
location: "Boston"
description: "The song that made us famous"
url_id: "http://vimeo.com/68269314"
name: "pop"
user: user},
{song_title: "Lady Ruby vs. Lady Python"
venue: "Longhorn Bar & Grill"
location: "Austin"
description: "Battle of the bands 2012"
url_id: "http://vimeo.com/71137905"
name: "rock"
user: user},
{song_title: "The Seductress: Rails"
venue: "Igloo Bar"
location: "Denver"
description: "The crowd goes nuts at 2:14"
url_id: "http://vimeo.com/70360517"
name: "hiphop"
user: user}
])
然后我运行了heroku rake db:migrate,然后运行了heroku rake db:seed,如rails app项目网站所示。我尝试对此进行问题排查,但我不知道从哪里开始或如何开始。这些命令应该有效。我真的可以帮上忙。
---- ----- EDIT
当我使用两个rake命令时,我根本没有收到任何错误。我明白了:
➜ musikfish git:(master) ✗ heroku run rake db:migrate
Running `rake db:migrate` attached to terminal... up, run.8472
➜ musikfish git:(master) ✗ heroku run rake db:seed
Running `rake db:seed` attached to terminal... up, run.9065
问题是当我去我的heroku应用程序时,没有任何东西。
musikfish git:(master) ✗ heroku logs
2014-04-29T01:27:43.662686+00:00 heroku[run.9065]: Starting process with command `bundle exec rake db:seed`
2014-04-29T01:27:43.446432+00:00 heroku[run.9065]: State changed from starting to up
2014-04-29T01:27:48.599137+00:00 heroku[run.9065]: Process exited with status 0
2014-04-29T01:27:48.615271+00:00 heroku[run.9065]: State changed from up to complete
2014-04-29T01:27:59.356149+00:00 heroku[router]: at=info method=GET path=/ host=musikfish.herokuapp.com request_id=9198db15-ceb6-47d0-bf5c-9c0c8f86ed00 fwd="76.19.195.114" dyno=web.1 connect=13ms service=26ms status=304 bytes=963
2014-04-29T01:27:59.437007+00:00 heroku[router]: at=info method=GET path=/assets/vendor/modernizr-aee7c485b9900b5743cd0108ba6c4203.js host=musikfish.herokuapp.com request_id=8fff456c-414b-44d5-9745-c287e21ae29f fwd="76.19.195.114" dyno=web.1 connect=0ms service=4ms status=304 bytes=133
2014-04-29T01:27:59.447087+00:00 heroku[router]: at=info method=GET path=/assets/application-35b8d7e622749de25608aa28d2dab9bf.css host=musikfish.herokuapp.com request_id=5b704bcd-11c5-445e-a3a4-3b5a9771b162 fwd="76.19.195.114" dyno=web.1 connect=0ms service=6ms status=304 bytes=133
2014-04-29T01:27:59.452743+00:00 heroku[router]: at=info method=GET path=/assets/application-f22c7c9cfd4209f8467d10162777b447.js host=musikfish.herokuapp.com request_id=99c37dd8-c9e7-414d-833c-b2355a0a7d78 fwd="76.19.195.114" dyno=web.1 connect=1ms service=6ms status=304 bytes=133
2014-04-29T01:27:59.339867+00:00 app[web.1]: Started GET "/" for 76.19.195.114 at 2014-04-29 01:27:59 +0000
2014-04-29T01:27:59.339876+00:00 app[web.1]: Started GET "/" for 76.19.195.114 at 2014-04-29 01:27:59 +0000
2014-04-29T01:27:59.342081+00:00 app[web.1]: Processing by MusicVideosController#index as HTML
2014-04-29T01:27:59.350172+00:00 app[web.1]: Rendered music_videos/index.html.erb within layouts/application (4.2ms)
2014-04-29T01:27:59.350164+00:00 app[web.1]: Rendered music_videos/index.html.erb within layouts/application (4.2ms)
2014-04-29T01:27:59.342088+00:00 app[web.1]: Processing by MusicVideosController#index as HTML
2014-04-29T01:27:59.351185+00:00 app[web.1]: Completed 200 OK in 9ms (Views: 4.4ms | ActiveRecord: 2.3ms)
2014-04-29T01:27:59.351191+00:00 app[web.1]: Completed 200 OK in 9ms (Views: 4.4ms | ActiveRecord: 2.3ms)
2014-04-29T01:27:59.707282+00:00 heroku[router]: at=info method=GET path=/assets/concert-fa42c0b37cf58a39f5c756d58acc0cff.jpg host=musikfish.herokuapp.com request_id=e62134aa-1020-4402-b507-e90f4cb2c2fa fwd="76.19.195.114" dyno=web.1 connect=1ms service=4ms status=304 bytes=133
2014-04-29T01:28:01.827756+00:00 heroku[router]: at=info method=POST path=/users/sign_out host=musikfish.herokuapp.com request_id=ba2049ed-925a-419f-8d8f-703025441667 fwd="76.19.195.114" dyno=web.1 connect=1ms service=31ms status=302 bytes=1008
2014-04-29T01:28:01.933934+00:00 heroku[router]: at=info method=GET path=/ host=musikfish.herokuapp.com request_id=82444cc8-b75c-4f81-a5b7-a0c4dbebae00 fwd="76.19.195.114" dyno=web.1 connect=2ms service=11ms status=302 bytes=1174
2014-04-29T01:28:02.019241+00:00 heroku[router]: at=info method=GET path=/users/sign_in host=musikfish.herokuapp.com request_id=ff98915d-2970-4369-81c4-b3335cf6fb50 fwd="76.19.195.114" dyno=web.1 connect=1ms service=24ms status=200 bytes=5117
2014-04-29T01:28:01.815374+00:00 app[web.1]: Parameters: {"authenticity_token"=>"6U9MH33BoyP3riIQVH9xRUG/jTGHDbDc9haqkb1wm+c="}
2014-04-29T01:28:01.812383+00:00 app[web.1]: Started DELETE "/users/sign_out" for 76.19.195.114 at 2014-04-29 01:28:01 +0000
2014-04-29T01:28:01.812441+00:00 app[web.1]: Started DELETE "/users/sign_out" for 76.19.195.114 at 2014-04-29 01:28:01 +0000
2014-04-29T01:28:01.836620+00:00 app[web.1]: Redirected to http://musikfish.herokuapp.com/
2014-04-29T01:28:01.815244+00:00 app[web.1]: Processing by Devise::SessionsController#destroy as HTML
2014-04-29T01:28:01.815318+00:00 app[web.1]: Processing by Devise::SessionsController#destroy as HTML
2014-04-29T01:28:01.836976+00:00 app[web.1]: Completed 302 Found in 21ms (ActiveRecord: 4.7ms)
2014-04-29T01:28:01.815409+00:00 app[web.1]: Parameters: {"authenticity_token"=>"6U9MH33BoyP3riIQVH9xRUG/jTGHDbDc9haqkb1wm+c="}
2014-04-29T01:28:01.836730+00:00 app[web.1]: Redirected to http://musikfish.herokuapp.com/
2014-04-29T01:28:01.837036+00:00 app[web.1]: Completed 302 Found in 21ms (ActiveRecord: 4.7ms)
2014-04-29T01:28:01.931057+00:00 app[web.1]: Started GET "/" for 76.19.195.114 at 2014-04-29 01:28:01 +0000
2014-04-29T01:28:01.931067+00:00 app[web.1]: Started GET "/" for 76.19.195.114 at 2014-04-29 01:28:01 +0000
2014-04-29T01:28:01.933233+00:00 app[web.1]: Processing by MusicVideosController#index as HTML
2014-04-29T01:28:01.933240+00:00 app[web.1]: Processing by MusicVideosController#index as HTML
2014-04-29T01:28:01.934294+00:00 app[web.1]: Completed 401 Unauthorized in 1ms
2014-04-29T01:28:01.934300+00:00 app[web.1]: Completed 401 Unauthorized in 1ms
2014-04-29T01:28:02.003346+00:00 app[web.1]: Started GET "/users/sign_in" for 76.19.195.114 at 2014-04-29 01:28:02 +0000
2014-04-29T01:28:02.003359+00:00 app[web.1]: Started GET "/users/sign_in" for 76.19.195.114 at 2014-04-29 01:28:02 +0000
2014-04-29T01:28:02.005391+00:00 app[web.1]: Processing by Devise::SessionsController#new as HTML
2014-04-29T01:28:02.005397+00:00 app[web.1]: Processing by Devise::SessionsController#new as HTML
2014-04-29T01:28:02.016010+00:00 app[web.1]: Rendered devise/sessions/new.html.erb within layouts/application (8.1ms)
2014-04-29T01:28:02.016022+00:00 app[web.1]: Rendered devise/sessions/new.html.erb within layouts/application (8.1ms)
2014-04-29T01:28:02.016885+00:00 app[web.1]: Completed 200 OK in 11ms (Views: 9.6ms | ActiveRecord: 0.0ms)
2014-04-29T01:28:02.016891+00:00 app[web.1]: Completed 200 OK in 11ms (Views: 9.6ms | ActiveRecord: 0.0ms)
2014-04-29T01:28:02.165810+00:00 heroku[router]: at=info method=GET path=/assets/record-b8785487ad26187346eb4a4f3ca44b8e.jpg host=musikfish.herokuapp.com request_id=761b5080-013c-4308-8073-6ae64ee63fe5 fwd="76.19.195.114" dyno=web.1 connect=1ms service=4ms status=304 bytes=133
2014-04-29T01:28:24.575301+00:00 heroku[router]: at=info method=POST path=/users/sign_in host=musikfish.herokuapp.com request_id=95ef1998-d961-4783-8685-d7d463c04cd8 fwd="76.19.195.114" dyno=web.1 connect=0ms service=134ms status=200 bytes=5158
2014-04-29T01:28:24.444910+00:00 app[web.1]: Started POST "/users/sign_in" for 76.19.195.114 at 2014-04-29 01:28:24 +0000
2014-04-29T01:28:24.450353+00:00 app[web.1]: Processing by Devise::SessionsController#create as HTML
2014-04-29T01:28:24.450395+00:00 app[web.1]: Processing by Devise::SessionsController#create as HTML
2014-04-29T01:28:24.450480+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"8oU2ObllOpGkDy+clk2mfnxi9y/oY/JpEWJAGVVEmNA=", "user"=>{"user_name"=>"therubies1000", "password"=>"[FILTERED]", "remember_me"=>"1"}, "commit"=>"Sign In!"}
2014-04-29T01:28:24.456080+00:00 app[web.1]: Completed 401 Unauthorized in 5ms
2014-04-29T01:28:24.457165+00:00 app[web.1]: Processing by Devise::SessionsController#new as HTML
2014-04-29T01:28:24.457172+00:00 app[web.1]: Processing by Devise::SessionsController#new as HTML
2014-04-29T01:28:24.457213+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"8oU2ObllOpGkDy+clk2mfnxi9y/oY/JpEWJAGVVEmNA=", "user"=>{"user_name"=>"therubies1000", "password"=>"[FILTERED]", "remember_me"=>"1"}, "commit"=>"Sign In!"}
2014-04-29T01:28:24.450529+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"8oU2ObllOpGkDy+clk2mfnxi9y/oY/JpEWJAGVVEmNA=", "user"=>{"user_name"=>"therubies1000", "password"=>"[FILTERED]", "remember_me"=>"1"}, "commit"=>"Sign In!"}
2014-04-29T01:28:24.456071+00:00 app[web.1]: Completed 401 Unauthorized in 5ms
2014-04-29T01:28:24.457231+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"8oU2ObllOpGkDy+clk2mfnxi9y/oY/JpEWJAGVVEmNA=", "user"=>{"user_name"=>"therubies1000", "password"=>"[FILTERED]", "remember_me"=>"1"}, "commit"=>"Sign In!"}
2014-04-29T01:28:24.570577+00:00 app[web.1]: Rendered devise/sessions/new.html.erb within layouts/application (9.5ms)
2014-04-29T01:28:24.570588+00:00 app[web.1]: Rendered devise/sessions/new.html.erb within layouts/application (9.5ms)
2014-04-29T01:28:24.571495+00:00 app[web.1]: Completed 200 OK in 114ms (Views: 11.0ms | ActiveRecord: 0.0ms)
2014-04-29T01:28:24.571501+00:00 app[web.1]: Completed 200 OK in 114ms (Views: 11.0ms | ActiveRecord: 0.0ms)
2014-04-29T01:28:24.444975+00:00 app[web.1]: Started POST "/users/sign_in" for 76.19.195.114 at 2014-04-29 01:28:24 +0000
2014-04-29T01:28:24.685158+00:00 heroku[router]: at=info method=GET path=/assets/application-f22c7c9cfd4209f8467d10162777b447.js host=musikfish.herokuapp.com request_id=88423114-72bc-49e8-bb7d-cf5b19fc1908 fwd="76.19.195.114" dyno=web.1 connect=2ms service=6ms status=304 bytes=133
2014-04-29T01:28:24.868171+00:00 heroku[router]: at=info method=GET path=/assets/vendor/modernizr-aee7c485b9900b5743cd0108ba6c4203.js host=musikfish.herokuapp.com request_id=5724d3e6-9603-4b84-84fb-3ba5c696c74f fwd="76.19.195.114" dyno=web.1 connect=118ms service=41ms status=304 bytes=133
2014-04-29T01:31:54.118937+00:00 heroku[router]: at=info method=POST path=/users/sign_in host=musikfish.herokuapp.com request_id=a92e7853-43a3-48b5-9f42-6e55beaf1be2 fwd="76.19.195.114" dyno=web.1 connect=5ms service=173ms status=200 bytes=5158
2014-04-29T01:31:53.955209+00:00 app[web.1]: Started POST "/users/sign_in" for 76.19.195.114 at 2014-04-29 01:31:53 +0000
2014-04-29T01:31:53.957652+00:00 app[web.1]: Processing by Devise::SessionsController#create as HTML
2014-04-29T01:31:53.957659+00:00 app[web.1]: Processing by Devise::SessionsController#create as HTML
2014-04-29T01:31:53.957698+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"8oU2ObllOpGkDy+clk2mfnxi9y/oY/JpEWJAGVVEmNA=", "user"=>{"user_name"=>"therubies1000", "password"=>"[FILTERED]", "remember_me"=>"1"}, "commit"=>"Sign In!"}
2014-04-29T01:31:53.957720+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"8oU2ObllOpGkDy+clk2mfnxi9y/oY/JpEWJAGVVEmNA=", "user"=>{"user_name"=>"therubies1000", "password"=>"[FILTERED]", "remember_me"=>"1"}, "commit"=>"Sign In!"}
2014-04-29T01:31:53.968990+00:00 app[web.1]: Completed 401 Unauthorized in 11ms
2014-04-29T01:31:53.969002+00:00 app[web.1]: Completed 401 Unauthorized in 11ms
2014-04-29T01:31:53.971927+00:00 app[web.1]: Processing by Devise::SessionsController#new as HTML
2014-04-29T01:31:53.955199+00:00 app[web.1]: Started POST "/users/sign_in" for 76.19.195.114 at 2014-04-29 01:31:53 +0000
2014-04-29T01:31:53.971933+00:00 app[web.1]: Processing by Devise::SessionsController#new as HTML
2014-04-29T01:31:53.971976+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"8oU2ObllOpGkDy+clk2mfnxi9y/oY/JpEWJAGVVEmNA=", "user"=>{"user_name"=>"therubies1000", "password"=>"[FILTERED]", "remember_me"=>"1"}, "commit"=>"Sign In!"}
2014-04-29T01:31:53.971991+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"8oU2ObllOpGkDy+clk2mfnxi9y/oY/JpEWJAGVVEmNA=", "user"=>{"user_name"=>"therubies1000", "password"=>"[FILTERED]", "remember_me"=>"1"}, "commit"=>"Sign In!"}
2014-04-29T01:31:54.117705+00:00 app[web.1]: Rendered devise/sessions/new.html.erb within layouts/application (5.9ms)
2014-04-29T01:31:54.117717+00:00 app[web.1]: Rendered devise/sessions/new.html.erb within layouts/application (5.9ms)
2014-04-29T01:31:54.118464+00:00 app[web.1]: Completed 200 OK in 146ms (Views: 7.2ms | ActiveRecord: 0.0ms)
2014-04-29T01:31:54.118470+00:00 app[web.1]: Completed 200 OK in 146ms (Views: 7.2ms | ActiveRecord: 0.0ms)
2014-04-29T01:31:54.237788+00:00 heroku[router]: at=info method=GET path=/assets/application-35b8d7e622749de25608aa28d2dab9bf.css host=musikfish.herokuapp.com request_id=77e5536c-f9af-4285-a236-a011c1355b81 fwd="76.19.195.114" dyno=web.1 connect=4ms service=9ms status=304 bytes=133
2014-04-29T01:31:54.243275+00:00 heroku[router]: at=info method=GET path=/assets/application-f22c7c9cfd4209f8467d10162777b447.js host=musikfish.herokuapp.com request_id=8ca4ebaf-739d-4e4a-901b-e616e2b7033b fwd="76.19.195.114" dyno=web.1 connect=6ms service=11ms status=304 bytes=133
2014-04-29T01:31:54.264123+00:00 heroku[router]: at=info method=GET path=/assets/vendor/modernizr-aee7c485b9900b5743cd0108ba6c4203.js host=musikfish.herokuapp.com request_id=f2a2d4e9-4163-425d-b26b-5255a6a1f5fe fwd="76.19.195.114" dyno=web.1 connect=6ms service=9ms status=304 bytes=133
2014-04-29T01:31:54.772855+00:00 heroku[router]: at=info method=GET path=/assets/record-b8785487ad26187346eb4a4f3ca44b8e.jpg host=musikfish.herokuapp.com request_id=d103b167-2ed5-4667-874f-679e3d07b859 fwd="76.19.195.114" dyno=web.1 connect=2ms service=5ms status=304 bytes=133
2014-04-29T01:32:03.174817+00:00 heroku[router]: at=info method=GET path=/ host=musikfish.herokuapp.com request_id=cd1eb130-8cf7-453a-982f-b7a74ccafe3e fwd="76.19.195.114" dyno=web.1 connect=11ms service=16ms status=302 bytes=1226
2014-04-29T01:32:03.158631+00:00 app[web.1]: Processing by MusicVideosController#index as HTML
2014-04-29T01:32:03.158689+00:00 app[web.1]: Processing by MusicVideosController#index as HTML
2014-04-29T01:32:03.159895+00:00 app[web.1]: Completed 401 Unauthorized in 1ms
2014-04-29T01:32:03.159937+00:00 app[web.1]: Completed 401 Unauthorized in 1ms
2014-04-29T01:32:03.156335+00:00 app[web.1]: Started GET "/" for 76.19.195.114 at 2014-04-29 01:32:03 +0000
2014-04-29T01:32:03.156448+00:00 app[web.1]: Started GET "/" for 76.19.195.114 at 2014-04-29 01:32:03 +0000
2014-04-29T01:32:03.570966+00:00 heroku[router]: at=info method=GET path=/users/sign_in host=musikfish.herokuapp.com request_id=0bcfa714-0019-4860-aa40-c18140690458 fwd="76.19.195.114" dyno=web.1 connect=121ms service=165ms status=200 bytes=5117
2014-04-29T01:32:03.511737+00:00 app[web.1]: Started GET "/users/sign_in" for 76.19.195.114 at 2014-04-29 01:32:03 +0000
2014-04-29T01:32:03.511725+00:00 app[web.1]: Started GET "/users/sign_in" for 76.19.195.114 at 2014-04-29 01:32:03 +0000
2014-04-29T01:32:03.514596+00:00 app[web.1]: Processing by Devise::SessionsController#new as HTML
2014-04-29T01:32:03.527802+00:00 app[web.1]: Completed 200 OK in 13ms (Views: 10.8ms | ActiveRecord: 0.0ms)
2014-04-29T01:32:03.527809+00:00 app[web.1]: Completed 200 OK in 13ms (Views: 10.8ms | ActiveRecord: 0.0ms)
2014-04-29T01:32:03.514590+00:00 app[web.1]: Processing by Devise::SessionsController#new as HTML
2014-04-29T01:32:03.527020+00:00 app[web.1]: Rendered devise/sessions/new.html.erb within layouts/application (9.6ms)
2014-04-29T01:32:03.527010+00:00 app[web.1]: Rendered devise/sessions/new.html.erb within layouts/application (9.6ms)
答案 0 :(得分:0)
您是否已成功在本地播种数据库?
您还可以尝试在种子文件中添加puts
行,以确保正在运行代码。 (IE,在MusicVideo.create之后,说puts "Music Videos created!"
,在运行rake db:seed
时将写入您的控制台
我的预感是你的模型验证失败;也许尝试使用create!
而不是create
来查看是否抛出了错误。