Unable to update form

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. def update
  2. @score = Score.find(params[:id])
    
  3. if @score.update_attributes(params[:score])
    
  4.   flash[:notice] = 'Score was successfully updated.'
    
  5.   redirect_to scores_path
    
  6. else
    
  7.   render :action => 'edit'
    
  8. end
    
  9. end

Am I missing something?
Thanks!
Matt

Mathieu Manny wrote:

Code :

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

I think you want to say “redirect_to :action => ‘scores_path’”.

-S

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.

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

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

I suggest you do it :

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


OR ANOTHER OPTION

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