Hello,
MyModel.rb,
TYPES = { "type1" => 1 , "type2" => 2,
"type3" => 3 }.freeze
validates_inclusion_of :my_type, :in => TYPES.keys
---------------------------------------
MyModelPatch.rb,
base.send(:remove_const, :TYPES)
base._validators[:my_type].reject!{ |validator| validator if
validator.is_a? ActiveModel::Validations::InclusionValidator }
TYPES = { "type1" => 1 , "type2" => 2,
"type3" => 3,"type4" => 4,
"type5" => 5 }.freeze
base.const_set('TYPES',TYPES)
base.class_eval do
validates_inclusion_of :my_type, :in => TYPES.keys
end
----------------------------------------
In my View or Console, The MyModel::TYPES gives me the patched hash, But
saving the patched model with the new types failes. With the error "is
not included in the list"
Please help me, As I am not able to figure out what wrong I have done,
And am I missing something.
Thank You,
Best Regards,
Rupesh
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/485fd1cd8035e73f0f5b182c368c77a8%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.