From: Ron Jeffries Date: 2005-09-15T11:31:42+09:00 Subject: Re: params v.s. @params in rails? On Mon, 5 Sep 2005 01:26:44 +0900, David Heinemeier Hansson wrote: >> The recommendation for using the params method, instead of accessing >> the @params instance variable directly, is that it�s more uniform to >> use the accessor method, since you can also do that from the view. > >Direct access to these instance variables is deprecated. The same goes >for cookies, session, request, response, and the other accessors. Use >the accessor instead of going directly, so it's request.get? instead >of @request.get?. David, Chet Hendrickson and I are just getting back to Ruby after too long away, and we've just started working through the Rails book. Mostly happy so far, though we're just a couple of days in. One thing that confused me was the validate method in the first example. I'm sure I'm missing something really obvious, but I'd rather be embarrassed than confused. ;-> The validate is: def validate errors.add(:price, "should be positive") unless price.nil? || price >= 0 end I don't see how "price" canrefer to the field in the record, unless price isperhaps an accessor kind of method. But in the class definition, I don't see any declaration of a price method. If it's not too much trouble, since we seem to be close to the topic ... what's up with that? How does that access to price work? Thanks, -- Ron Jeffries www.XProgramming.com I'm giving the best advice I have. You get to decide if it's true for you.