# Not updating

**URL:** <https://www.ruby-forum.com/t/not-updating/94247>\
**Category:** Rails\
**Created:** [April 26, 2006, 6:21pm UTC](https://www.ruby-forum.com/t/not-updating/94247 "2006-04-26T18:21:43Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohammad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mohammad](https://www.ruby-forum.com/u/mohammad)\
**Post date:** [April 26, 2006, 6:21pm UTC](https://www.ruby-forum.com/t/not-updating/94247/1 "2006-04-26T18:21:43Z")

</div>

I copied the scaffolding edit and update and made it like this,

Note: awnser is edit.

Admin\_contoller.rb

def awnser  
@question = Question.find(params[:id])  
end

def update  
@question = Question.find(params[:id])  
if @question.update\_attributes(params[:question])  
flash[:notice] = ‘Question was successfully updated.’  
redirect\_to :action =\> ‘list’  
else  
render :action =\> ‘edit’  
flash[:notice] = “Edit failed”  
end  
end

Awnser.rhtml

# Awnsering question

\<%= start\_form\_tag :action =\> ‘update’, :id =\> @question %\>

\<%= @question.question %\>

Awnser  
\<%= text\_area 'questions', 'awnser' %\>

\<%= submit\_tag ‘Awnser’ %\>  
\<%= end\_form\_tag %\>

It flashes that it works but it really dosn’t change the question.awnser

---

<div class="post-metadata">

**Author:** ![mohammad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mohammad](https://www.ruby-forum.com/u/mohammad)\
**Post date:** [April 26, 2006, 9:59pm UTC](https://www.ruby-forum.com/t/not-updating/94247/2 "2006-04-26T21:59:01Z")

</div>

Bill W. wrote:

> Hi Mohammad,
> 
> I might be misunderstanding your question but if, when your “Note” says  
> ‘awnser is edit’ you mean that you don’t have an ‘edit’ aciton in your  
> controller, then you might need to render :action =\> ‘awnser’ instead of  
> render :action =" ‘edit’.
> 
> hth,  
> Bill

I did change this I thought that that would be it but, no that didn’t  
work it still thinks that it is updating it when its not, I made sure  
that there was no more typos for changing the names and there didn’t  
appear to be any. Im not sure what is going on.

---

<div class="post-metadata">

**Author:** ![mohammad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mohammad](https://www.ruby-forum.com/u/mohammad)\
**Post date:** [April 26, 2006, 7:09pm UTC](https://www.ruby-forum.com/t/not-updating/94247/3 "2006-04-26T19:09:27Z")

</div>

Hi Mohammad,

I might be misunderstanding your question but if, when your “Note” says  
‘awnser is edit’ you mean that you don’t have an ‘edit’ aciton in your  
controller, then you might need to render :action =\> ‘awnser’ instead of  
render :action =" ‘edit’.

hth,  
Bill

----- Original Message -----  
From: “Mohammad” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Wednesday, April 26, 2006 11:21 AM  
Subject: [Rails] Not updating

---

<div class="post-metadata">

**Author:** ![mohammad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mohammad](https://www.ruby-forum.com/u/mohammad)\
**Post date:** [April 26, 2006, 10:05pm UTC](https://www.ruby-forum.com/t/not-updating/94247/4 "2006-04-26T22:05:57Z")

</div>

Mohammad wrote:

> Awnser.rhtml
> 
> # Awnsering question
> 
> \<%= start\_form\_tag :action =\> ‘update’, :id =\> @question %\>
> 
> \<%= @question.question %\>
> 
> Awnser  
> \<%= text\_area 'questions', 'awnser' %\>

That text\_area needs to be ‘question’, ‘awnser’, singlualr question, not  
plural questions

and if the db field is string, rather than text, it should probably be a  
text\_field, rather than a text\_area.

Hope this helps,

Alan

---

<div class="post-metadata">

**Author:** ![mohammad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mohammad](https://www.ruby-forum.com/u/mohammad)\
**Post date:** [April 26, 2006, 10:53pm UTC](https://www.ruby-forum.com/t/not-updating/94247/5 "2006-04-26T22:53:37Z")

</div>

Mohammad,

You need to save the model after you update it.

@question = Question.find(params[:id])  
@question.update\_attributes(params[:question])  
if @question.save  
…

---

<div class="post-metadata">

**Author:** ![mohammad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mohammad](https://www.ruby-forum.com/u/mohammad)\
**Post date:** [April 26, 2006, 10:13pm UTC](https://www.ruby-forum.com/t/not-updating/94247/6 "2006-04-26T22:13:07Z")

</div>

If you’d post your code, it’ll probably jump out at someone. If you do,  
please explain the problem you’re having again.

Best regards,  
Bill  
----- Original Message -----  
From: “Mohammad” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Wednesday, April 26, 2006 2:59 PM  
Subject: [Rails] Re: Not updating

---

<div class="post-metadata">

**Author:** ![mohammad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mohammad](https://www.ruby-forum.com/u/mohammad)\
**Post date:** [April 27, 2006, 3:39am UTC](https://www.ruby-forum.com/t/not-updating/94247/7 "2006-04-27T03:39:46Z")

</div>

Alan thanks this is what I did wrong, once again thanks Alan.

---

<div class="post-metadata">

**Author:** ![mohammad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mohammad](https://www.ruby-forum.com/u/mohammad)\
**Post date:** [April 26, 2006, 11:03pm UTC](https://www.ruby-forum.com/t/not-updating/94247/8 "2006-04-26T23:03:18Z")

</div>

Oops, I guess update\_attributes does a save. My bad.
