# Unable to update form

**URL:** <https://www.ruby-forum.com/t/unable-to-update-form/146496>\
**Category:** Rails\
**Created:** [August 21, 2008, 5:55pm UTC](https://www.ruby-forum.com/t/unable-to-update-form/146496 "2008-08-21T17:55:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hellomatts](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ee7513/32.png) [@hellomatts](https://www.ruby-forum.com/u/hellomatts)\
**Post date:** [August 21, 2008, 5:55pm UTC](https://www.ruby-forum.com/t/unable-to-update-form/146496/1 "2008-08-21T17:55:11Z")

</div>

I’m new to Rails, and have been reading up on it like crazy… Anyway, I  
built a form using render :partial, and it works fine when creating a  
new record, however, am having a hell of a time saving modifications to  
it… Here is my edit.html.erb file:

Code :

1. \<% form\_tag :action =\> ‘update’, :id =\> @score do %\>
2. \<%= render :partial =\> ‘form’ %\>
3. \<%= submit\_tag ‘Edit’ %\>
4. \<% end %\>

The response that I receive from the browser is as follows:

Unknown action  
No action responded to 10

In my controller file, I have the following:

Code :

1. 
2. def update
3. 

```
@score = Score.find(params[:id])

```

4. 

```
if @score.update_attributes(params[:score])

```

5. 

```
  flash[:notice] = 'Score was successfully updated.'

```

6. 

```
  redirect_to scores_path

```

7. 

```
else

```

8. 

```
  render :action => 'edit'

```

9. 

```
end

```

10. end

Am I missing something?  
Thanks!  
Matt

---

<div class="post-metadata">

**Author:** ![hellomatts](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ee7513/32.png) [@hellomatts](https://www.ruby-forum.com/u/hellomatts)\
**Post date:** [August 21, 2008, 6:20pm UTC](https://www.ruby-forum.com/t/unable-to-update-form/146496/2 "2008-08-21T18:20:32Z")

</div>

Mathieu Manny wrote:

> Code :
> 
> 1. 
> 2. def update
> 3. 
> 
> ```
> @score = Score.find(params[:id])
> 
> ```
> 
> 4. 
> 
> ```
> if @score.update_attributes(params[:score])
> 
> ```
> 
> 5. 
> 
> ```
> flash[:notice] = 'Score was successfully updated.'
> 
> ```
> 
> 6. 
> 
> ```
> redirect_to scores_path
> 
> ```
> 
> 7. 
> 
> ```
> else
> 
> ```
> 
> 8. 
> 
> ```
> render :action => 'edit'
> 
> ```
> 
> 9. 
> 
> ```
> end
> 
> ```
> 
> 10. end

I think you want to say “redirect\_to :action =\> ‘scores\_path’”.

-S

---

<div class="post-metadata">

**Author:** ![hellomatts](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ee7513/32.png) [@hellomatts](https://www.ruby-forum.com/u/hellomatts)\
**Post date:** [August 21, 2008, 7:05pm UTC](https://www.ruby-forum.com/t/unable-to-update-form/146496/3 "2008-08-21T19:05:56Z")

</div>

If he’s got restful routes, he’s fine with his redirect\_to… I use it  
all the time, like “redirect\_to projects\_path”

What’s inside the form partial? Since edit.html.erb has a form tag, the  
form partial shouldn’t include a form tag, or a form\_for.

---

<div class="post-metadata">

**Author:** ![hellomatts](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ee7513/32.png) [@hellomatts](https://www.ruby-forum.com/u/hellomatts)\
**Post date:** [September 28, 2008, 4:56pm UTC](https://www.ruby-forum.com/t/unable-to-update-form/146496/4 "2008-09-28T16:56:54Z")

</div>

Hi,  
Did you ever figure out the problem? I’m hitting the same issue. For  
some reason the ‘update’ action is not being added to the url when the  
form is sumbitted.

Laris

---

<div class="post-metadata">

**Author:** ![hellomatts](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ee7513/32.png) [@hellomatts](https://www.ruby-forum.com/u/hellomatts)\
**Post date:** [September 28, 2008, 5:20pm UTC](https://www.ruby-forum.com/t/unable-to-update-form/146496/5 "2008-09-28T17:20:34Z")

</div>

You are in not rule of your routes.rb, because the error said that cant  
process ID=10

I suggest you do it :

1. 

2.def update  
3. @score = Score.find(params[:id])  
4. respond\_to do |format|  
5. if @score.update\_attributes(params[:score])  
6. flash[:notice] = ‘Score was successfully updated.’  
7. format.html{redirect\_to scores\_path(@score) }  
8. else  
9. format.html{render :action =\> ‘edit’}  
10. end  
11. end  
12.end

Answered on Sunday, 28-Sept-2008  
By : Y Reinhart AP  
Blog : [Teapoci.Blogspot.com](http://Teapoci.Blogspot.com)

---

<div class="post-metadata">

**Author:** ![hellomatts](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ee7513/32.png) [@hellomatts](https://www.ruby-forum.com/u/hellomatts)\
**Post date:** [September 28, 2008, 5:29pm UTC](https://www.ruby-forum.com/t/unable-to-update-form/146496/6 "2008-09-28T17:29:24Z")

</div>

* * *

## OR ANOTHER OPTION

1. 

2.def update  
3. @score = Score.find(params[:id])  
4. respond\_to do |format|  
5. if @score.update\_attributes(params[:score])  
6. flash[:notice] = ‘Score was successfully updated.’  
7. format.html{redirect\_to scores\_url}  
8. else  
9. format.html{render :action =\> ‘edit’}  
10. end  
11. end  
12.end

I did not test them, give me update of my answers. thank you.

Answered on Sunday, 28-Sept-2008  
By : Y Reinhart AP  
Blog : [Teapoci.Blogspot.com](http://Teapoci.Blogspot.com)
