ruby on rails - Configuration of ContentfulModel gem is lost after initialization -


completely new rails 4.2.3 application. changes gemfile have been removal of spring, addition of dotenv, , latest contentful_rails , contentful_model gems published on rubygems.org.

for unknown reasons, configuration details defined in initializer gone time app comes up. it's same object (same value contentfulmodel.configuration.object_id) values correct nil.

i added initializer shown in readme.

$ cat config/initializers/contentful_model.rb  contentfulmodel.configure |config|   byebug   config.access_token         = env['contentful_access_token']   config.preview_access_token = env['contentful_preview_access_token']   config.space                = env['contentful_space'] #  config.options              = {     #extra options send contentful::client #  } end 

and defined 1 model, category.

$ cat app/models/category.rb  class category < contentfulmodel::base    self.content_type_id = "[category content type string]" end 

so here's happens when fire rails console:

$ rails c  [1, 9] in /home/trevor/code/chef/www-contentful-rails/config/initializers/contentful_model.rb    1: contentfulmodel.configure |config|    2:   config.access_token         = env['contentful_access_token']    3:   config.preview_access_token = env['contentful_preview_access_token']    4:   config.space                = env['contentful_space']    5: #  config.options              = {    6:     #extra options send contentful::client    7: #  }    8:   byebug => 9: end (byebug) contentfulmodel.configuration #<contentfulmodel::configuration:0x00000005bc7be0 @access_token="[my actual token string]", @entry_mapping={}, @preview_access_token="[my actual preview token string]", @space="[my actual space]"> (byebug) continue /home/trevor/.rvm/gems/ruby-2.2.2@www-contentful-rails/gems/actionpack-4.2.3/lib/action_dispatch/http/mime_type.rb:163: warning: initialized constant mime::json                     /home/trevor/.rvm/gems/ruby-2.2.2@www-contentful-rails/gems/actionpack-4.2.3/lib/action_dispatch/http/mime_type.rb:163: warning: previous definition of json here                        loading development environment (rails 4.2.3) 2.2.2 :001 > contentfulmodel.configuration  => #<contentfulmodel::configuration:0x00000005bc7be0 @access_token=nil, @entry_mapping={"[category content type string]"=>category}, @preview_access_token=nil, @space=nil>                         2.2.2 :002 >  

i've spent bunch of time sifting gem source , stepping through debugger without results. i've posted an issue project on github because haven't been able identify source of problem , have assume within gem. assistance how troubleshoot further welcome!

the solution use undocumented approach required due changes few months ago.

the contentful_rails gem requires contentful_model (and vice versa), , configuration documentation contentful_model in project's readme, describing approach in question. configuration made in way wiped when contentful_rails initialized, expected configuration done in own initializer.

so have deleted config/initializers/contentful_model.rb , config/intializers/contents_rails.rb file looks like:

contentfulrails.configure |config|   config.authenticate_webhooks = true # false here allow webhooks process without basic auth   config.webhooks_username     = env['contentful_webhook_username']   config.webhooks_password     = env['contentful_webhook_password']    config.access_token          = env['contentful_access_token']   config.preview_access_token  = env['contentful_preview_access_token']   config.space                 = env['contentful_space']   config.contentful_options    = {     #extra options send contentful::client   } end 

of note config.options no longer thing; it's config.contentful_options.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -