Forum: Ruby on Rails object.save is not creating an insert statement

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
John Stackhouse (Guest)
on 2006-03-09 00:23
I have a model for a task class.  When I try to save a task, for some
reason no INSERT statement is being generated.  Here's the pertinent
part of the


development.log:
------------------------------------
Processing TasksController#create_fromProject (for 70.247.24.238 at
2006-03-08 14:20:30) [POST]
  Parameters: {"commit"=>"Create", "action"=>"create_fromProject",
"task"=>{...blahblahblah...}, "id"=>"3", "controller"=>"tasks"}
  Task Columns (0.000345)   SHOW FIELDS FROM tasks
  SQL (0.000133)   BEGIN
  SQL (0.000124)   COMMIT
Redirected to .........


And the code in the task controller:
------------------------------------
def create_fromProject
    @task = Task.new(params[:task])
    if @task.save
      flash[:notice] = 'Task was successfully created.'
      redirect_to :action => 'list'
    else
      render :action => 'new'
    end
  end


So what's the deal?

Thanks!
Norman T. (Guest)
on 2006-03-09 11:35
(Received via mailing list)
Am Mittwoch, den 08.03.2006, 23:23 +0100 schrieb John Stackhouse:
> "task"=>{...blahblahblah...}, "id"=>"3", "controller"=>"tasks"}
>     if @task.save
>       flash[:notice] = 'Task was successfully created.'
>       redirect_to :action => 'list'
>     else
>       render :action => 'new'
>     end
>   end
>
>
> So what's the deal?

Seems to look ok for me. Perhaps the problem is in your model code.

--
Norman T.

http://blog.inlet-media.de
Kamal F. (Guest)
on 2006-03-09 11:38
(Received via mailing list)
The data you are passing to the task object might be failing some of the
validation you set up in the model.
Norman T. (Guest)
on 2006-03-09 11:47
(Received via mailing list)
Am Donnerstag, den 09.03.2006, 09:37 +0000 schrieb Kamal F.:
> >  Task Columns (0.000345)   SHOW FIELDS FROM tasks
> >      flash[:notice] = 'Task was successfully created.'
> >      redirect_to :action => 'list'
> >    else
> >      render :action => 'new'
> >    end
> >  end
> >

But if, there should not be a redirection.

--
Norman T.

http://blog.inlet-media.de
Mark Reginald J. (Guest)
on 2006-03-09 12:39
(Received via mailing list)
Norman T. wrote:

> But if, there should not be a redirection.

Yes. Perhaps a before_save method is returning false.



--
We develop, watch us RoR, in numbers too big to ignore.
This topic is locked and can not be replied to.