You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use this lib in a project (ruby 2.3.1p112 and 'rails', '~> 5.0.1'), but wasn't able to point to a different YAML configuration. I've put the following code into config/initializers/cnab150.rb:
Cnab150.configure do |config|
config.layout_file_path = "#{Rails.root}/config/cnab150.yml"
end
But I get this: project/config/initializers/cnab150.rb:2:in `block in <top (required)>': undefined method `layout_file_path=' for nil:NilClass (NoMethodError)
The text was updated successfully, but these errors were encountered:
To follow up, I monkeypatched the configuration file and it worked. I'm very new to ruby/rails, so I'm not really sure what's going on, but I guess it's got to do with the Rails version I'm using.
Code patched:
module Cnab150
class << self
attr_accessor :config
end
def self.configure
self.config ||= Configuration.new
yield(config)
end
class Configuration
attr_accessor :layout_file_path
def initialize
@layout_file_path = "#{File.dirname(__dir__)}/../config/layout.yml"
end
# The layouts method load the layouts from the yml file.
def layouts
@_ ||= YAML.load_file(@layout_file_path)['cnab150']
end
end
end
I'm trying to use this lib in a project (
ruby 2.3.1p112
and'rails', '~> 5.0.1'
), but wasn't able to point to a different YAML configuration. I've put the following code intoconfig/initializers/cnab150.rb
:But I get this:
project/config/initializers/cnab150.rb:2:in `block in <top (required)>': undefined method `layout_file_path=' for nil:NilClass (NoMethodError)
The text was updated successfully, but these errors were encountered: