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  wrote:
> Thanks guys,
>
> That helped get rid of a lot of code.
>
> Dave
>
> On Thu, May 21, 2009 at 10:22 AM, Magnus Holm  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' => ..., '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  wrote:
>>>
>>> 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,
>>>  :name => input.name,
>>>  ...
>>> )
>>>
>>> Can I use it in a camping app relatively easily?
>>>
>>> Dave
>>>
>>> On Wed, May 20, 2009 at 5:27 PM, Eric Mill  wrote:
>>> > 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  wrote:
>>> >> 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 
>>> >> wrote:
>>> >>> 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 
>>> >>> wrote:
>>>  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  wrote:
>>> >
>>> > Can ActiveRecord::Validations::ClassMethods be used to provide
>>> > feedback to the user? I noticed the tepee example uses
>>> > "validates_uniqueness_of ". If the title isn't unique however
>>> > nothing
>>> > is written and the user is never notified.
>>> >
>>> > Does anyone have an example or two of how I could go about informing
>>> > the user that the title they entered was not unique and they need to
>>> > enter another?
>>> >
>>> > --
>>> > Dave
>>> > ___
>>> > Camping-list mailing list
>>> > Camping-list@rubyforge.org
>>> > http://rubyforge.org/mailman/listinfo/camping-list
>>> 
>>> 
>>>  ___
>>>  Camping-list mailing list
>>>  Camping-list@rubyforge.org
>>>  http://rubyforge.org/mailman/listinfo/camping-list
>>> 
>>> >>> ___
>>> >>> Camping-list mailing list
>>> >>> Camping-list@rubyforge.org
>>> >>> http://rubyforge.org/mailman/listinfo/camping-list
>>> >>>
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >> Dave
>>> >> ___
>>> >> Camping-list mailing list
>>> >> Camping-list@rubyforge.org
>>> >> http://rubyforge.org/mailman/listinfo/camping-list
>>> >>
>>> > ___
>>> > Camping-list mailing list
>>> > Camping-list@rubyforge.org
>>> > http://rubyforge.org/mailman/listinfo/camping-list
>>> >
>>>
>>>
>>>
>>> --
>>> Dave
>>> ___
>>> Camping-list mailing list
>>> Camping-list@rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/camping-list
>>
>>
>> ___
>> Camping-list mailing list
>> Camping-list@rubyforge.org
>> http://rubyforge.org/mailman/listinfo/camping-list
>>
>
>
>
> --
> Dave
> ___
> Camping-list mailing list
> Camping-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>
___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list


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  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' => ..., '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  wrote:
>>
>> 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,
>>  :name => input.name,
>>  ...
>> )
>>
>> Can I use it in a camping app relatively easily?
>>
>> Dave
>>
>> On Wed, May 20, 2009 at 5:27 PM, Eric Mill  wrote:
>> > 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  wrote:
>> >> 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 
>> >> wrote:
>> >>> 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 
>> >>> wrote:
>>  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  wrote:
>> >
>> > Can ActiveRecord::Validations::ClassMethods be used to provide
>> > feedback to the user? I noticed the tepee example uses
>> > "validates_uniqueness_of ". If the title isn't unique however
>> > nothing
>> > is written and the user is never notified.
>> >
>> > Does anyone have an example or two of how I could go about informing
>> > the user that the title they entered was not unique and they need to
>> > enter another?
>> >
>> > --
>> > Dave
>> > ___
>> > Camping-list mailing list
>> > Camping-list@rubyforge.org
>> > http://rubyforge.org/mailman/listinfo/camping-list
>> 
>> 
>>  ___
>>  Camping-list mailing list
>>  Camping-list@rubyforge.org
>>  http://rubyforge.org/mailman/listinfo/camping-list
>> 
>> >>> ___
>> >>> Camping-list mailing list
>> >>> Camping-list@rubyforge.org
>> >>> http://rubyforge.org/mailman/listinfo/camping-list
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >> Dave
>> >> ___
>> >> Camping-list mailing list
>> >> Camping-list@rubyforge.org
>> >> http://rubyforge.org/mailman/listinfo/camping-list
>> >>
>> > ___
>> > Camping-list mailing list
>> > Camping-list@rubyforge.org
>> > http://rubyforge.org/mailman/listinfo/camping-list
>> >
>>
>>
>>
>> --
>> Dave
>> ___
>> Camping-list mailing list
>> Camping-list@rubyforge.org
>> http://rubyforge.org/mailman/listinfo/camping-list
>
>
> ___
> Camping-list mailing list
> Camping-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>



