I know its not kindly looked upon for using enum w/ mysql, but how would I do this using the rails migration? or is it even possible? I can''t seem to find this on any sites/books about rails migration. I was simply wanting 2 options of ''Y'',''N'' Ah, but how I love RoR... today was my first ''real'' day outside of tutorials. And glad to just be joining the group! -Salo --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 05/09/06, salo <danielsalo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I know its not kindly looked upon for using enum w/ mysql, but how > would I do this using the rails migration? or is it even possible? I > can''t seem to find this on any sites/books about rails migration. I > was simply wanting 2 options of ''Y'',''N''Doesn''t mysql have a boolean type? -- Rasputin :: Jack of All Trades - Master of Nuns http://number9.hellooperator.net/ --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Sadly it does not, and the MySQL way to do boolean is to use enumerate Y/N, or at least that''s the use I saw most suggested when I was first starting to learn to use MySQL databases. The easiest way to handle this would honestly be to convert your enum columns into single bit integers (Integer :size => 1). But this may not be an option to you depending on who controls the data. Your only other option, I believe, would be to either write, or find, a ror to mysql driver that converts all boolean requests to the database from 1/0 to Y/N. Booleans are a tricky thing to work with in RoR. The idea is to make your application database agnostic, but because of certain quirks, e.g. Oracle and mysql databases not having boolean options, it''s a little hard to reach RoR nirvana. The accepted practice seems to be to use single bit integers, which is why I suggested the change. On 9/5/06, Dick Davies <rasputnik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 05/09/06, salo <danielsalo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I know its not kindly looked upon for using enum w/ mysql, but how > > would I do this using the rails migration? or is it even possible? I > > can''t seem to find this on any sites/books about rails migration. I > > was simply wanting 2 options of ''Y'',''N'' > > Doesn''t mysql have a boolean type? > > -- > Rasputin :: Jack of All Trades - Master of Nuns > http://number9.hellooperator.net/ > > > >-- Mike Weber Web Developer UW-Eau Claire --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 9/5/06, Mike Weber <mikep.dubya-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Sadly it does not, and the MySQL way to do boolean is to use enumerate > Y/N, >MySQL doesn''t have a native boolean type, but it will silently convert columns declared boolean to tinyint(1), which Rails recognizes as de-facto boolean. jeremy --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 05/09/06, Mike Weber <mikep.dubya-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Sadly it does not, and the MySQL way to do boolean is to use enumerate Y/N, > or at least that''s the use I saw most suggested when I was first starting to > learn to use MySQL databases. The easiest way to handle this would honestly > be to convert your enum columns into single bit integers (Integer :size => > 1). But this may not be an option to you depending on who controls the > data. Your only other option, I believe, would be to either write, or find, > a ror to mysql driver that converts all boolean requests to the database > from 1/0 to Y/N. > > Booleans are a tricky thing to work with in RoR. The idea is to make your > application database agnostic, but because of certain quirks, e.g. Oracle > and mysql databases not having boolean options, it''s a little hard to reach > RoR nirvana. The accepted practice seems to be to use single bit integers, > which is why I suggested the change.Makes sense to me to do any required conversion in the connection adapter - also explains why check_box returns 0 and 1 instead of the (to me) more intuitive true/false. -- Rasputin :: Jack of All Trades - Master of Nuns http://number9.hellooperator.net/ --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
check the API, but I believe that you can specify, for checkboxes, what value it takes in and returns. *check_box*(object_name, method, options = {}, checked_value = "1", unchecked_value = "0") as you can see, you can change the checked_value and unchecked_value to work with your interface. So you could create your checkboxes using: check_box(model, method, {}, "Y", "N") On 9/5/06, Dick Davies <rasputnik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 05/09/06, Mike Weber <mikep.dubya-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Sadly it does not, and the MySQL way to do boolean is to use enumerate > Y/N, > > or at least that''s the use I saw most suggested when I was first > starting to > > learn to use MySQL databases. The easiest way to handle this would > honestly > > be to convert your enum columns into single bit integers (Integer :size > => > > 1). But this may not be an option to you depending on who controls the > > data. Your only other option, I believe, would be to either write, or > find, > > a ror to mysql driver that converts all boolean requests to the database > > from 1/0 to Y/N. > > > > Booleans are a tricky thing to work with in RoR. The idea is to make > your > > application database agnostic, but because of certain quirks, e.g. > Oracle > > and mysql databases not having boolean options, it''s a little hard to > reach > > RoR nirvana. The accepted practice seems to be to use single bit > integers, > > which is why I suggested the change. > > Makes sense to me to do any required conversion in the connection adapter > - > also explains why check_box returns 0 and 1 instead of the (to me) more > intuitive true/false. > > -- > Rasputin :: Jack of All Trades - Master of Nuns > http://number9.hellooperator.net/ > > > >-- Mike Weber Web Developer UW-Eau Claire --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
I''ll give that a go right now. It would be nice if rails could detect true / false with the options instead of declaring 1=true 0=false (or maybe it can and I don''t know about it :) Thanks for the input... --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 9/5/06, salo <danielsalo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I know its not kindly looked upon for using enum w/ mysql, but how > would I do this using the rails migration? or is it even possible? I > can''t seem to find this on any sites/books about rails migration. I > was simply wanting 2 options of ''Y'',''N'' > > Ah, but how I love RoR... today was my first ''real'' day outside of > tutorials. And glad to just be joining the group! > > > -SaloMy team had some issues with this that you might be interested in. The short version: enums and migrations don''t mix well at all - avoid. long version: http://www.robsanheim.com/2006/08/24/rails-schema-dumper-mysql-enums-bad-for-business/ - rob -- http://www.robsanheim.com http://www.seekingalpha.com http://www.ajaxian.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
It''s funny that I found your site with that information on google before you posted here... I''m starting to do just that: avoid enums and migrations, but I feel that this is something that should change in the future of RoR. -Salo --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Rob Sanheim wrote:> On 9/5/06, salo <danielsalo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> -Salo > My team had some issues with this that you might be interested in. > The short version: enums and migrations don''t mix well at all - avoid. >Thanks for confirming that, I have the same problem, and my enum is not ''true'', ''false'' either. I just simple not to use migration. I am still use my SQL script, I am OK. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---