Skip to content

undefined method `fields' for nil:NilClass  #179

@telezoic

Description

@telezoic

Hi folks,

I'm working through the production build as outlined at: https://digitalnz.github.io/supplejack/start/production-install.html

I think I've found a way (almost) to connect a production solr instance to the API. With solr 5 I have created a ‘production’ core, generated the sunspot solr files, copied those files to the production core, changed the sunspot.yml to point to production core, and created a symlink from the sunspot production folder to the solr production core.

I can start my solr instance and see my new production core [at localhost:8983/solr] by running rake sunspot:solr:start RAILS_ENV=production from the api folder.

From the api folder if I run bundle exec rails s -b 0.0.0.0 -p 3000, the api gives the following error:

{
  "errors": [
    "RSolr::Error::Http - 404 Not Found\nError:     Not Found\n\nURI: http://localhost:8982/solr/default/select?wt=json\nRequest Headers: {\"Content-Type\"=>\"application/x-www-form-urlencoded; charset=UTF-8\"}\nRequest Data: \"fq=type%3ASupplejackApi%5C%3A%5C%3ARecord&fq=record_type_i%3A0&&start=0&rows=20&q=*%3A*\"\n\nBacktrace: /home/ArchMage/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rsolr-2.2.1/lib/rsolr/client.rb:206:in `rescue in execute'\n/home/ArchMage/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rsolr-2.2.1/lib/rsolr/client.rb:196:in `execute'\n/home/ArchMage/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/rsolr-2.2.1/lib/rsolr/client.rb:191:in `send_and_receive'\n/home/ArchMage/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/sunspot_rails-2.2.8/lib/sunspot/rails/solr_instrumentation.rb:16:in `block in send_and_receive_with_as_instrumentation'\n/home/ArchMage/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activesupport-5.1.4/lib/active_support/notifications.rb:166:in `block in instrument'\n/home/ArchMage/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activesupport-5.1.4/lib/active_support/notifications/instrumenter.rb:21:in `instrument'\n/home/ArchMage/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/activesupport-5.1.4/lib/active_support/notifications.rb:166:in `instrument'\n/home/ArchMage/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/sunspot_rails-2.2.8/lib/sunspot/rails/solr_instrumentation.rb:15:in `send_and_receive_with_as_instrumentation'\n(eval):2:in `post'\n/home/ArchMage/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/sunspot-2.2.8/lib/sunspot/search/abstract_search.rb:49:in `execute'\n/home/ArchMage/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/supplejack_api-c262ce8a72d7/app/models/supplejack_api/search.rb:350:in `execute_solr_search_and_handle_errors'"
  ]
}

I'm thinking this is because I haven't specified the production environment (8983)

I added a line to the puma.rb file

environment ENV.fetch("RAILS_ENV") { "production" }

and then tried starting the api with bundle exec rails s -e production -b 0.0.0.0 -p 3000.

this throws the following:

/home/ArchMage/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/devise-4.3.0/app/controllers/devise/sessions_controller.rb:5: syntax error, unexpected '{', expecting keyword_end (SyntaxError)
...ion only: [:create, :destroy] { request.env["devise.skip_tim...
...                              ^
/home/ArchMage/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/devise-4.3.0/app/controllers/devise/sessions_controller.rb:5: syntax error, unexpected '}', expecting keyword_end
..."devise.skip_timeout"] = true }

I see some discussion online of a bug with ruby 2.5.+ (I'm at ruby 2.5.3p105) and devise 4.3.0 around the session controller. Updating to devise 4.4.0 removes the error but throws a new one from the api gem:

/home/ArchMage/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/supplejack_api-c262ce8a72d7/app/models/supplejack_api/set_item.rb:7:in `<class:SetItem>': undefined method `fields' for nil:NilClass (NoMethodError)

I hoping you might have a strategy/pointer to help me get around this :)

Thanks,

D.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions