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
The error occur when trying to create a new model using ActiveRecord which hasn't been initialized in the config/configurable.yml file.
Ruby Version: 2.6.6
gem version: 0.4.6
Inside a Rails console:
c=Configurable.newc.name='evil'c.value='monkey_patch't=Time.now.to_s(:db)c.created_at=tc.updated_at=tc.valid?c.valid?NoMethodError: undefinedmethod`[]' for nil:NilClassfrom /home/dev/rails/my_app/vendor/cache/gems/configurable_engine-0.4.8/app/models/configurable.rb:125:in `type_of_value'
Looking at the method reveals the bug, which should be an easy fix:
deftype_of_valuereturnunlessnamevalid=caseConfigurable.defaults[name][:type]# raises if Configurable.defaults[name].nil?when'boolean'[true,1,"1","true",false,0,"0","false"].include?(value)when'decimal'BigDecimal(value)rescuefalsewhen'integer'Integer(value)rescuefalsewhen'list'value.is_a?(Array)elsetrueenderrors.add(:value,I18n.t("activerecord.errors.messages.invalid"))unlessvalidend
The text was updated successfully, but these errors were encountered:
The error occur when trying to create a new model using
ActiveRecord
which hasn't been initialized in theconfig/configurable.yml
file.Ruby Version: 2.6.6
gem version: 0.4.6
Inside a Rails console:
Looking at the method reveals the bug, which should be an easy fix:
The text was updated successfully, but these errors were encountered: