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.
   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

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

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.

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