Hi... I use non modal attribute for companyinfo modal.. For that i have created like below attr_accessor :std_code To validate that field i included the below code in to my companyinfo modal. validates_presence_of :std_code,:message => ''*The std number is required.'' it validates when i leave that field empty and shows the validation error. but even after filling the field it shows me error.... what would be the problem.... pls help -- Posted via http://www.ruby-forum.com/.
pls help me -- Posted via http://www.ruby-forum.com/.
2009/6/4 Newb Newb <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > Hi... > I use non modal attribute for companyinfo modal.. > For that i have created like below > > attr_accessor :std_code >I am not sure what you mean by a non modal attribute.> To validate that field i included the below code in to my companyinfo > modal. > > validates_presence_of :std_code,:message => ''*The std number is > required.'' > > it validates when i leave that field empty and shows the validation > error. > but even after filling the field it shows me error.... > what would be the problem.... > pls helpHave you checked in the rails log that std_code is being passed in with the params? Colin
Colin Law wrote:> 2009/6/4 Newb Newb <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>: >> >> Hi... >> I use non modal attribute for companyinfo modal.. >> For that i have created like below >> >> attr_accessor :std_code >> > > I am not sure what you mean by a non modal attribute. > >> pls help > Have you checked in the rails log that std_code is being passed in > with the params? > > Colinyes it has been passed with params actually i dont have any field like std_code into my table. so i mentioned as non modal attribute i use like below in my form. <%= error_message_on( @company, :std_code) -%> <%= f.text_field :std_code, { :class => "txtbox",:size => "2" } %> pls guide me -- Posted via http://www.ruby-forum.com/.
2009/6/4 Newb Newb <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > Colin Law wrote: >> 2009/6/4 Newb Newb <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>: >>> >>> Hi... >>> I use non modal attribute for companyinfo modal.. >>> For that i have created like below >>> >>> attr_accessor :std_code >>> >> >> I am not sure what you mean by a non modal attribute. >> >>> pls help >> Have you checked in the rails log that std_code is being passed in >> with the params? >> >> Colin > > yes it has been passed with params > > actually i dont have any field like std_code into my table. > so i mentioned as non modal attribute > i use like below in my form. > <%= error_message_on( @company, :std_code) -%> > <%= f.text_field :std_code, { :class => "txtbox",:size => "2" } %> > pls guide me > --I have not tried to validate an attribute that is not in the table. If it is not saving it what is the point of the validation? I would suggest using ruby-debug to break into the controller just before the validation and check the value of std_code. Colin
Thank you for taking time to reply... That is i have phone field into my table. I get country code and std code and phone code from the form after getting i append like below 1-011-5558 then i save into my phone field. so i in my modal i have like below attr_accessor :country_code,:std_code,phone_code for this purpose i have to validate those three atrr_accessor fields.. i mean is phone = country_code+"-"+std_code+"-"+phone_code Any Helps -- Posted via http://www.ruby-forum.com/.
any helps or suggestions pls... -- Posted via http://www.ruby-forum.com/.
2009/6/4 Newb Newb <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > Thank you for taking time to reply... > > That is i have phone field into my table. > I get country code and std code and phone code from the form > after getting i append like below > > 1-011-5558 > > then i save into my phone field. > > so i in my modal i have like below > > attr_accessor :country_code,:std_code,phone_code > > > for this purpose i have to validate those three atrr_accessor fields.. > > i mean is phone = country_code+"-"+std_code+"-"+phone_code > Any Helps > --Have you tried my suggestion to use ruby-debug to break into the controller just before the validation and check the value of std_code? Colin
ok...in this case you can do validation in this way.. validate :std_code def std_code errors.add( :std_code ) if self.std_code and self.std_code.blank? end -Sandip R~ On Thu, Jun 4, 2009 at 8:46 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > 2009/6/4 Newb Newb <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>: > > > > Thank you for taking time to reply... > > > > That is i have phone field into my table. > > I get country code and std code and phone code from the form > > after getting i append like below > > > > 1-011-5558 > > > > then i save into my phone field. > > > > so i in my modal i have like below > > > > attr_accessor :country_code,:std_code,phone_code > > > > > > for this purpose i have to validate those three atrr_accessor fields.. > > > > i mean is phone = country_code+"-"+std_code+"-"+phone_code > > Any Helps > > -- > > Have you tried my suggestion to use ruby-debug to break into the controller > just > before the validation and check the value of std_code? > > Colin > > > >-- Ruby on Rails Developer http://sandip.sosblog.com http://funonrails.wordpress.com www.joshsoftware.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 -~----------~----~----~----~------~----~------~--~---