-- 
Dave
___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list


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  wrote:

> 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,
>  :name => input.name,
>  ...
> )
>
> Can I use it in a camping app relatively easily?
>
> Dave
>
> On Wed, May 20, 2009 at 5:27 PM, Eric Mill  wrote:
> > 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  wrote:
> >> 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 
> wrote:
> >>> 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 
> wrote:
>  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  wrote:
> >
> > Can ActiveRecord::Validations::ClassMethods be used to provide
> > feedback to the user? I noticed the tepee example uses
> > "validates_uniqueness_of ". If the title isn't unique however nothing
> > is written and the user is never notified.
> >
> > Does anyone have an example or two of how I could go about informing
> > the user that the title they entered was not unique and they need to
> > enter another?
> >
> > --
> > Dave
> > ___
> > Camping-list mailing list
> > Camping-list@rubyforge.org
> > http://rubyforge.org/mailman/listinfo/camping-list
> 
> 
>  ___
>  Camping-list mailing list
>  Camping-list@rubyforge.org
>  http://rubyforge.org/mailman/listinfo/camping-list
> 
> >>> ___
> >>> Camping-list mailing list
> >>> Camping-list@rubyforge.org
> >>> http://rubyforge.org/mailman/listinfo/camping-list
> >>>
> >>
> >>
> >>
> >> --
> >> Dave
> >> ___
> >> Camping-list mailing list
> >> Camping-list@rubyforge.org
> >> http://rubyforge.org/mailman/listinfo/camping-list
> >>
> > ___
> > Camping-list mailing list
> > Camping-list@rubyforge.org
> > http://rubyforge.org/mailman/listinfo/camping-list
> >
>
>
>
> --
> Dave
> ___
> Camping-list mailing list
> Camping-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>
___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list

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  wrote:
> 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,
>  :name => input.name,
>  ...
> )
>
> Can I use it in a camping app relatively easily?
>
> Dave
>
> On Wed, May 20, 2009 at 5:27 PM, Eric Mill  wrote:
>> 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  wrote:
>>> 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  wrote:
 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  wrote:
> 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  wrote:
>>
>> Can ActiveRecord::Validations::ClassMethods be used to provide
>> feedback to the user? I noticed the tepee example uses
>> "validates_uniqueness_of ". If the title isn't unique however nothing
>> is written and the user is never notified.
>>
>> Does anyone have an example or two of how I could go about informing
>> the user that the title they entered was not unique and they need to
>> enter another?
>>
>> --
>> Dave
>> ___
>> Camping-list mailing list
>> Camping-list@rubyforge.org
>> http://rubyforge.org/mailman/listinfo/camping-list
>
>
> ___
> Camping-list mailing list
> Camping-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>
 ___
 Camping-list mailing list
 Camping-list@rubyforge.org
 http://rubyforge.org/mailman/listinfo/camping-list

>>>
>>>
>>>
>>> --
>>> Dave
>>> ___
>>> Camping-list mailing list
>>> Camping-list@rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/camping-list
>>>
>> ___
>> Camping-list mailing list
>> Camping-list@rubyforge.org
>> http://rubyforge.org/mailman/listinfo/camping-list
>>
>
>
>
> --
> Dave
> ___
> Camping-list mailing list
> Camping-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>
___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list


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,
  :name => input.name,
  ...
)

Can I use it in a camping app relatively easily?

Dave

On Wed, May 20, 2009 at 5:27 PM, Eric Mill  wrote:
> 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  wrote:
>> 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  wrote:
>>> 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  wrote:
 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  wrote:
