2016-09-12 3 views
0

매우 이상한 문제에 봉착했습니다. 나는 개발 환경에서 성공적으로 레일 애플리케이션을 개발하고 테스트했지만, 프로덕션 환경에서 내 사이트를 만들고 실행하는 과정에서 rake secret 명령을 실행해야했습니다. 불행하게도, 나는 다음과 같은 오류 메시지가 직면 :레일 NoMethodError : 정의되지 않은 메소드`[] = 'for nil : 프로덕션 환경의 NilClass

rake aborted! 
NoMethodError: undefined method `[]=' for nil:NilClass 
/var/www/html/comigo/comigo/config/application.rb:31:in `<class:Application>' 
/var/www/html/comigo/comigo/config/application.rb:19:in `<module:Comigo>' 
/var/www/html/comigo/comigo/config/application.rb:18:in `<top (required)>' 
/var/www/html/comigo/comigo/Rakefile:4:in `require' 
/var/www/html/comigo/comigo/Rakefile:4:in `<top (required)>' 
/home/deplguerrabr/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/rake_module.rb:28:in `load' 
/home/deplguerrabr/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/rake_module.rb:28:in `load_rakefile' 
/home/deplguerrabr/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:686:in `raw_load_rakefile' 
/home/deplguerrabr/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:96:in `block in load_rakefile' 
/home/deplguerrabr/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:178:in `standard_exception_handling' 
/home/deplguerrabr/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:95:in `load_rakefile' 
/home/deplguerrabr/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:79:in `block in run' 
/home/deplguerrabr/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:178:in `standard_exception_handling' 
/home/deplguerrabr/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/lib/rake/application.rb:77:in `run' 
/home/deplguerrabr/.rvm/gems/ruby-2.3.1/gems/rake-11.2.2/exe/rake:27:in `<top (required)>' 
/home/deplguerrabr/.rvm/gems/ruby-2.3.1/bin/rake:22:in `load' 
/home/deplguerrabr/.rvm/gems/ruby-2.3.1/bin/rake:22:in `<main>' 
/home/deplguerrabr/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `eval' 

내가 몇 가지 관련 문제로 리디렉션 된 웹 검색을하지만 그 중 아무도 나의 엄격하게 동일하지 않았다. 여기에 나는 probabily 내 프로젝트의 환경에 대한 큰 그림을 줄 수있는 몇 가지 문제를 열거했다 : 1) 인증 (버전 3.4.1) 에 대한 devise를 사용하고 있습니다 2)이 문제는 생산 환경에서만 나타납니다 3) 생산 및 개발 환경 4)에서 같은 루비 버전과 레일 여기 내가 사용하고있는 보석입니다

