下記エラーがでてしまいました。new とeditで同じフォームをしようしている場合はurlを指定するときいたのですが、正しい先がわかりません。
初歩的なものなのですがどうしてもわからずこまっています。
どうぞよろしくお願い致します。
Ruby on rails 4
【現在の内容】
routes
Rails.application.routes.draw do resources :recipes root 'recipes#index' get 'recipes/index' end <rake routesにて確認しましたがいまいち見方になれておらず、 どのように指定したらよいのか迷っています。> Prefix Verb URI Pattern Controller#Action recipes GET /recipes(.:format) recipes#index POST /recipes(.:format) recipes#create new_recipe GET /recipes/new(.:format) recipes#new edit_recipe GET /recipes/:id/edit(.:format) recipes#edit recipe GET /recipes/:id(.:format) recipes#show PATCH /recipes/:id(.:format) recipes#update PUT /recipes/:id(.:format) recipes#update DELETE /recipes/:id(.:format) recipes#destroy root GET / recipes#index recipes_index GET /recipes/index(.:format) recipes#index
controller
def create @recipe = Recipe.new(recipe_params) if @recipe.save redirect_to @recipe, notice:"Successfully created new recipe" else render 'new' end end def edit end def update if @recipe.updte(recipe_params) redirect_to @recipe else render 'edit' end end def destroy @recipe.destroy redirect_to root_path, notice:"Successfully deleted recipe" end private def recipe_params params.require(:recipe).permit(:title, :description) end def find_recipe @recipe = Recipe.find(params[:id]) end end
Edit
<h1>Edit Recipe</h1> <%=render 'form'%>
new
<h1>New Recipe</h1> <%=render'form'%> <br> <%=link_to"Back",root_path, class:"btn btn-default"%>
model
class Recipe < ActiveRecord::Base end
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/12/13 06:19