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.
E81ae027925dca383763c78369780a75?d=identicon&s=25 John Stackhouse (Guest)
on 2006-03-08 23: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!
Bf66e10c8fc4abefebde0425e7f6f15a?d=identicon&s=25 Norman Timmler (Guest)
on 2006-03-09 10: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 Timmler

http://blog.inlet-media.de
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 Kamal Fariz (Guest)
on 2006-03-09 10: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.
Bf66e10c8fc4abefebde0425e7f6f15a?d=identicon&s=25 Norman Timmler (Guest)
on 2006-03-09 10:47
(Received via mailing list)
Am Donnerstag, den 09.03.2006, 09:37 +0000 schrieb Kamal Fariz:
> >  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 Timmler

http://blog.inlet-media.de
C64e63b70be7dfed8b0742540b8b27e5?d=identicon&s=25 Mark Reginald James (Guest)
on 2006-03-09 11:39
(Received via mailing list)
Norman Timmler 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.