# Forms, database, and yes I'm new

**URL:** <https://www.ruby-forum.com/t/forms-database-and-yes-im-new/126321>\
**Category:** Rails\
**Created:** [January 17, 2008, 12:58pm UTC](https://www.ruby-forum.com/t/forms-database-and-yes-im-new/126321 "2008-01-17T12:58:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaizerkaizer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/45deac/32.png) [@kaizerkaizer](https://www.ruby-forum.com/u/kaizerkaizer)\
**Post date:** [January 17, 2008, 12:58pm UTC](https://www.ruby-forum.com/t/forms-database-and-yes-im-new/126321/1 "2008-01-17T12:58:06Z")

</div>

I have a quick question on a problem of mine.  
I’ve done the ONLamp tutorial with scaffolding a recipe etc, and honesly  
I didn’t get really any wiser. So I decided to try it out on my own  
without scaffolding.

However. Now I’m stuck with my edit-form. I need to update a row with  
old text in the ‘pres’ column in the table called ‘presentations’ in my  
database with a new text typed in with a form (in edit.rhtml).

My Edit method gets the ‘pres’ from the 'presentations’table but it  
doesn’t update the edited ‘pres’ with the new text to the database when  
the submit button is clicked. I really can’t understand why not? What is  
wrong with my code?

* * *

## Model

class Presentation \< ActiveRecord::Base

```
belongs_to :user

```

end

* * *

## controller

class PresentationController \< ApplicationController

def info  
@user\_login = current\_user.login  
@user\_presentation = current\_user.presentation.pres

end

def edit  
@presentation = current\_user.presentation(params[:id])  
end

def update  
@presentation = current\_user.presentation(params[:id])  
if @presentation.update\_attributes(params[:pres])  
redirect\_to :action =\> ‘info’

else  
render :action =\> ‘edit’

```
 end

```

end  
end

* * *

## Edit view

\<% form\_tag :action =\> ‘update’, :id =\> @presentation do %\>

Edit Information  
 \<%= text\_area 'presentation', 'pres' %\>

\<%= submit\_tag 'Update' %\>

\<% end %\>

---

<div class="post-metadata">

**Author:** ![kaizerkaizer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/45deac/32.png) [@kaizerkaizer](https://www.ruby-forum.com/u/kaizerkaizer)\
**Post date:** [January 17, 2008, 1:29pm UTC](https://www.ruby-forum.com/t/forms-database-and-yes-im-new/126321/2 "2008-01-17T13:29:34Z")

</div>

On 17 Jan 2008, at 11:58, Dag S. wrote:

> @presentation = current\_user.presentation(params[:id])  
> if @presentation.update\_attributes(params[:pres])  
> redirect\_to :action =\> ‘info’  
> [snip]

> Edit Information  
> \<%= text\_area 'presentation', 'pres' %\>

text\_area (and other similar) helpers will make the submitted  
parameters available as params[:presentation] since that’s the name of  
the object you’re editing.  
Use if @presentation.update\_attributes(params[:presentation])  
and you should be fine.

Fred

---

<div class="post-metadata">

**Author:** ![kaizerkaizer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/45deac/32.png) [@kaizerkaizer](https://www.ruby-forum.com/u/kaizerkaizer)\
**Post date:** [January 17, 2008, 9:29pm UTC](https://www.ruby-forum.com/t/forms-database-and-yes-im-new/126321/3 "2008-01-17T21:29:39Z")

</div>

Thank you Fred for solving my problem and explaining! Im very greatful
