# I don't get why my model isn't saving - assistance requested

**URL:** <https://www.ruby-forum.com/t/i-dont-get-why-my-model-isnt-saving-assistance-requested/151480>\
**Category:** Rails\
**Created:** [October 22, 2008, 1:36am UTC](https://www.ruby-forum.com/t/i-dont-get-why-my-model-isnt-saving-assistance-requested/151480 "2008-10-22T01:36:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wemagor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/8edcca/32.png) [@wemagor](https://www.ruby-forum.com/u/wemagor)\
**Post date:** [October 22, 2008, 1:36am UTC](https://www.ruby-forum.com/t/i-dont-get-why-my-model-isnt-saving-assistance-requested/151480/1 "2008-10-22T01:36:30Z")

</div>

I’m trying to do something relatively basic. I’m using the restful  
authentication plugin, so I have Users, and I also have Tasks which  
belong to a user:

class User \< ActiveRecord::Base  
has\_many :assigned\_tasks, :class\_name =\> “Task”, :foreign\_key =\>  
“assigned\_to”  
has\_many :created\_tasks, :class\_name =\> “Task”, :foreign\_key =\>  
“created\_by”  
end

class Task \< ActiveRecord::Base  
belongs\_to :creator, :class\_name =\> “User”, :foreign\_key =\>  
“created\_by”  
belongs\_to :user, :class\_name =\> “User”, :foreign\_key =\>  
“assigned\_to”  
end

I’m using Rails 2.1.1 so I’m doing this in the view:

# new.html.erb

\<% form\_for @task do |f| %\>  
… fields  
\<% end %\>

But the application posts to the index action, not the create action  
like it’s supposed to; even if I try to post a blank form, when errors  
should be raised, it’s posting without raising any errors whatsoever.  
The new action in the controller reads like this:

def new  
@task = @current\_user.created\_tasks.build  
end

and here’s the create action:

def create  
@task = @current\_user.created\_tasks.build(params[:task])  
if @task.save  
flash[:notice] = “Task was created”  
redirect\_to task\_path(@task)  
else  
render :action =\> ‘new’  
end  
end

Can someone let me know what I’m doing wrong? Should I not be  
creating the task with build? I thought I was getting pretty decent  
with the basics of Rails, but I guess not because something this  
simple is tripping me up.

---

<div class="post-metadata">

**Author:** ![wemagor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/8edcca/32.png) [@wemagor](https://www.ruby-forum.com/u/wemagor)\
**Post date:** [October 22, 2008, 2:27am UTC](https://www.ruby-forum.com/t/i-dont-get-why-my-model-isnt-saving-assistance-requested/151480/2 "2008-10-22T02:27:22Z")

</div>

Okay… I have no idea what the problem was, but it seems to be  
working right now.

---

<div class="post-metadata">

**Author:** ![wemagor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/8edcca/32.png) [@wemagor](https://www.ruby-forum.com/u/wemagor)\
**Post date:** [November 5, 2008, 12:03am UTC](https://www.ruby-forum.com/t/i-dont-get-why-my-model-isnt-saving-assistance-requested/151480/3 "2008-11-05T00:03:35Z")

</div>

I had the same problem, restarting the server helped.

---

<div class="post-metadata">

**Author:** ![wemagor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/8edcca/32.png) [@wemagor](https://www.ruby-forum.com/u/wemagor)\
**Post date:** [October 22, 2008, 5:17am UTC](https://www.ruby-forum.com/t/i-dont-get-why-my-model-isnt-saving-assistance-requested/151480/4 "2008-10-22T05:17:41Z")

</div>

if you do task.save! it should show you where it fails
