Rails - getting 500 server errors through the browser, but works through the script / console. What gives?

Well, I chased it for hours, and I just can't figure it out. I have a Ruby on Rails application that I have deployed for my hosting provider DreamHost. I created a new environment called "stage" and created the stage.rb file in the / config / environment folder and placed the following line in my environment. Rb

# Be sure to restart your server when you modify this file

# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION

ENV["RAILS_ENV"] ||= "stage"

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')

Rails::Initializer.run do |config|

I can run

RAILS_ENV=stage script/console

and everything is working fine. I can run rake db: migrate and generate my database. Then I can go into the console and act on my model. I also see ActiveRecord activity in stage.log

The problem is that when I open the browser and go to the URL, I get a 500 error

We are sorry, but something went wrong.

, stage.log.

Apache .

1.1.1.1 - - [19/Jan/2010:06:05:01 -0800] "GET /classes/calendar HTTP/1.1" 500 861 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10" 

, . , .

, . , DreamHost FTP , , , , , .

, Rob

+3
2

, RAILS_ENV "". || = , RAILS_ENV . RAILS_ENV, , "" DH , || = .

, , - , , production.log stage.log( , script/console), () .

: :

ENV["RAILS_ENV"] = "stage"
+1

. rails DH, Passenger fastcgi?

, , gem env:

RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.5
  - RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i686-linux]
  - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /usr/lib/ruby/gems/1.8
     - /home/<username>/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - :sources => ["http://gems.rubyforge.org/", "http://gems.github.com", "http://gemcutter.org"]
  - REMOTE SOURCES:
     - http://gems.rubyforge.org/
     - http://gems.github.com
     - http://gemcutter.org

, apache. config/environment.rb

ENV['GEM_PATH'] = '/home/<usrname>/.gem/ruby/1.8:/usr/lib/ruby/gems/1.8'

, GEM_PATH , , gem env.

0

Source: https://habr.com/ru/post/1729074/


All Articles