Mam następujący problem. Chcę edytować wcześniej utworzony już obiekt i mam problem z widokiem dla tego kontrolera, a konkretnie jak mi się wydaje z metodą link_to
articles_controller.rb dwie interesujące mnie metody -
def edit
@article = Article.find(params[:id])
end
def update
@article = Article.find(params[:id])
if @article.update_attributes(params[:article])
redirect_to articles_path
else
render :action => “edit”
end
end
index.html.rb
<td><%= link_to 'edit', edit_article_path(@article) %></td>
routing
articles GET /articles(.:format) articles#index
POST /articles(.:format) articles#create
new_article GET /articles/new(.:format) articles#new
edit_article GET /articles/:id/edit(.:format) articles#edit
article GET /articles/:id(.:format) articles#show
PUT /articles/:id(.:format) articles#update
DELETE /articles/:id(.:format) articles#destroy
Ewentualnie do podejrzenia https://github.com/aplaskota/blog