>
> Can ActiveRecord::Validations::ClassMethods be used to provide
> feedback to the user? I noticed the tepee example uses
> "validates_uniqueness_of ". If the title isn't unique however nothing
> is written and the user is never notified.
>
> Does anyone have an example or two of how I could go about informing
> the user that the title they entered was not unique and they need to
> enter another?
>
> --
> Dave
> ___
> Camping-list mailing list
> Camping-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list


 ___
 Camping-list mailing list
 Camping-list@rubyforge.org
 http://rubyforge.org/mailman/listinfo/camping-list

>>> ___
>>> Camping-list mailing list
>>> Camping-list@rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/camping-list
>>>
>>
>>
>>
>> --
>> Dave
>> ___
>> Camping-list mailing list
>> Camping-list@rubyforge.org
>> http://rubyforge.org/mailman/listinfo/camping-list
>>
> ___
> Camping-list mailing list
> Camping-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>



-- 
Dave
___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list


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  wrote:
> 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  wrote:
>> 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  wrote:
>>> 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  wrote:

 Can ActiveRecord::Validations::ClassMethods be used to provide
 feedback to the user? I noticed the tepee example uses
 "validates_uniqueness_of ". If the title isn't unique however nothing
 is written and the user is never notified.

 Does anyone have an example or two of how I could go about informing
 the user that the title they entered was not unique and they need to
 enter another?

 --
 Dave
 ___
 Camping-list mailing list
 Camping-list@rubyforge.org
 http://rubyforge.org/mailman/listinfo/camping-list
>>>
>>>
>>> ___
>>> Camping-list mailing list
>>> Camping-list@rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/camping-list
>>>
>> ___
>> Camping-list mailing list
>> Camping-list@rubyforge.org
>> http://rubyforge.org/mailman/listinfo/camping-list
>>
>
>
>
> --
> Dave
> ___
> Camping-list mailing list
> Camping-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>
___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list


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  wrote:
> 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  wrote:
>> 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  wrote:
>>>
>>> Can ActiveRecord::Validations::ClassMethods be used to provide
>>> feedback to the user? I noticed the tepee example uses
>>> "validates_uniqueness_of ". If the title isn't unique however nothing
>>> is written and the user is never notified.
>>>
>>> Does anyone have an example or two of how I could go about informing
>>> the user that the title they entered was not unique and they need to
>>> enter another?
>>>
>>> --
>>> Dave
>>> ___
>>> Camping-list mailing list
>>> Camping-list@rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/camping-list
>>
>>
>> ___
>> Camping-list mailing list
>> Camping-list@rubyforge.org
>> http://rubyforge.org/mailman/listinfo/camping-list
>>
> ___
> Camping-list mailing list
> Camping-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>



-- 
Dave
___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list


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  wrote:
> 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  wrote:
>>
>> Can ActiveRecord::Validations::ClassMethods be used to provide
>> feedback to the user? I noticed the tepee example uses
>> "validates_uniqueness_of ". If the title isn't unique however nothing
>> is written and the user is never notified.
>>
>> Does anyone have an example or two of how I could go about informing
>> the user that the title they entered was not unique and they need to
>> enter another?
>>
>> --
>> Dave
>> ___
>> Camping-list mailing list
>> Camping-list@rubyforge.org
>> http://rubyforge.org/mailman/listinfo/camping-list
>
>
> ___
> Camping-list mailing list
> Camping-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>
___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list


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  wrote:

> Can ActiveRecord::Validations::ClassMethods be used to provide
> feedback to the user? I noticed the tepee example uses
> "validates_uniqueness_of ". If the title isn't unique however nothing
> is written and the user is never notified.
>
> Does anyone have an example or two of how I could go about informing
> the user that the title they entered was not unique and they need to
> enter another?
>
> --
> Dave
> ___
> Camping-list mailing list
> Camping-list@rubyforge.org
> http://rubyforge.org/mailman/listinfo/camping-list
>
___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list

using ActiveRecord::Validations::ClassMethods

2009-05-20 Thread David Susco
Can ActiveRecord::Validations::ClassMethods be used to provide
feedback to the user? I noticed the tepee example uses
"validates_uniqueness_of ". If the title isn't unique however nothing
is written and the user is never notified.

Does anyone have an example or two of how I could go about informing
the user that the title they entered was not unique and they need to
enter another?

-- 
Dave
___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list