はじめに
- Ruby on Rails初心者です。
- 現在、複数人でバージョン管理しながらアプリ制作を行っています。
- 表題の通り、ビューがあるのにテンプレートがないというエラーが出ており、その理由が掴めず困っています。
エラーメッセージ
Ruby
1Template is missingMissing 2template user/user_post, application/user_post with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in: * "C:/Users/s.nozaki/git_remote/team_A/app/views"
ソースコード
以下のコードで実行しました
Ruby
1# ルーティング: ユーザモデルに関係のある部分だけ記述しています。 2 post '/:id/posts_alternation' => 'user#alternation' 3 get '/:id/posts_alternation' => 'user#user_post' 4 post '/logout' => 'user#logout' 5 post '/user/login' => 'user#login' 6 get '/user/login_form' => 'user#login_form' 7 resources :user 8 9# コントローラ 10# user_controller.rb 11def user_post 12end 13 14 def alternation 15 @post = Post.find(params[:id]) 16 if @post 17 @post.content = params[:content] 18 flash[:notice] = "編集しました" 19 redirect_to user_path 20 end 21 end 22 23# ビュー 24# app/view/user/posts_alternation 25<div class="main posts-new"> 26<div class="container"> 27 <h1 class="form-heading">投稿する</h1> 28 <%= form_tag("/#{@post.id}/posts_alternation") do %> 29(中略) 30 <% end %> 31</div> 32</div> 33
ビューファイルはあるので、ルーティングが間違っているのかもしれませんが、どのように指定すれば解決できるのか
いまいちわからない状況です。
何かアドバイスいただけますと幸いです。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/09/20 02:26
2017/09/20 02:41