actionmailer (4.2.6) 
actionpack (4.2.6) 
actionview (4.2.6) 
activejob (4.2.6) 
activemodel (4.2.6) 
activerecord (4.2.6) 
activesupport (4.2.6) 
acts_as_votable (0.10.0) 
arel (6.0.3) 
autoprefixer-rails (6.4.1.1, 6.3.7, 6.3.6) 
bcrypt (3.1.11) 
bigdecimal (default: 1.2.8) 
binding_of_caller (0.7.2) 
bootstrap-sass (3.2.0.2) 
bootstrap-tagsinput-rails (0.4.2.1) 
bootsy (2.2.2) 
bson (3.2.6) 
bson_ext (1.5.1) 
builder (3.2.2) 
bundler (1.12.5) 
bundler-unload (1.0.2) 
bxslider-rails (4.2.5.1) 
byebug (9.0.5, 9.0.3) 
cancancan (1.14.0) 
carrierwave (0.11.2) 
carrierwave-mongoid (0.10.0, 0.9.0) 
client_side_validations (4.2.3) 
climate_control (0.0.3) 
cocaine (0.5.8) 
coffee-rails (4.1.1) 
coffee-script (2.4.1) 
coffee-script-source (1.10.0) 
commonjs (0.2.7) 
concurrent-ruby (1.0.2) 
countries (1.2.5) 
country_select (2.5.2) 
currencies (0.4.2) 
debug_inspector (0.0.2) 
devise (4.2.0, 4.1.1, 3.4.1) 
did_you_mean (1.0.0) 
erubis (2.7.0) 
execjs (2.7.0, 2.6.0) 
executable-hooks (1.3.2) 
faraday (0.9.2) 
faraday_middleware (0.9.2) 
fileutils (0.7) 
font-awesome-rails (4.6.3.0) 
gem-wrappers (1.2.7) 
geoip (1.4.0) 
globalid (0.3.7, 0.3.6) 
gmaps4rails (2.1.2) 
google_visualr (2.5.1) 
haml (4.0.7) 
hashie (3.4.4) 
httpauth (0.2.1) 
i18n (0.7.0) 
i18n_data (0.7.0) 
image-picker-rails (0.2.4) 
instagram (1.1.6) 
io-console (default: 0.4.5) 
jbuilder (2.6.0, 2.5.0, 2.4.1) 
jquery-migrate-rails (1.2.1) 
jquery-rails (4.2.1, 4.1.1) 
jquery-slick-rails (1.6.0.2) 
jquery-ui-rails (5.0.5) 
js_regex (1.0.14) 
json (default: 1.8.3) 
jwt (1.5.4, 1.5.1, 0.1.13) 
kaminari (0.16.3) 
less (2.6.0) 
less-rails (2.7.1) 
libv8 (3.16.14.15 x86_64-linux) 
loofah (2.0.3) 
mail (2.6.4) 
mime-types (3.1, 3.0) 
mime-types-data (3.2016.0521, 3.2016.0221) 
mimemagic (0.3.2, 0.3.1) 
mini_magick (4.5.1) 
mini_portile2 (2.1.0, 2.0.0) 
minitest (5.9.0, 5.8.3) 
mongo (2.1.0.beta) 
multi_json (1.12.1, 1.12.0) 
multi_xml (0.5.5) 
multipart-post (2.0.0) 
mysql2 (0.4.4) 
nested_form (0.3.2) 
net-telnet (0.1.1) 
nokogiri (1.6.8, 1.6.7.2) 
oauth (0.5.1) 
oauth2 (1.2.0, 1.1.0, 0.8.1) 
omniauth (1.3.1) 
omniauth-facebook (4.0.0, 3.0.0, 1.4.0) 
omniauth-oauth (1.1.0) 
omniauth-oauth2 (1.4.0, 1.0.3) 
omniauth-twitter (1.2.1) 
origin (2.2.0) 
orm_adapter (0.5.0) 
paperclip (5.0.0.beta2) 
passenger (5.0.28) 
pdf-core (0.6.1) 
pg (0.18.4) 
pkg-config (1.1.7) 
power_assert (0.2.6) 
prawn (2.1.0) 
prawn-table (0.2.2) 
prawnto_2 (0.2.6) 
psych (default: 2.0.17) 
rack (1.6.4) 
rack-pjax (0.8.0) 
rack-test (0.6.3) 
rails (4.2.6) 
rails-api (0.4.0) 
rails-deprecated_sanitizer (1.0.3) 
rails-dom-testing (1.0.7) 
rails-html-sanitizer (1.0.3) 
rails_12factor (0.0.3) 
rails_admin (0.8.1) 
rails_serve_static_assets (0.0.5) 
rails_stdout_logging (0.0.5) 
railties (4.2.6) 
rake (11.2.2, 11.1.2, 10.4.2) 
rdoc (4.2.2, default: 4.2.1) 
recaptcha (3.2.0) 
ref (2.0.0) 
regexp_parser (0.3.3) 
remotipart (1.2.1) 
responders (2.3.0, 2.2.0) 
rmagick (2.15.4) 
rubygems-bundler (1.4.4) 
rubygems-update (2.6.4) 
rvm (1.11.3.9) 
safe_yaml (1.0.4) 
sass (3.4.22) 
sass-rails (5.0.6, 5.0.5, 5.0.4) 
sdoc (0.4.1) 
simple_form (3.3.1, 3.2.1) 
sort_alphabetical (1.0.2) 
spring (1.7.2, 1.7.1) 
sprockets (3.7.0, 3.6.3, 3.6.0) 
sprockets-rails (3.2.0, 3.1.1, 3.0.4) 
test-unit (3.1.5) 
therubyracer (0.12.2) 
thor (0.19.1) 
thread_safe (0.3.5) 
tilt (2.0.5, 2.0.4) 
time_difference (0.4.2) 
ttfunk (1.4.0) 
turbolinks (5.0.1, 5.0.0, 2.5.3) 
turbolinks-source (5.0.0) 
twitter-bootswatch-rails (3.3.4.0) 
twitter-bootswatch-rails-helpers (3.3.2.0) 
tzinfo (1.2.2) 
uglifier (3.0.2, 3.0.0) 
underscore-rails (1.8.3) 
unicode_utils (1.4.0) 
warden (1.2.6) 
web-console (2.3.0) 
wysiwyg-rails (2.2.4) 

