简体   繁体   中英

hosting rails site on heroku

Trying to deploy my rails site to heroku. i've made sure to commit everything, raked after i pushed etc. it all seems to work, however, i got an application error when i try to open my site on heroku, even though it worked on local.

Heroku logs:

2013-01-29T16:08:11+00:00 heroku[web.1]: State changed from starting to crashed
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/inflector/methods.rb:229:in `constantize'
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/inflector/methods.rb:260:in `safe_constantize'
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/core_ext/string/inflections.rb:66:in `safe_constantize'
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_controller/metal/params_wrapper.rb:152:in `_default_wrap_model'
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_controller/metal/params_wrapper.rb:169:in `_set_wrapper_defaults'
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_controller/metal/params_wrapper.rb:133:in `inherited'
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.11/lib/abstract_controller/railties/routes_helpers.rb:7:in block (2 levels) in with' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_controller/railties/paths.rb:7:in block (2 levels) in with'
2013-01-29T16:08:10+00:00 app[web.1]: from /app/app/controllers/restaurants_controller.rb:1:in `'

2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in require' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in block in require' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in load_dependency' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in require' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:359:in require_or_load' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/inflector/methods.rb:230:in block in constantize' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:55:in block in run_initializers' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:313:in depend_on' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:225:in require_dependency' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:439:in block (2 levels) in eager_load!' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:438:in each' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:438:in block in eager_load!' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/inflector/methods.rb:229:in each' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:436:in each' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:54:in run_initializers' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/application.rb:136:in initialize!' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in method_missing' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/config/environment.rb:5:in' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/config.ru:3:in require' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/config.ru:3:inblock in ' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.4/lib/rack/builder.rb:51:in instance_eval' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.4/lib/rack/builder.rb:51:in initialize' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/config.ru:in new' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/config.ru:in' 
2013-01-29T16:08:13+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=team-van.herokuapp.com fwd=18.189.116.76 dyno= queue= wait= connect= service= status=503 bytes= 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:190:in const_missing' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:30:in run' 
2013-01-29T16:08:10+00:00 app[web.1]: Exiting 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.4/lib/rack/builder.rb:40:in eval' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.4/lib/rack/builder.rb:40:in parse_file' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.4/lib/rack/server.rb:200:in app' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands/server.rb:46:in app' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.4/lib/rack/server.rb:304:in wrapped_app' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.4/lib/rack/server.rb:254:in start' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands/server.rb:70:in start' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:55:in block in ' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:50:in tap' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:50:in ' 
2013-01-29T16:08:10+00:00 app[web.1]: from script/rails:6:in require' 
2013-01-29T16:08:10+00:00 app[web.1]: from script/rails:6:in' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:436:in eager_load!' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:54:in each' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:190:in each' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:30:in instance_exec' 
2013-01-29T16:08:11+00:00 heroku[web.1]: Process exited with status 1 
2013-01-29T16:08:10+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/attribute_assignment.rb:88:in block in assign_attributes': unknown attribute: category (ActiveRecord::UnknownAttributeError) 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/attribute_assignment.rb:78:in each' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/attribute_assignment.rb:78:in assign_attributes' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/base.rb:497:in initialize' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/app/models/restaurant.rb:49:in new' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/app/models/restaurant.rb:49:inblock in ' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/csv.rb:1792:in each' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/csv.rb:1208:inblock in foreach' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/csv.rb:1354:in open' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/csv.rb:1207:inforeach' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/app/models/restaurant.rb:48:in <top (required)>' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in require' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in block in require' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in load_dependency' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in require' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:359:in require_or_load' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:502:in load_missing_constant' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:192:in block in const_missing' 
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/application/finisher.rb:53:in `block in

My model/restaurant.rb

class Restaurant < ActiveRecord::Base

  attr_accessible :activity, :category, :age, :budget, 
    :description, :info_url, :name, :rating, 
    :size, :tag, :time, :tourist, :location

  scope :lunch, where("category = 'l'")
  scope :dinner, where("category = 'd'")

  scope :boston, where("location = 'b'")
  scope :newyork, where("location = 'nyc'")
  scope :sanfran, where("location = 'sf'")

  scope :b1, order("budget asc")
  scope :b2, where("budget <=2").order("budget desc")
  scope :b3, order("budget desc")

  scope :g1, order("size asc")
  scope :g2, where("size <=2").order("size desc")
  scope :g3, order("size desc")

  scope :a1, order("age asc")
  scope :a2, where("age <=2").order("age desc")
  scope :a3, order("age desc")

  scope :l1, order("activity asc")
  scope :l2, where("activity <=2").order("activity desc")
  scope :l3, order("activity desc")

  scope :t1, order("tourist asc")
  scope :t2, where("tourist <=2").order("tourist desc")
  scope :t3, order("tourist desc")

  scope :rate, order("rating desc")

  def self.lsearching(b,g,a,l,t,loc)
    @lrestaurants = eval ("Restaurant." + "lunch." + b + "." + g + "." + a + "." + l + "." + t + "." + loc)
    #@restaurants = Restaurant.rate
  end
  def self.dsearching(b,g,a,l,t, loc)
    @drestaurants = eval ("Restaurant." + "dinner." + b + "." + g + "." + a + "." + l + "." + t + "." + loc)

  end

end

require 'csv'
CSV.foreach('app/assets/nycrestaurant.csv',  "r:ISO-8859-1") do |row|
  record = Restaurant.new(
    :name   => row[0], 
    :category => row[1],
    :description => row[11],
    :info_url => row[3],
    :time => row[4],
    :size => row[5],
    :activity => row[6],
    :budget => row[7],
    :age => row[8],
    :tourist => row[9],
    :rating => row[10],
    :tag => row[11],
    :location => row[12]
  )
  record.save!
end

CSV.foreach('app/assets/bostonrest.csv',  "r:ISO-8859-1") do |row|
  record = Restaurant.new(
    :name   => row[0], 
    :category => row[11],
    :description => row[1],
    :info_url => row[3],
    :time => row[4],
    :size => row[5],
    :activity => row[6],
    :budget => row[7],
    :age => row[8],
    :tourist => row[9],
    :rating => row[10],
    :tag => row[2],
    :location => row[12]
  )
  record.save!
end

You need run the migrations on heroku, at console run:

heroku run rake db:migrate

And you need to learn to read logs! Look here:

2013-01-29T16:08:10+00:00 app[web.1]:  /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/attribute_assignment.rb:88:in block in assign_attributes': unknown attribute: category (ActiveRecord::UnknownAttributeError)
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/attribute_assignment.rb:78:in each'
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/attribute_assignment.rb:78:in assign_attributes'
2013-01-29T16:08:10+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/base.rb:497:in initialize'
2013-01-29T16:08:10+00:00 app[web.1]: from /app/app/models/restaurant.rb:49:in new'
2013-01-29T16:08:10+00:00 app[web.1]: from /app/app/models/restaurant.rb:49:inblock

The message unknown attribute: category means that the database doesn't have the column category.

And last, format the log message before posting here, we appreciate.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM