Re: using ActiveRecord::Validations::ClassMethods

2009-05-22 Thread David Susco
Thanks guys, That helped get rid of a lot of code. Dave On Thu, May 21, 2009 at 10:22 AM, Magnus Holm judo...@gmail.com wrote: params is simply Rails' version of @input. If you name your keys user[id] and user[name] in the HTML, then @input.user should contain a Hash like { 'id' = ...,

Re: using ActiveRecord::Validations::ClassMethods

2009-05-22 Thread Eric Mill
Awesome! The only thing more fun than writing code is deleting code. On Fri, May 22, 2009 at 9:09 AM, David Susco dsu...@gmail.com wrote: Thanks guys, That helped get rid of a lot of code. Dave On Thu, May 21, 2009 at 10:22 AM, Magnus Holm judo...@gmail.com wrote: params is simply Rails'

Re: using ActiveRecord::Validations::ClassMethods

2009-05-21 Thread David Susco
Thanks, I've gotten it to work. On this part though: @user = User.new params[:user Is the closing bracket missing? Is params something from Rails that allows you to create the user instance variable all in one line instead of doing something like this: @user = User.new( :id = input.id,

Re: using ActiveRecord::Validations::ClassMethods

2009-05-21 Thread Eric Mill
Hah, yeah, the bracket is missing. And in Camping, the equivalent of Rails' params is @input. -- Eric On Thu, May 21, 2009 at 9:50 AM, David Susco dsu...@gmail.com wrote: Thanks, I've gotten it to work. On this part though: @user = User.new params[:user Is the closing bracket missing? Is

Re: using ActiveRecord::Validations::ClassMethods

2009-05-21 Thread Magnus Holm
params is simply Rails' version of @input. If you name your keys user[id] and user[name] in the HTML, then @input.user should contain a Hash like { 'id' = ..., 'name' = ... } (maybe the keys are Symbols; I don't remember at the moment) //Magnus Holm On Thu, May 21, 2009 at 15:50, David Susco

Re: using ActiveRecord::Validations::ClassMethods

2009-05-20 Thread Magnus Holm
I'm a little rusty on AR at the moment, but I think it looks something like this: In the controller: if @user.valid? # everything is fine else # ops! @user.errors contains the errors end //Magnus Holm On Wed, May 20, 2009 at 19:43, David Susco dsu...@gmail.com wrote: Can

Re: using ActiveRecord::Validations::ClassMethods

2009-05-20 Thread Eric Mill
Yeah, but in practice, you'd call @user.save, which internally calls #valid?, and returns true or false on whether the object was saved or not. If the object wasn't saved, @user.errors is populated with the error messages. -- Eric On Wed, May 20, 2009 at 4:03 PM, Magnus Holm judo...@gmail.com

Re: using ActiveRecord::Validations::ClassMethods

2009-05-20 Thread David Susco
So, in my crud controllers, should I be using calls to save instead of create and update_attributes? As those just return the object, and not true of false based on my validations. Dave On Wed, May 20, 2009 at 4:30 PM, Eric Mill kproject...@gmail.com wrote: Yeah, but in practice, you'd call

Re: using ActiveRecord::Validations::ClassMethods

2009-05-20 Thread Eric Mill
In my create actions, I customarily do like @user = User.new params[:user if @user.save ... else ... end But update_attributes should also return true or false, I believe. On Wed, May 20, 2009 at 4:42 PM, David Susco dsu...@gmail.com wrote: So, in my crud controllers, should I be using