마침내를, 여기 내 설정이다/application.rb 코드 :

require File.expand_path('../boot', __FILE__) 

require "rails" 
# Pick the frameworks you want: 
require "active_model/railtie" 
require "active_job/railtie" 
# require "active_record/railtie" 
require "action_controller/railtie" 
require "action_mailer/railtie" 
require "action_view/railtie" 
require "sprockets/railtie" 
require "rails/test_unit/railtie" 

# Require the gems listed in Gemfile, including any gems 
# you've limited to :test, :development, or :production. 
Bundler.require(*Rails.groups) 

module Comigo 
    class Application < Rails::Application 
    # Settings in config/environments/* take precedence over those specified here. 
    # Application configuration should go into files in config/initializers 
    # -- all .rb files in that directory are automatically loaded. 

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 
    # config.time_zone = 'Central Time (US & Canada)' 

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 
    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 
    # config.i18n.default_locale = :de 
    config.action_view.javascript_expansions[:defaults] = %w(jquery.min jquery_ujs) 
    end 

감사합니다. 도와 줘. 나는 몇 시간 동안이 문제에 갇혀있다!

+1

문제가 아니므로 레일스 애셋 파이프 라인을 사용하여 해당 라인을 제거하고 (자바 스크립트에서 jquery.min 및 jquery_ujs를 추가하십시오) application.js 매니페스트 – arieljuod

+0

코드를 게시 할 수 있습니까? 나는 당신이 이야기하고있는 라인에 대해 확신하지 못합니다 ... –

+0

덕분에, 당신은 저를 도왔습니다! –

답변

0

arieljuod이 문제를 해결하는 데 도움이되었습니다. 난 그냥 그 라인은 다음과 같은 순서로 자산/자바 스크립트/application.js에 추가 된 것을 확인했다 :

//= require jquery 
//= require jquery_ujs 

하고 난 다음에 내 설정/application.rb 코드 변경 :

require File.expand_path('../boot', __FILE__) 

require "rails" 
# Pick the frameworks you want: 
require "active_model/railtie" 
require "active_job/railtie" 
# require "active_record/railtie" 
require "action_controller/railtie" 
require "action_mailer/railtie" 
require "action_view/railtie" 
require "sprockets/railtie" 
require "rails/test_unit/railtie" 

# Require the gems listed in Gemfile, including any gems 
# you've limited to :test, :development, or :production. 
Bundler.require(*Rails.groups) 

module Comigo 
    class Application < Rails::Application 
    # Settings in config/environments/* take precedence over those specified here. 
    # Application configuration should go into files in config/initializers 
    # -- all .rb files in that directory are automatically loaded. 

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 
    # config.time_zone = 'Central Time (US & Canada)' 

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 
    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 
    # config.i18n.default_locale = :de 
    #config.action_view.javascript_expansions[:defaults] = %w(jquery.min jquery_ujs) 
    end 

을 빠른 솔루션이지만, 몇 시간이 걸렸습니다. D

관련 문제