i love how rails adds code around the fields when they have errors, but what if i want to add a css class to another element in the form when there is an error, say the form label or something like that. i looked around at the api for validations and it looked like you can check individual methods for errors. i would imagine you can do that for the fields you have validations for and write some sort of conditional that would put a class or any other html you want in there, but i''m not quite sure how to implement that. does anyone have any examples? is there a better way of doing something like that? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 11/14/06, Josh Kieschnick <jjkiesch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > i love how rails adds code around the fields when they have errors, > but what if i want to add a css class to another element in the form > when there is an error, say the form label or something like that. > > i looked around at the api for validations and it looked like you can > check individual methods for errors. i would imagine you can do that > for the fields you have validations for and write some sort of > conditional that would put a class or any other html you want in > there, but i''m not quite sure how to implement that. does anyone have > any examples? is there a better way of doing something like that? > > > >Assuming a simple form creating a user AR model: <% if @user.errors[:username] -%> ... <% end -%> Hope this helps. -- Zack Chandler http://depixelate.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 -~----------~----~----~----~------~----~------~--~---
--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi! How can i find the total no. of records in the table in a controller. Regards, Swanand --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
From the documentation at http://api.rubyonrails.org/ : Person.find(:all) # returns an array of objects for all the rows fetched by SELECT * FROM people You can now use the size method to get the number of records in that table On 12/5/06, swanand deodhar <swanand.blms-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi! > How can i find the total no. of records in the table in a controller. > Regards, > Swanand > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
swanand deodhar wrote:> Hi! > How can i find the total no. of records in the table in a controller. > Regards, > SwanandThere is a count method on the model class. A. -- 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 -~----------~----~----~----~------~----~------~--~---
Person.count # returns the total count of all people for conditional counts you can see docs ~cheers On 12/5/06, swanand deodhar <swanand.blms-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi! > How can i find the total no. of records in the table in a controller. > Regards, > Swanand > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thnx for help. Tht worked On 12/5/06, gaurav bagga <gaurav.v.bagga-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Person.count # returns the total count of all people > > for conditional counts you can see docs > > ~cheers > > On 12/5/06, swanand deodhar <swanand.blms-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > wrote: > > > > Hi! > > How can i find the total no. of records in the table in a controller. > > Regards, > > Swanand > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Bala Paranj wrote:> From the documentation at http://api.rubyonrails.org/ : > Person.find(:all) > # returns an array of objects for all the rows fetched by SELECT * FROM > people > You can now use the size method to get the number of records in that tableAt the cost of copying all that data into Ruby objects. Try Person.count or Person.count_by_sql. -- Phlip http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---