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 <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 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 <kproject...@gmail.com> 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 <dsu...@gmail.com> 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 <kproject...@gmail.com>
> 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 <judo...@gmail.com>
> 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 <dsu...@gmail.com> 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

Reply via email to