On 24 February 2011 10:14, Bhasker Harihara <[email protected]> wrote: > > > On Wed, Feb 23, 2011 at 10:14 PM, Colin Law <[email protected]> wrote: >> >> On 23 February 2011 16:03, Bhasker Harihara <[email protected]> >> wrote: >> >> Please don't top post, it makes it difficult to follow the thread. >> Insert your reply at appropriate points in previous post. Thanks >> >> > This is what I have and it gives the error. >> > >> > validates :uname, :presence => true, >> > :length => { :maximum => 50 } >> > >> > puts "The name is set to #{user.uname}" >> > >> > But without the puts it updates the record into the databse. I think >> > it is >> > to do with scoping. If have this puts after make salt then I have no >> > problem >> > I cannot access my server currently, but I have sent the error message in > the first mail.
No you did not put the *complete* error message in the first post, the message would have gone on to say which method was undefined and would have told you where the problem had occurred. > Yes, the puts is immediately after the validates. It is in the user.rb file > and user is my model. The validates line does not itself do the validation, it is a macro that registers a callback to do the validation at the appropriate point. The validates line itself is executed when the file is loaded, not when the validation is done. Similarly your puts will not be executed after the validation, but when the file is loaded (after the validates macro is run). If the purpose of the puts is to help to debug your application have a look at the Rails Guide on debugging. It explains, amongst other techniques, how to use ruby-debug to break into your code and inspect data and program flow. Colin -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

