During migration I would like to turn off a single validation. That is, I don''t want to turn off all validations for a single record, I want to turn of a single validation (of several) for all records. -- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Feb 26, 3:18 am, Ralph Shnelvar <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> During migration I would like to turn off a single validation. > > That is, I don''t want to turn off all validations for a single record, I > want to turn of a single validation (of several) for all records.If you''re using models in a migration you should usually be creating a private copy of the class in the migration ie class SomeMigration < ... class SomeModel < ActiveRecord::Base end def self.up ... end end ( see also http://guides.rubyonrails.org/migrations.html#using-models-in-your-migrations ) Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung wrote:> > If you''re using models in a migration you should usually be creating a > private copy of the class in the migration ie. . . Fred, thank you. What you propose is the right way to do things. I''m looking for the wrong way to do things .. that is, I''m looking to turn off a validation once it has been turned on. Ralph -- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 26 February 2010 13:24, Ralph Shnelvar <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Frederick Cheung wrote: >> >> If you''re using models in a migration you should usually be creating a >> private copy of the class in the migration ie > . . . > > Fred, thank you. > > What you propose is the right way to do things. I''m looking for the > wrong way to do things .. that is, I''m looking to turn off a validation > once it has been turned on.I think you missed Frederick''s point, (or I have missed yours). Note that he is suggesting putting a local declaration of your model class _inside_ the migration. This means that any validations in your model.rb file will not be seen. There should not be a need for validations inside a migration, so the fact that all validations are being ignored should not matter. (You are doing a migration not a seed aren''t you?). class SomeMigration < ... class SomeModel < ActiveRecord::Base end def self.up ... end end -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law wrote:>You are doing a migration not a > seed aren''t you?).I''m doing a seed with "random" data and I want all the validations ... except one. I know. I know. I''m bad bad bad. But this is a hack AND I''d like to know if the hack can be done. -- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ralph Shnelvar wrote:> Colin Law wrote: > >>You are doing a migration not a >> seed aren''t you?). > > I''m doing a seed with "random" data and I want all the validations ... > except one.Seeds don''t belong in migrations, and anyway they shouldn''t need you to turn off validations.> > I know. I know. I''m bad bad bad. But this is a hack AND I''d like toDon''t hack. Don''t do things you know are bad. Period.> know if the hack can be done. -- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Feb 26, 6:39 pm, Ralph Shnelvar <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote: > >You are doing a migration not a > > seed aren''t you?). > > I''m doing a seed with "random" data and I want all the validations ... > except one. > > I know. I know. I''m bad bad bad. But this is a hack AND I''d like to > know if the hack can be done.You could probably twist the :if/:unless options for this, although it will almost certainly come and bite you later on. Fred> -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Fri, Feb 26, 2010 at 7:39 PM, Ralph Shnelvar <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote: > >>You are doing a migration not a >> seed aren''t you?). > > I''m doing a seed with "random" data and I want all the validations ... > except one.Another option: If you can trust your seed data save(false) turns off validations. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.