3esmile
3esmile

Reputation: 51

all data lost after deploying ruby on rails on heroku

after I deploy my app into Heroku, everything looks fine, but all my data has lost, there's no data on my heroku app pages. below is my heroku logs:

2014-04-29T17:50:58.886649+00:00 app[web.1]:   Rendered layouts/_footer.erb (0.0ms)
2014-04-29T17:50:58.890068+00:00 app[web.1]: Completed 200 OK in 26ms (Views: 11.2ms | ActiveRecord: 12.3ms)
2014-04-29T17:50:59.255494+00:00 heroku[router]: at=info method=GET path=/assets/bg_gulanyu.jpg host=ancient-hamlet-8143.herokuapp.com request_id=a0906a17-2017-48fc-93b3-3375f0a3e658 fwd="216.151.31.224" dyno=web.1 connect=2ms service=7ms status=304 bytes=236
2014-04-29T17:50:59.669323+00:00 heroku[router]: at=info method=GET path=/assets/controls.png host=ancient-hamlet-8143.herokuapp.com request_id=d9d34b08-58ea-423d-b630-25239be7ab74 fwd="216.151.31.224" dyno=web.1 connect=2ms service=7ms status=304 bytes=236
2014-04-29T17:50:59.682317+00:00 heroku[router]: at=info method=GET path=/assets/glyphicons-halflings-regular.woff host=ancient-hamlet-8143.herokuapp.com request_id=ff27501f-7281-4519-a60b-1eca87258d41 fwd="216.151.31.224" dyno=web.1 connect=3ms service=10ms status=304 bytes=236
2014-04-29T17:50:59.687130+00:00 heroku[router]: at=info method=GET path=/assets/bx_loader.gif host=ancient-hamlet-8143.herokuapp.com request_id=eae630fc-db55-486a-b583-c1822295acce fwd="216.151.31.224" dyno=web.1 connect=3ms service=9ms status=304 bytes=236
2014-04-29T17:51:01.494615+00:00 heroku[router]: at=info method=GET path=/spots host=ancient-hamlet-8143.herokuapp.com request_id=052c362a-4a9f-4674-a3a7-ac20acbf9217 fwd="216.151.31.224" dyno=web.1 connect=9ms service=33ms status=304 bytes=355
2014-04-29T17:51:01.451084+00:00 app[web.1]: Started GET "/spots" for 216.151.31.224 at 2014-04-29 17:51:01 +0000
2014-04-29T17:51:01.471413+00:00
 app[web.1]:   Rendered layouts/_header.erb (0.5ms)
