# Undefined method save

**URL:** <https://www.ruby-forum.com/t/undefined-method-save/127209>\
**Category:** Rails\
**Created:** [January 26, 2008, 7:13am UTC](https://www.ruby-forum.com/t/undefined-method-save/127209 "2008-01-26T07:13:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [January 26, 2008, 7:13am UTC](https://www.ruby-forum.com/t/undefined-method-save/127209/1 "2008-01-26T07:13:20Z")

</div>

I have this app that is supposed to take as input several parts of a  
blog entry and save it in a table. I did the migration to create the  
tables and the created a partial for the form to enter the data. I hit  
the submit button and the I get:

undefined method `save’ for . . .

My table has the correct models mapped to it and it is hitting the  
controller correctly because it’s displaying the message, but when it  
hits ‘save’, as far as I can tell, there should be no reason why it  
doesn’t work. Here is the cotroller code:

def add\_entry  
@entry = Blog.new  
@entry = params[:blog]  
@user = User.find\_by\_id(params[:id])

```
if !@entry.nil? and @entry.save
  render :inline => '<h1>' + @entry.header + '</h1>'
else
  flash[:notice] = 'ERROR'
  render :partial => 'entry_form', :id => @user.id
end

```

end

Anyone have any ideas? thanks,

-S

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [January 26, 2008, 1:26pm UTC](https://www.ruby-forum.com/t/undefined-method-save/127209/2 "2008-01-26T13:26:07Z")

</div>

On 26 Jan 2008, at 06:13, Shandy N. wrote:

> hits ‘save’, as far as I can tell, there should be no reason why it  
> flash[:notice] = ‘ERROR’  
> render :partial =\> ‘entry\_form’, :id =\> @user.id  
> end  
> end

You’ve set @entry to be params[:blog]. Hashes don’t have a save  
method. Maybe you meant @entry = Blog.new(params[:blog) or  
@entry.attributes = params[:blog]

Fred
