Re: Update attributes

namwob
Fri, 16 Feb 2007 22:16:24 -0000

Can someone explain why "validates_presence_of" screws up a call to
update a model object?

On Feb 16, 2:11 pm, "namwob"
<ebow...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> The issue that I can''t grasp is why this call was made in my log
file
> for a simple update call
>
> SELECT * FROM users WHERE
> (users.name = ''joseph'' AND users.id <> 11)
>
> On Feb 16, 2:06 pm, "Mike Garey"
<random...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > what exact line is causing rails to throw that error?
>
> > On 2/16/07, namwob
<ebow...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > The id does get passed.  Note from my dev.log file the parameters
> > > getting passed:
>
> > > Parameters:
{"user"=>{"name"=>"joseph",
> > >
"hashed_password"=>"3708cf23bf5bcd14a2383a4fb24c4af1fb4fb352",
> > > "user_type"=>"nelnet",
"user_role"=>"user"}, "commit"=>"
Update User
> > > ", "action"=>"update_user",
"id"=>"11", "controller"=>"admin"}
>
> > > id is listed, so it makes it to the controller.
>
> > > On Feb 16, 2:01 pm, "Mike Garey"
<random...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > > > On 2/16/07, namwob
<ebow...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > > > I am a bit confused as to why I am getting an error
updating an
> > > > > object.
>
> > > > > This is the ERROR:  Couldn''t find User without
an ID
>
> > > > before you start getting to the strange SQL call, try and
find out why
> > > > an ID isn''t being passed.  At what line do you
receive this error? At
> > > > the User.find(params[:id]) ? If so, find out why
you''re not getting a
> > > > value for an id here, then try to figure out the next part.
>
> > > > Mike