2014-04-29T17:51:01.465226+00:00 app[web.1]:   Rendered layouts/_spotItem.html.erb (2.6ms)
2014-04-29T17:51:01.471816+00:00 app[web.1]:   Rendered layouts/_footer.erb (0.0ms)
2014-04-29T17:51:01.454272+00:00 app[web.1]: Processing by SpotsController#index as HTML
2014-04-29T17:51:01.465885+00:00 app[web.1]:   Rendered spots/index.html.erb within layouts/application (3.5ms)
2014-04-29T17:51:01.474967+00:00 app[web.1]: Completed 200 OK in 21ms (Views: 11.0ms | ActiveRecord: 8.1ms)
2014-04-29T17:51:01.471593+00:00 app[web.1]:   Rendered layouts/_sidebar.erb (0.0ms)
2014-04-29T17:51:01.957138+00:00 heroku[router]: at=info method=GET path=/assets/bg_gulanyu.jpg host=ancient-hamlet-8143.herokuapp.com request_id=7f0d0d8a-8ab1-4115-b87a-d3b9056abd6a fwd="216.151.31.224" dyno=web.1 connect=32ms service=32ms status=304 bytes=236
2014-04-29T17:51:02.235561+00:00 heroku[router]: at=info method=GET path=/assets/glyphicons-halflings-regular.woff host=ancient-hamlet-8143.herokuapp.com request_id=b1ecc5d5-8442-44e4-9d6d-b65b68b43e9a fwd="216.151.31.224" dyno=web.1 connect=3ms service=9ms status=304 bytes=236
2014-04-29T17:51:05.260056+00:00 heroku[router]: at=info method=GET path=/spots/new host=ancient-hamlet-8143.herokuapp.com request_id=e3af6e0a-6fa0-4de3-8397-d57a884962de fwd="216.151.31.224" dyno=web.1 connect=16ms service=89ms status=500 bytes=939
2014-04-29T17:51:05.165888+00:00 app
[web.1]: Started GET "/spots/new" for 216.151.31.224 at 2014-04-29 17:51:05 +0000
2014-04-29T17:51:05.237761+00:00 app[web.1]: 
2014-04-29T17:51:05.237764+00:00 app[web.1]: ActionView::Template::Error (undefined method `image2' for #<Spot:0x00000003f9ac88>):
2014-04-29T17:51:05.237765+00:00 app[web.1]:     37:             <th><%= f.label :image1 %></th>
2014-04-29T17:51:05.169475+00:00 app[web.1]: Processing by SpotsController#new as HTML
2014-04-29T17:51:05.237767+00:00 app[web.1]:     38:             <td><%= f.text_field :image, :class => 'form-control' %></td>
2014-04-29T17:51:05.237770+00:00 app[web.1]:     40:             <td><%= f.text_field :image2, :class => 'form-control' %></td>
2014-04-29T17:51:05.237769+00:00 app[web.1]:     39:             <th><%= f.label :image2 %></th>
2014-04-29T17:51:05.237777+00:00 app[web.1]:   app/views/spots/_form.html.erb:40:in `block in _app_views_spots__form_html_erb__916336334634292621_40913960'
2014-04-29T17:51:05.237775+00:00 app[web.1]:     43:           </thead>
2014-04-29T17:51:05.235228+00:00 app[web.1]:   Rendered spots/_form.html.erb (41.0ms)
2014-04-29T17:51:05.235301+00:00 app[web.1]:   Rendered spots/new.html.erb within layouts/application (42.2ms)
2014-04-29T17:51:05.237772+00:00 app[web.1]:     41:             
2014-04-29T17:51:05.237778+00:00 app[web.1]:   app/views/spots/_form.html.erb:1:in `_app_views_spots__form_html_erb__916336334634292621_40913960'
2014-04-29T17:51
:05.237780+00:00 app[web.1]:   app/views/spots/new.html.erb:3:in `_app_views_spots_new_html_erb___1927106455304175595_40887520'
2014-04-29T17:51:05.237785+00:00 app[web.1]: 
2014-04-29T17:51:05.237774+00:00 app[web.1]:     42:           </tr>
2014-04-29T17:51:05.237783+00:00 app[web.1]: 
2014-04-29T17:51:05.237782+00:00 app[web.1]:   app/controllers/spots_controller.rb:36:in `new'
2014-04-29T17:51:05.235524+00:00 app[web.1]: Completed 500 Internal Server Error in 66ms
2014-04-29T17:51:06.662376+00:00 heroku[router]: at=info method=GET path=/spots/new host=ancient-hamlet-8143.herokuapp.com request_id=219d96ee-ee05-455a-ba2f-e5586109d70e fwd="216.151.31.224" dyno=web.1 connect=2ms service=26ms status=500 bytes=939
2014-04-29T17:51:06.630165+00:00 app[web.1]: Started GET "/spots/new" for 216.151.31.224 at 2014-04-29 17:51:06 +0000
2014-04-29T17:51:06.644934+00:00 app[web.1]:   Rendered spots/_form.html.erb (4.0ms)
2014-04-29T17:51:06.645390+00:00 app[web.1]: Completed 500 Internal Server Error in 11ms
2014-04-29T17:51:06.647778+00:00 app[web.1]:     37:             <th><%= f.label :image1 %></th>
2014-04-29T17:51:06.634478+00:00 app[web.1]: Processing by SpotsController#new as HTML
2014-04-29T17:51:06.645149+00:00 app[web.1]:   Rendered spots/new.html.erb within layouts/application (4.4ms)
2014-04-29T17:51:06.647772+00:00 app[web.1]: 
2014-04-29T17:51:06.647776+00:00 app[web.1]: ActionView::Template::Error (undefined method `im
age2' for #<Spot:0x00000003f2cb48>):
2014-04-29T17:51:06.647783+00:00 app[web.1]:     40:             <td><%= f.text_field :image2, :class => 'form-control' %></td>
2014-04-29T17:51:06.647791+00:00 app[web.1]:   app/views/spots/_form.html.erb:1:in `_app_views_spots__form_html_erb__916336334634292621_40913960'
2014-04-29T17:51:06.647780+00:00 app[web.1]:     38:             <td><%= f.text_field :image, :class => 'form-control' %></td>
2014-04-29T17:51:06.647781+00:00 app[web.1]:     39:             <th><%= f.label :image2 %></th>
2014-04-29T17:51:06.647794+00:00 app[web.1]:   app/controllers/spots_controller.rb:36:in `new'
2014-04-29T17:51:06.647784+00:00 app[web.1]:     41:             
2014-04-29T17:51:06.647786+00:00 app[web.1]:     42:           </tr>
2014-04-29T17:51:06.647787+00:00 app[web.1]:     43:           </thead>
2014-04-29T17:51:06.647795+00:00 app[web.1]: 
2014-04-29T17:51:06.647789+00:00 app[web.1]:   app/views/spots/_form.html.erb:40:in `block in _app_views_spots__form_html_erb__916336334634292621_40913960'
2014-04-29T17:51:06.647792+00:00 app[web.1]:   app/views/spots/new.html.erb:3:in `_app_views_spots_new_html_erb___1927106455304175595_40887520'
2014-04-29T17:51:06.647797+00:00 app[web.1]: 
2014-04-29T17:51:07.889739+00:00 heroku[router]: at=info method=GET path=/spots/new host=ancient-hamlet-8143.herokuapp.com request_id=cb7d590c-86cf-404e-835d-f9b758b88e1d fwd="216.151.31.224" dyno=web.1 connect=15ms ser
vice=32ms status=500 bytes=939
2014-04-29T17:51:07.864220+00:00 app[web.1]:   Rendered spots/_form.html.erb (3.7ms)
2014-04-29T17:51:07.849102+00:00 app[web.1]: Started GET "/spots/new" for 216.151.31.224 at 2014-04-29 17:51:07 +0000
2014-04-29T17:51:07.852450+00:00 app[web.1]: Processing by SpotsController#new as HTML
2014-04-29T17:51:07.866822+00:00 app[web.1]:     40:             <td><%= f.text_field :image2, :class => 'form-control' %></td>
2014-04-29T17:51:07.866824+00:00 app[web.1]:     41:             
2014-04-29T17:51:07.866821+00:00 app[web.1]:     39:             <th><%= f.label :image2 %></th>
2014-04-29T17:51:07.866819+00:00 app[web.1]:     38:             <td><%= f.text_field :image, :class => 'form-control' %></td>
2014-04-29T17:51:07.864421+00:00 app[web.1]:   Rendered spots/new.html.erb within layouts/application (4.0ms)
2014-04-29T17:51:07.864547+00:00 app[web.1]: Completed 500 Internal Server Error in 12ms
2014-04-29T17:51:07.866792+00:00 app[web.1]: 
2014-04-29T17:51:07.866796+00:00 app[web.1]: ActionView::Template::Error (undefined method `image2' for #<Spot:0x00000004630958>):
2014-04-29T17:51:07.866818+00:00 app[web.1]:     37:             <th><%= f.label :image1 %></th>
2014-04-29T17:51:07.866825+00:00 app[web.1]:     42:           </tr>
2014-04-29T17:51:07.866834+00:00 app[web.1]:     43:           </thead>
2014-04-29T17:51:07.866836+00:00 app[web.1]:   app/views/spots/_form.html.erb:40:in `block in _app_views_spots__form_html_erb__916336334634292621_40913960'
2014-04-29T17:51:07.866837+00:00 app[web.1]:   app/views/spots/_form.html.erb:1:in `_app_views_spots__form_html_erb__916336334634292621_40913960'
2014-04-29T17:51:07.866838+00:00 app[web.1]:   app/views/spots/new.html.erb:3:in `_app_views_spots_new_html_erb___1927106455304175595_40887520'
2014-04-29T17:51:07.866840+00:00 app[web.1]:   app/controllers/spots_controller.rb:36:in `new'
2014-04-29T17:51:07.866841+00:00 app[web.1]: 
2014-04-29T17:51:07.866842+00:00 app[web.1]: 
2014-04-29T17:51:09.134976+00:00 heroku[router]: at=info method=GET path=/spots/new host=ancient-hamlet-8143.herokuapp.com request_id=e6898201-d655-4b01-818c-bde4d5e42ef0 fwd="216.151.31.224" dyno=web.1 connect=11ms service=36ms status=500 bytes=939
2014-04-29T17:51:09.104382+00:00 app[web.1]: Completed 500 Internal Server Error in 11ms
2014-04-29T17:51:09.107047+00:00 app[web.1]:     39:             <th><%= f.label :image2 %></th>
2014-04-29T17:51:09.107039+00:00 app[web.1]: 
2014-04-29T17:51:09.107042+00:00 app[web.1]: ActionView::Template::Error (undefined method `image2' for #<Spot:0x00000004c2aca0>):
2014-04-29T17:51:09.107044+00:00 app[web.1]:     37:             <th><%= f.label :image1 %></th>
2014-04-29T17:51:09.107045+00:00 app[web.1]:     38:             <td><%= f.text_field :image, :class => 'form-control' %></td>
2014-04-29T17:51:09.089624+00:00 app[web.1]: Started GET "/spots/new" for 216.151.31.224 at 2014-04-29 17:51:09 +0000
2014-04-29T17:51:09.104086+00:00 app[web.1]:   Rendered spots/_form.html.erb (4.1ms)
2014-04-29T17:51:09.104245+00:00 app[web.1]:   Rendered spots/new.html.erb within layouts/application (4.5ms)
2014-04-29T17:51:09.107049+00:00 app[web.1]:     40:             <td><%= f.text_field :image2, :class => 'form-control' %></td>
2014-04-29T17:51:09.107051+00:00 app[web.1]:     41:             
2014-04-29T17:51:09.107053+00:00 app[web.1]:     42:           </tr>
2014-04-29T17:51:09.107055+00:00 app[web.1]:     43:           </thead>
2014-04-29T17:51:09.107056+00:00 app[web.1]:   app/views/spots/_form.html.erb:40:in `block in _app_views_spots__form_html_erb__916336334634292621_40913960'
2014-04-29T17:51:09.107058+00:00 app[web.1]:   app/views/spots/_form.html.erb:1:in `_app_views_spots__form_html_erb__916336334634292621_40913960'
2014-04-29T17:51:09.107060+00:00 app[web.1]:   app/views/spots/new.html.erb:3:in `_app_views_spots_new_html_erb___1927106455304175595_40887520'
2014-04-29T17:51:09.107061+00:00 app[web.1]:   app/controllers/spots_controller.rb:36:in `new'
2014-04-29T17:51:09.107062+00:00 app[web.1]: 
2014-04-29T17:51:09.107064+00:00 app[web.1]: 
2014-04-29T17:51:09.092806+00:00 app[web.1]: Processing by SpotsController#new as HTML

but the app runs well on my local machine, below is the screenshot:

■ list page: https://www.dropbox.com/s/cdvb46fv2t7ootm/Screenshot%202014-04-30%2002.03.18.png

========================================

Problem solved by using gem yaml_db.
https://coderwall.com/p/90qymq

the reason is I did not transfer my local database to heroku database.

Upvotes: 0

Views: 789

Answers (3)

3esmile
3esmile

Reputation: 51

Problem solved by using gem yaml_db.
https://coderwall.com/p/90qymq

the reason is I did not transfer my local database to heroku database.

Upvotes: 0

RahulOnRails
RahulOnRails

Reputation: 6542

In your case, you only pushed your code to Heroku, not the database.

May be you have sqlite or any database while development, but Heroku supports only postgres.

You have to import your data from local to heroku using seeds file or 
migration file.

Or

May be you forgot to run rake db:create and rake db:migrate to create db.

Generating Seeds From Existing Data

Upvotes: 1

Anurag
Anurag

Reputation: 3114

From your comment I can see that you are using sqlite as your database, which is a filesystem database.

Heroku filesystem is read-only, which means you cannot dynamically write to the filesystem for semi-permanent storage. Writing to a filesystem database like SQLite or GDBM is not supported on Heroku.

Also if you choose multiple dyno's on Heroku then saving and retrieving any file on Heroku is not advisable. Because when you save a file it might be saved on one dyno and when you try to read it the request might go to another dyno.

For databases try to use Heroku provided PostgreSQL database instead of a filesystem database.

For more information refer Heroku docs

Upvotes: 0

Related Questions