2016-09-12 4 views
0

Ich bin auf einem sehr seltsamen Problem fest. Ich habe meine Rails-Anwendung erfolgreich in der Entwicklungsumgebung entwickelt und getestet, aber in dem Prozess, meine Site in der Produktionsumgebung zu starten, musste ich den Befehl rake secret ausführen. Leider konfrontiert, ich die folgende Fehlermeldung:Rails NoMethodError: undefinierte Methode `[] = 'für Nil: NilClass in Produktionsumgebung

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' 

Suche im Internet i zu einigen verwandten Themen umgeleitet wurde, aber keiner von ihnen waren streng die gleiche wie meine. Hier liste ich einige Probleme auf, die Ihnen wahrscheinlich ein großes Bild von der Umgebung meines Projekts geben können: 1) Ich benutze Gerät zur Authentifizierung (Version 3.4.1) 2) Dieses Problem tritt nur in der Produktionsumgebung auf 3) Ich habe die gleichen Versionen von ruby ​​und Rails in der Produktion und Entwicklung Umwelt 4) hier die Edelsteine ​​sind, die ich verwende:

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) 

Finaly, hier ist meine config/application.rb Code:

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 

Danke, ich hoffe, dass jeder ca n hilf mir. Ich stecke mehrere Stunden in diesem Problem fest!

+1

Es ist kein Problem, Sie sollten zur Verwendung von Rails Assets Pipeline, entfernen Sie diese Zeile (die eine durch den Fehler hingewiesen) und jquery.min und jquery_ujs zu Ihrem Javascript hinzufügen application.js manifest – arieljuod

+0

können Sie den Code veröffentlichen? Ich bin mir nicht sicher über welche Linie du sprichst ... –

+0

danke, du hast mir geholfen! –

Antwort

0

arieljuod hat mir geholfen, das Problem zu lösen. i nur dafür gesorgt, dass diese Linien in assets/Javascripts/application.js in der folgenden Reihenfolge hinzugefügt wurden:

//= require jquery 
//= require jquery_ujs 

und ich änderte meine config/application.rb Code wie folgt:

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 

Schnelle Lösung, aber es dauerte mehrere Stunden: D

Verwandte Themen