Hello I am following a rails tutorial, I am using rails 3.2.3 and I have this error Routing Error
No route matches [POST] “/movies/9/edit”
Here is my haml page:
%h2 Edit Movie
= form_tag edit_movie_path(@movie), :method => :put do
= label :movie, :title, ‘Title’
= text_field :movie, ‘title’
= label :movie, :rating, ‘Rating’
= select :movie, :rating, [‘G’,’PG’,’PG-13′,’R’,’NC-17′]
= label :movie, :release_date, ‘Released On’
= date_select :movie, :release_date
= submit_tag ‘Save Changes’
Here is my controller:
def edit
@movie = Movie.find params[:id]
end
def update
@movie = Movie.find params[:id]
@movie.update_attributes!(params[:movie])
flash[:notice] = "#{@movie.title} was successfully updated."
redirect_to movie_path(@movie)
end
and my routes:
movies GET /movies(.:format) movies#index
POST /movies(.:format) movies#create
new_movie GET /movies/new(.:format) movies#new
edit_movie GET /movies/:id/edit(.:format) movies#edit
movie GET /movies/:id(.:format) movies#show
PUT /movies/:id(.:format) movies#update
DELETE /movies/:id(.:format) movies#destroy
Thanks for the help
The tutorial may be leading you astray.
It’s telling you to have your form
PUTto the edit path.You really want to
PUTto the normal movie path. Anupdateis implied by thePUTverb.Instead of:
Try:
Indeed, you may want to find a different tutorial.