Sunspot_configuration.rb:52:in `block in <top (required)>': undefined method `gsub' for nil:NilClass

I was uploading my app to a server, put it in production mode on the
server, still on development mode locally and suddenly I cannot run
“rails
server” anymores since it dies automatically with this error:

/Users/agusddt/developments/crm/config/initializers/sunspot_configuration.rb:52:in
block in <top (required)>': undefined methodgsub’ for nil:NilClass
(NoMethodError)

from
/Users/agusddt/developments/crm/config/initializers/sunspot_configuration.rb:45:in
`each’

from
/Users/agusddt/developments/crm/config/initializers/sunspot_configuration.rb:45:in
`<top (required)>’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in
`load’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in
`block in load’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in
`load_dependency’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in
`load’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/engine.rb:652:in
`block in load_config_initializer’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/notifications.rb:166:in
`instrument’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/engine.rb:651:in
`load_config_initializer’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/engine.rb:616:in
`block (2 levels) in class:Engine

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/engine.rb:615:in
`each’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/engine.rb:615:in
`block in class:Engine

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/initializable.rb:30:in
`instance_exec’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/initializable.rb:30:in
`run’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/initializable.rb:55:in
`block in run_initializers’

from
/Users/agusddt/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:226:in
`block in tsort_each’

from
/Users/agusddt/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:348:in
`block (2 levels) in each_strongly_connected_component’

from
/Users/agusddt/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:418:in
`block (2 levels) in each_strongly_connected_component_from’

from
/Users/agusddt/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:427:in
`each_strongly_connected_component_from’

from
/Users/agusddt/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:417:in
`block in each_strongly_connected_component_from’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/initializable.rb:44:in
`each’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/initializable.rb:44:in
`tsort_each_child’

from
/Users/agusddt/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:411:in
`call’

from
/Users/agusddt/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:411:in
`each_strongly_connected_component_from’

from
/Users/agusddt/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:347:in
`block in each_strongly_connected_component’

from
/Users/agusddt/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:345:in
`each’

from
/Users/agusddt/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:345:in
`call’

from
/Users/agusddt/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:345:in
`each_strongly_connected_component’

from
/Users/agusddt/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:224:in
`tsort_each’

from
/Users/agusddt/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/tsort.rb:205:in
`tsort_each’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/initializable.rb:54:in
`run_initializers’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/application.rb:352:in
`initialize!’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/railtie.rb:194:in
`public_send’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/railtie.rb:194:in
`method_missing’

from /Users/agusddt/developments/crm/config/environment.rb:5:in `<top
(required)>’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in
`require’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in
`block in require’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in
`load_dependency’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in
`require’

from /Users/agusddt/developments/crm/config.ru:3:in `block in ’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/rack-1.6.4/lib/rack/builder.rb:55:in
`instance_eval’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/rack-1.6.4/lib/rack/builder.rb:55:in
`initialize’

from /Users/agusddt/developments/crm/config.ru:in `new’

from /Users/agusddt/developments/crm/config.ru:in `’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/rack-1.6.4/lib/rack/builder.rb:49:in
`eval’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/rack-1.6.4/lib/rack/builder.rb:49:in
`new_from_string’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/rack-1.6.4/lib/rack/builder.rb:40:in
`parse_file’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/rack-1.6.4/lib/rack/server.rb:299:in
`build_app_and_options_from_config’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/rack-1.6.4/lib/rack/server.rb:208:in
`app’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/commands/server.rb:61:in
`app’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/rack-1.6.4/lib/rack/server.rb:336:in
`wrapped_app’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/commands/server.rb:139:in
`log_to_stdout’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/commands/server.rb:78:in
`start’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:80:in
`block in server’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:75:in
`tap’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:75:in
`server’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:39:in
`run_command!’

from
/Users/agusddt/.rvm/gems/ruby-2.1.5/gems/railties-4.2.3/lib/rails/commands.rb:17:in
`<top (required)>’

from bin/rails:4:in `require’

from bin/rails:4:in `’

Taking a look into the logs appears just a warning:

DEPRECATION WARNING: Currently, Active Record suppresses errors raised
within after_rollback/after_commit callbacks and only print them to
the
logs. In the next version, these errors will no longer be suppressed.
Instead, the errors will propagate normally just like in other Active
Record callbacks.

