Hi all i am learning Rails3.2.7 but by ActiveRecords Validations are not working. These are my User.rb class User < ActiveRecord::Base attr_accessible :password, :fullname,:user_name ,:email,:company_name#,:terms_of_service,:password_confirmation validates :terms_of_service, :acceptance => { :accept => ''yes'' } validates :password ,:confirmation => true validates :password_confirmation, :presence => true validates :fullname ,:presence => true validates :user_name ,:presence => true validates :email ,:presence => true validates :company_name ,:presence => true end but when i click Submit button with out entering the data my validations are not working i''m not getting errors messages which is default in rails.Can any one tell where did i go wrong Thanks in advance -- 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 To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/IC3GCiYi5GgJ. For more options, visit https://groups.google.com/groups/opt_out.
Is the record being saved? If not, then most likely you just do not have infrastructure in place to display the errors. 2012/9/12 honey ruby <emailtohoneyruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> Hi all i am learning Rails3.2.7 but by ActiveRecords Validations are not > working. > > These are my User.rb > > class User < ActiveRecord::Base > attr_accessible :password, :fullname,:user_name > ,:email,:company_name#,:terms_of_service,:password_confirmation > > validates :terms_of_service, :acceptance => { :accept => ''yes'' } > validates :password ,:confirmation => true > validates :password_confirmation, :presence => true > validates :fullname ,:presence => true > validates :user_name ,:presence => true > validates :email ,:presence => true > validates :company_name ,:presence => true > > > > end > > but when i click Submit button with out entering the data my validations > are not working i''m not getting errors messages which is default in > rails.Can any one tell where did i go wrong > > > Thanks in advance > > -- > 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 > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/IC3GCiYi5GgJ. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- 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 https://groups.google.com/groups/opt_out.
@Gintautas Šimkus when i enter data my data is saving. What do u mean by infrastructure in place to display the errors. On Wed, Sep 12, 2012 at 5:18 PM, Gintautas Šimkus <dihitales-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> Is the record being saved? If not, then most likely you just do not have > infrastructure in place to display the errors. > > > 2012/9/12 honey ruby <emailtohoneyruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > >> Hi all i am learning Rails3.2.7 but by ActiveRecords Validations are not >> working. >> >> These are my User.rb >> >> class User < ActiveRecord::Base >> attr_accessible :password, :fullname,:user_name >> ,:email,:company_name#,:terms_of_service,:password_confirmation >> >> validates :terms_of_service, :acceptance => { :accept => ''yes'' } >> validates :password ,:confirmation => true >> validates :password_confirmation, :presence => true >> validates :fullname ,:presence => true >> validates :user_name ,:presence => true >> validates :email ,:presence => true >> validates :company_name ,:presence => true >> >> >> >> end >> >> but when i click Submit button with out entering the data my validations >> are not working i''m not getting errors messages which is default in >> rails.Can any one tell where did i go wrong >> >> >> Thanks in advance >> >> -- >> 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 >> To view this discussion on the web visit >> https://groups.google.com/d/msg/rubyonrails-talk/-/IC3GCiYi5GgJ. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > -- > 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 https://groups.google.com/groups/opt_out. > > >-- 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 https://groups.google.com/groups/opt_out.
OK, what I meant is that maybe you were expecting error to get displayed without actually putting the code (most likely in a layout template), i.e. (the example is in HAML) = render partial ''layouts/errors'' and layouts/_errors could look something like %div#errors= flash[:error] But if it is (incorrectly) saving, then the above is not the case. 2012/9/12 hanish jadala <emailtohoneyruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> @Gintautas Šimkus when i enter data my data is saving. What do u mean by > infrastructure in place to display the errors. > > > On Wed, Sep 12, 2012 at 5:18 PM, Gintautas Šimkus <dihitales@gmail.com>wrote: > >> Is the record being saved? If not, then most likely you just do not have >> infrastructure in place to display the errors. >> >> >> 2012/9/12 honey ruby <emailtohoneyruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> >>> Hi all i am learning Rails3.2.7 but by ActiveRecords Validations are not >>> working. >>> >>> These are my User.rb >>> >>> class User < ActiveRecord::Base >>> attr_accessible :password, :fullname,:user_name >>> ,:email,:company_name#,:terms_of_service,:password_confirmation >>> >>> validates :terms_of_service, :acceptance => { :accept => ''yes'' } >>> validates :password ,:confirmation => true >>> validates :password_confirmation, :presence => true >>> validates :fullname ,:presence => true >>> validates :user_name ,:presence => true >>> validates :email ,:presence => true >>> validates :company_name ,:presence => true >>> >>> >>> >>> end >>> >>> but when i click Submit button with out entering the data my validations >>> are not working i''m not getting errors messages which is default in >>> rails.Can any one tell where did i go wrong >>> >>> >>> Thanks in advance >>> >>> -- >>> 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 >>> To view this discussion on the web visit >>> https://groups.google.com/d/msg/rubyonrails-talk/-/IC3GCiYi5GgJ. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> -- >> 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 https://groups.google.com/groups/opt_out. >> >> >> > > -- > 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 https://groups.google.com/groups/opt_out. > > >-- 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 https://groups.google.com/groups/opt_out.
On 12 September 2012 12:44, honey ruby <emailtohoneyruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all i am learning Rails3.2.7 but by ActiveRecords Validations are not > working. > > These are my User.rb > > class User < ActiveRecord::Base > attr_accessible :password, :fullname,:user_name > ,:email,:company_name#,:terms_of_service,:password_confirmationThat # in the middle looks a bit odd. Did you mean it to be there?> > validates :terms_of_service, :acceptance => { :accept => ''yes'' } > validates :password ,:confirmation => true > validates :password_confirmation, :presence => true > validates :fullname ,:presence => true > validates :user_name ,:presence => true > validates :email ,:presence => true > validates :company_name ,:presence => true > > > > end > > but when i click Submit button with out entering the data my validations are > not working i''m not getting errors messages which is default in rails.Can > any one tell where did i go wrongIf the code you have posted for the model is not copied/pasted then please do that (so we can check for typos), also post the code for the controller action run when you click submit (just that action will do), and also post the section of development.log for when you clck submit (look at the log before you click submit to see where to start the copy/paste from). Maybe better to have a look at the Rails Guide on debugging first though to find out how to debug the code, then see if you can work it out for yourself. Colin> > > Thanks in advance > > -- > 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 > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/IC3GCiYi5GgJ. > For more options, visit https://groups.google.com/groups/opt_out. > >-- 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 https://groups.google.com/groups/opt_out.
Hello, On Wednesday, September 12, 2012 5:14:07 PM UTC+5:30, honey ruby wrote:> > Hi all i am learning Rails3.2.7 but by ActiveRecords Validations are not > working. > > These are my User.rb > > class User < ActiveRecord::Base > attr_accessible :password, :fullname,:user_name > ,:email,:company_name#,:terms_of_service,:password_confirmation >For this : - First remove the # after :company_name. For :password_confirmation, you should also add :- attr_accessor :password_confirmation. (because it is not going to be saved in db.) Hope this helps.> validates :terms_of_service, :acceptance => { :accept => ''yes'' } > validates :password ,:confirmation => true > validates :password_confirmation, :presence => true > validates :fullname ,:presence => true > validates :user_name ,:presence => true > validates :email ,:presence => true > validates :company_name ,:presence => true > > > > end > > but when i click Submit button with out entering the data my validations > are not working i''m not getting errors messages which is default in > rails.Can any one tell where did i go wrong > > > Thanks in advance > >-- 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 To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/d-QJym4qYc8J. For more options, visit https://groups.google.com/groups/opt_out.
On Wednesday, September 12, 2012 5:14:07 PM UTC+5:30, honey ruby wrote:> > Hi all i am learning Rails3.2.7 but by ActiveRecords Validations are not > working. > > These are my User.rb > > class User < ActiveRecord::Base > attr_accessible :password, :fullname,:user_name > ,:email,:company_name#,:terms_of_service,:password_confirmation >*For this : - First remove the # after :company_name. For :password_confirmation, you should also add :- attr_accessor :password_confirmation. (because it is not going to be saved in db.) Hope this helps *.> > validates :terms_of_service, :acceptance => { :accept => ''yes'' } > validates :password ,:confirmation => true > validates :password_confirmation, :presence => true > validates :fullname ,:presence => true > validates :user_name ,:presence => true > validates :email ,:presence => true > validates :company_name ,:presence => true > > > > end > > but when i click Submit button with out entering the data my validations > are not working i''m not getting errors messages which is default in > rails.Can any one tell where did i go wrong > > > Thanks in advance > >-- 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 To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/XVQpK2np-SgJ. For more options, visit https://groups.google.com/groups/opt_out.