所以我有关于电影的这个数据库。我为它创建了一个resources :movies
条目进入我的路由文件,这应该为它提供所需的每个路由。尝试更新数据库条目时路由错误
这是我的电影控制器:https://github.com/Veske/form/blob/ryhm/app/controllers/movies_controller.rb
这是我的错误,当我尝试在whatever.com/movies/1/edit编辑影片:
Routing Error
No route matches [POST] "/movies/1/edit"
这些都是电影路线现在:
movies_path GET /movies(.:format) movies#index
POST /movies(.:format) movies#create
new_movie_path GET /movies/new(.:format) movies#new
edit_movie_path GET /movies/:id/edit(.:format) movies#edit
movie_path GET /movies/:id(.:format) movies#show
PATCH /movies/:id(.:format) movies#update
PUT /movies/:id(.:format) movies#update
DELETE /movies/:id(.:format) movies#destroy
现在人们清楚地看到,的确有电影没有POST /:现在ID /编辑。但为什么呢?我输入的路线不应该给我吗?
编辑:
链接到电影查看:https://github.com/Veske/form/blob/ryhm/app/views/movies/edit.html.erb
明白了,试图现在修复它.. – Veske
好吧我使用PUT:<%= form_for:movie,:html => {:method =>:put} do | f | %> 但是这并没有改变我没有为电影/:id/edit放置路线的事实。我怎样才能获得这条路线?我的意思是......资源应该为我做这件事? – Veske
在您的控制器中,在编辑动作中,在一个实例变量(例如'@movie = Movie.find(params [:id])')中加载电影,然后执行'form_for @ movie' – CDub