json_schema_builder
json_schema_builder copied to clipboard
Error for models containing at least one concern with `included` block
Hi and thanks for this gem
If I have a model
class Account < ActiveRecord::Base
include Avatarify
end
that includes a concern
module Meritify
extend ActiveSupport::Concern
included do
mount_uploader :avatar, AvatarUploader
end
def thumb_avatar_url
avatar.thumb.url
end
def normal_avatar_url
avatar.normal.url
end
end
and i run
SchemaBuilder::Writer.new.write
via rails console
I'm getting this
ActiveSupport::Concern::MultipleIncludedBlocks: Cannot define multiple 'included' blocks for a Concern
from /home/oivai/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/concern.rb:126:in `included'
If I exclude concern from model, everything works just fine. Would you point me to the right direction? Is there a solution?
I suppose there is a problem with your own module inclusion, as we dont use any ActiveSupport::Concern in here.
The writer just looks at your models and tries to figure out their names and available fields in model_as_hash:
find models: https://github.com/salesking/json_schema_builder/blob/master/lib/schema_builder/writer.rb#L121 Introspect: https://github.com/salesking/json_schema_builder/blob/master/lib/schema_builder/writer.rb#L36
By looking at the error you seem to use the 'included do' block twice within the same module. Maybe you have a chance to prevent the usage of AR::Concern(and its hard-to-figure-out-errors-magic) by using the plain 'includes InstanceMethods, extend ClassMethods' scheme.
Thanks, I'll give it a try!
On 21.03.2016 at 10:54 GMT Georg Leciejewski wrote:
I suppose there is a problem with your own module inclusion, as we dont use any ActiveSupport::Concern in here.
The writer just looks at your models and tries to figure out their names and available fields in model_as_hash:
find models: https://github.com/salesking/json_schema_builder/blob/master/lib/schema_builder/writer.rb#L121 Introspect: https://github.com/salesking/json_schema_builder/blob/master/lib/schema_builder/writer.rb#L36
By looking at the error you seem to use the 'included do' block twice within the same module. Maybe you have a chance to prevent the usage of AR::Concern(and its hard-to-figure-out-errors-magic) by using the plain 'includes InstanceMethods, extend ClassMethods' scheme.
— You are receiving this because you authored the thread. Reply to this email directly or https://github.com/salesking/json_schema_builder/issues/5#issuecomment-199224073<<view it on GitHub>>