i have a table called "confirm_clients",there are 3columns,they are t.column :user_id, :string t.column :msg_id, :string t.column :confirm, :boolean i want to check whether the boolean value of confirm is true when a given user_id and msg_id,plz can anyone how can i do it --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Ishara Gunathilake wrote:> i have a table called "confirm_clients",there are 3columns,they are > t.column :user_id, :string > t.column :msg_id, :string > t.column :confirm, :boolean > > i want to check whether the boolean value of confirm is true > when a given user_id and msg_id,plz can anyone how can i do ittry to use "before_save" in model class -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
assuming 0 as false and 1 as true. Try it out confirm_client=ConfirmClient.find(5) # I am supposing the client with id 5 if confirm_client.confirm==1 #yes indeed this client is verified do_something else #not verified client do_something_else probably redirect to some place with flash[:notice] end On Nov 1, 10:58 am, "Ishara Gunathilake" <jaimgunathil...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> i have a table called "confirm_clients",there are 3columns,they are > t.column :user_id, :string > t.column :msg_id, :string > t.column :confirm, :boolean > > i want to check whether the boolean value of confirm is true > when a given user_id and msg_id,plz can anyone how can i do it--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Nov 1, 7:54 am, mrbless <mrbl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> assuming 0 as false and 1 as true. Try it out > confirm_client=ConfirmClient.find(5) # I am supposing the client with > id 5How true/false are represented in the DB is database dependant. You don''t need to worry about that though - confirm_client.confirm is typecasted by rails to either true or false no matter what the underlying column stores (t/f, 0/1, Y/N etc...) Fred> if confirm_client.confirm==1 #yes indeed this client is verified > do_something > else #not verified client > do_something_else probably redirect to some place with > flash[:notice] > end > > On Nov 1, 10:58 am, "Ishara Gunathilake" <jaimgunathil...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > i have a table called "confirm_clients",there are 3columns,they are > > t.column :user_id, :string > > t.column :msg_id, :string > > t.column :confirm, :boolean > > > i want to check whether the boolean value of confirm is true > > when a given user_id and msg_id,plz can anyone how can i do it--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Nov 1, 2008, at 8:52 AM, Frederick Cheung wrote:> On Nov 1, 7:54 am, mrbless <mrbl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> assuming 0 as false and 1 as true. Try it out >> confirm_client=ConfirmClient.find(5) # I am supposing the client with >> id 5 > > How true/false are represented in the DB is database dependant. You > don''t need to worry about that though - confirm_client.confirm is > typecasted by rails to either true or false no matter what the > underlying column stores (t/f, 0/1, Y/N etc...) > > FredBut, I''ve found that you almost always want to replace: t.column :confirm, :boolean with t.column :confirm, :boolean, :default => false, :null => false Unless you need the SQL NULL to mean something other than "not true" (because it is also "not false") Otherwise, something like: ConfirmClient.find(:all, :conditions => { :confirm => [true, false] }) Does *NOT* find all the records. This is usually when you begin to question your sanity until discovering the NULL values in the ''confirm'' column. -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> >> if confirm_client.confirm==1 #yes indeed this client is verified >> do_something >> else #not verified client >> do_something_else probably redirect to some place with >> flash[:notice] >> end >> >> On Nov 1, 10:58 am, "Ishara Gunathilake" <jaimgunathil...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> wrote: >> >>> i have a table called "confirm_clients",there are 3columns,they are >>> t.column :user_id, :string >>> t.column :msg_id, :string >>> t.column :confirm, :boolean >> >>> i want to check whether the boolean value of confirm is true >>> when a given user_id and msg_id,plz can anyone how can i do it--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---