John Stackhouse
2006-Mar-08 22:23 UTC
[Rails] object.save is not creating an insert statement
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! -- Posted via http://www.ruby-forum.com/.
maybe you have validations in your model that are failing. That''s the first thing that comes to mind. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Norman Timmler
2006-Mar-09 09:33 UTC
[Rails] object.save is not creating an insert statement
Am Mittwoch, den 08.03.2006, 23:23 +0100 schrieb John Stackhouse:> 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?Seems to look ok for me. Perhaps the problem is in your model code. -- Norman Timmler http://blog.inlet-media.de
The data you are passing to the task object might be failing some of the validation you set up in the model. On Wednesday, March 08, 2006, at 11:23 PM, John Stackhouse wrote:>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! > >-- >Posted via http://www.ruby-forum.com/. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails-- Posted with http://DevLists.com. Sign up and save your time!
Norman Timmler
2006-Mar-09 09:45 UTC
[Rails] object.save is not creating an insert statement
Am Donnerstag, den 09.03.2006, 09:37 +0000 schrieb Kamal Fariz:> The data you are passing to the task object might be failing some of the > validation you set up in the model. > > On Wednesday, March 08, 2006, at 11:23 PM, John Stackhouse wrote: > >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 > >But if, there should not be a redirection. -- Norman Timmler http://blog.inlet-media.de