On Thu, Feb 24, 2011 at 5:28 PM, Jim Ruther Nill <[email protected]> wrote:
> > > On Thu, Feb 24, 2011 at 12:03 AM, Bhasker Harihara < > [email protected]> wrote: > >> 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}" >> >> > I don't know why you're getting the error but why do you want to do this? > even if it doesn't throw an error, > the line with puts won't run after validates because the save process > doesn't work that way. > > if you really want to use that line, use it inside an after_validation > callback so it will be run after validation. > > after_validation :puts_user_name > > def puts_user_name > puts "The name is set to #{user.uname}" > end > > I want to update some fields of the user based on some criteria that the user inputs. puts "the name of the user is #{user.name}" the entire line appears in the server log window (rails server) window, expcet for the value of variable. I will check the after_validation and see if I can use it -- thanks for the idea. Can you also expalin how validates get the values from the form_for Regards, > >> 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 >> >> >> >> On Wed, Feb 23, 2011 at 9:13 PM, Colin Law <[email protected]>wrote: >> >>> On 23 February 2011 15:03, Bhasker Harihara <[email protected]> >>> wrote: >>> > Hi, >>> > >>> > My form_for is loading properly and also storing in the db. >>> > >>> > My show user is also fine. >>> > >>> > I just want to do a puts "user name is #{user.name}" this gives me >>> > >>> > NoMethodError in UsersController#new >>> > >>> > When I use self.name it give the same error >>> > >>> > but when I do the same at the console, it works fine. What is that I >>> am >>> > missing. >>> >>> Show us the code that is failing and the full error message and tell >>> us which line it is failing on. Then we might be able to help. >>> >>> 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. >>> >>> >> -- >> 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. >> > > > > -- > ------------------------------------------------------------- > visit my blog at http://jimlabs.heroku.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 [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. > -- 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.

