Structure of ruby file is as shown below,
market
|__abcd
|__classification
|__for_sale_mobile_phone.rb
|__catalogues
|__mobile_phone_brands
|__acer.rb
|__apple.rb
|__samsung.rb
In for_sale_mobile_phone.rb
, I like to include all brands of mobile_phone_brands
under a block.
I m trying to include brands in below fashion,
.....
c.tree_field :brand, { child_key: :model } do |b|
Dir[
File.dirname(__FILE__) + '/catalogues/mobile_phone_brands/*.rb'
].each { |brand| load brand }
b.required = true
end
.....
here is how brand file looks like. for example, apple.rb
b.value "apple" do |brand|
brand.value "6plus"
brand.value "6s"
brand.value "6s-plus"
brand.value "se"
brand.value "7"
brand.value "7-plus"
brand.value "other-model"
end
I m getting below error,
undefined local variable or method `b' on line 1: apple.rb
How can I include file under a block scope?
Thanks in advance!