You can opt into the new behavior and remove this warning by setting:

config.active_record.raise_in_transactional_callbacks = true

(called from class:Asset at
/Users/agusddt/developments/crm/app/models/asset.rb:21)

But it seems the error is associated to asset.rb

Anyone can help me? I tried serveral things but I just do not know what
else to do.

Thanks!

On Wednesday, July 22, 2015 at 5:17:29 PM UTC+1, agusddt wrote:

/Users/agusddt/developments/crm/config/initializers/sunspot_configuration.rb:45:in

`each’

from

/Users/agusddt/developments/crm/config/initializers/sunspot_configuration.rb:45:in

`<top (required)>’

[snip]

I doubt this warning is relevant - the probably is almost certainly in
config/initializers/sunspot_configuration.rb:52

Fred

I even uninstalled sunspot_Rails, sunspot_solr and their dependencies
and
still gices me the error and would not let me run "rails server"on
localhost

El miércoles, 22 de julio de 2015, 13:52:43 (UTC-3), agusddt escribió:

Fred, thanks for your answer.
The thing is that I cannot run "rails server"on localhost, it terminates
immediately.

El miércoles, 22 de julio de 2015, 13:20:04 (UTC-3), Frederick C.
escribió:

On 22 July 2015 at 17:52, agusddt [email protected] wrote:

Fred, thanks for your answer.
The thing is that I cannot run "rails server"on localhost, it terminates
immediately.

You have not said what is in
config/initializers/sunspot_configuration.rb:52 as suggested by Fred

Colin

On 22 July 2015 at 20:21, agusddt [email protected] wrote:

Sorry about that, problem is on line highlighted.
This is sunspot_configuration.rb:

Kernel.const_get "#{model_name.gsub('.rb', '').camelize}"

Well, as the error indicates, presumably model_name is nil

Colin

Sorry about that, problem is on line highlighted.
This is sunspot_configuration.rb:

ActiveRecord::Base.class_eval do

def current_model
require Rails.root + ‘lib/util/generic_decorators.rb’

if file.include? ‘/liquid/’

end

El miércoles, 22 de julio de 2015, 15:28:02 (UTC-3), Colin L. escribió:

On Wed, Jul 22, 2015 at 10:45 AM, agusddt [email protected] wrote:

I was uploading my app to a server, put it in production mode on the
server, still on development mode locally and suddenly I cannot run “rails
server” anymores since it dies automatically with this error:

/Users/agusddt/developments/crm/config/initializers/sunspot_configuration.rb:52:in

block in <top (required)>': undefined method gsub’ for nil:NilClass
(NoMethodError)

I’m very curious about what you’re describing. You’re remark above about
uploading to your server notwithstanding, your local development
environment shouldn’t have changed at all simply because you uploaded
your
app someplace else. Did you remove or change something from your
development environment when you uploaded? If not, there must be
something
quite else going on.

As this worked in development before, perhaps if you were to ensure your
local environment can roll back to a previous version that’s known to
work.

Are you seeing problems in production or is everything there working
well?

Thanks for your answer!

I understand that It shouldn’t have changed just because I uploaded it,
the
thing is I did make some minor changes (on the views) and upload them
without checking on the local host but on the remote server. Everything
is
working perfectly on the server under production, the only solution I
found
was to uninstall the gems and delete all associated configuration. Upon
doing that it worked fine locally but the thing is I do need to use the
gem
Sunspot, so tried to install it back and it stopped running again.

I commented the line that was giving me trouble just for now to keep
working, but o don’t understand what could have happened, since I’m
pretty
sure I did not mess on the configuration locally when uploading.

Em quinta-feira, 23 de julho de 2015, tamouse pontiki <
[email protected]> escreveu:

On 24 July 2015 at 03:17, Agustina Diaz de Tuesta [email protected]
wrote:

I commented the line that was giving me trouble just for now to keep
working, but o don’t understand what could have happened, since I’m pretty
sure I did not mess on the configuration locally when uploading.

If you check out the previously working version from your source
control system and run bundle install then you should be back with a
working system. So all your automated tests should work, as should
rails s.

Colin