質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

解決済

1回答

761閲覧

コメントを送信したらル-ティングエラーが出た

yozakura10

総合スコア8

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2020/10/26 03:29

前提・実現したいこと
prototypeにコメント蘭を作成しました
そのコメントを送信して無事にページを移動したいです

発生している問題・エラーメッセージ
ruby on railsでの作成途中でおきました
エラーメッセージ

エラー文です

ruby

1 2Routing Error 3No route matches [GET] "/prototype/1" 4Rails.root: /Users/kamiyaryota/Desktop/projects/protospace-31035 5 6Application Trace | Framework Trace | Full Trace 7Routes 8Routes match in priority from top to bottom 9 10Helper HTTP Verb Path Controller#Action 11Path / Url 12Path Match 13new_user_session_path GET /users/sign_in(.:format) 14devise/sessions#new 15 16user_session_path POST /users/sign_in(.:format) 17devise/sessions#create 18 19destroy_user_session_path DELETE /users/sign_out(.:format) 20devise/sessions#destroy 21 22new_user_password_path GET /users/password/new(.:format) 23devise/passwords#new 24 25edit_user_password_path GET /users/password/edit(.:format) 26devise/passwords#edit 27 28user_password_path PATCH /users/password(.:format) 29devise/passwords#update 30 31PUT /users/password(.:format) 32devise/passwords#update 33 34POST /users/password(.:format) 35devise/passwords#create 36 37cancel_user_registration_path GET /users/cancel(.:format) 38devise/registrations#cancel 39 40new_user_registration_path GET /users/sign_up(.:format) 41devise/registrations#new 42 43edit_user_registration_path GET /users/edit(.:format) 44devise/registrations#edit 45 46user_registration_path PATCH /users(.:format) 47devise/registrations#update 48 49PUT /users(.:format) 50devise/registrations#update 51 52DELETE /users(.:format) 53devise/registrations#destroy 54 55POST /users(.:format) 56devise/registrations#create 57 58root_path GET / 59prototypes#index 60 61new_user_path GET /users/new(.:format) 62users#new 63 64edit_user_path GET /users/:id/edit(.:format) 65users#edit 66 67user_path PATCH /users/:id(.:format) 68users#update 69 70PUT /users/:id(.:format) 71users#update 72 73prototype_comments_path POST /prototypes/:prototype_id/comments(.:format) 74comments#create 75 76prototypes_path POST /prototypes(.:format) 77prototypes#create 78 79new_prototype_path GET /prototypes/new(.:format) 80prototypes#new 81 82edit_prototype_path GET /prototypes/:id/edit(.:format) 83prototypes#edit 84 85prototype_path GET /prototypes/:id(.:format) 86prototypes#show 87 88PATCH /prototypes/:id(.:format) 89prototypes#update 90 91PUT /prototypes/:id(.:format) 92prototypes#update 93 94DELETE /prototypes/:id(.:format) 95prototypes#destroy 96 97users_sign_out_path GET /users/sign_out(.:format) 98devise/sessions#destroy 99 100rails_postmark_inbound_emails_path POST /rails/action_mailbox/postmark/inbound_emails(.:format) 101action_mailbox/ingresses/postmark/inbound_emails#create 102 103rails_relay_inbound_emails_path POST /rails/action_mailbox/relay/inbound_emails(.:format) 104action_mailbox/ingresses/relay/inbound_emails#create 105 106rails_sendgrid_inbound_emails_path POST /rails/action_mailbox/sendgrid/inbound_emails(.:format) 107action_mailbox/ingresses/sendgrid/inbound_emails#create 108 109rails_mandrill_inbound_health_check_path GET /rails/action_mailbox/mandrill/inbound_emails(.:format) 110action_mailbox/ingresses/mandrill/inbound_emails#health_check 111 112rails_mandrill_inbound_emails_path POST /rails/action_mailbox/mandrill/inbound_emails(.:format) 113action_mailbox/ingresses/mandrill/inbound_emails#create 114 115rails_mailgun_inbound_emails_path POST /rails/action_mailbox/mailgun/inbound_emails/mime(.:format) 116action_mailbox/ingresses/mailgun/inbound_emails#create 117 118rails_conductor_inbound_emails_path GET /rails/conductor/action_mailbox/inbound_emails(.:format) 119rails/conductor/action_mailbox/inbound_emails#index 120 121POST /rails/conductor/action_mailbox/inbound_emails(.:format) 122rails/conductor/action_mailbox/inbound_emails#create 123 124new_rails_conductor_inbound_email_path GET /rails/conductor/action_mailbox/inbound_emails/new(.:format) 125rails/conductor/action_mailbox/inbound_emails#new 126 127edit_rails_conductor_inbound_email_path GET /rails/conductor/action_mailbox/inbound_emails/:id/edit(.:format) 128rails/conductor/action_mailbox/inbound_emails#edit 129 130rails_conductor_inbound_email_path GET /rails/conductor/action_mailbox/inbound_emails/:id(.:format) 131rails/conductor/action_mailbox/inbound_emails#show 132 133PATCH /rails/conductor/action_mailbox/inbound_emails/:id(.:format) 134rails/conductor/action_mailbox/inbound_emails#update 135 136PUT /rails/conductor/action_mailbox/inbound_emails/:id(.:format) 137rails/conductor/action_mailbox/inbound_emails#update 138 139DELETE /rails/conductor/action_mailbox/inbound_emails/:id(.:format) 140rails/conductor/action_mailbox/inbound_emails#destroy 141 142rails_conductor_inbound_email_reroute_path POST /rails/conductor/action_mailbox/:inbound_email_id/reroute(.:format) 143rails/conductor/action_mailbox/reroutes#create 144 145rails_service_blob_path GET /rails/active_storage/blobs/:signed_id/*filename(.:format) 146active_storage/blobs#show 147 148rails_blob_representation_path GET /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) 149active_storage/representations#show 150 151rails_disk_service_path GET /rails/active_storage/disk/:encoded_key/*filename(.:format) 152active_storage/disk#show 153 154update_rails_disk_service_path PUT /rails/active_storage/disk/:encoded_token(.:format) 155active_storage/disk#update 156 157rails_direct_uploads_path POST /rails/active_storage/direct_uploads(.:format) 158active_storage/direct_uploads#create 159 160Request 161Parameters: 162 163None 164Toggle session dump 165Toggle env dump 166Response 167Headers: 168 169None

routes.rbです

ruby

1Rails.application.routes.draw do 2 devise_for :users 3 root to: "prototypes#index" 4 resources :users, only: [:new, :edit, :update,] 5 resources :prototypes, only: [:new, :create, :show, :edit, :update, :destroy,] do 6 resources :comments, only: :create 7 end 8 9 devise_ 10scope :user do 11 get '/users/sign_out' => 'devise/sessions#destroy' 12 end 13 14end 15

commentsコントローラーrbです

ruby

1class CommentsController < ApplicationController 2 def create 3 @comment = Comment.new(comment_params) 4 if @comment.save 5 redirect_to "/prototype/#{@comment.prototype.id}" 6 else 7 render :show 8 end 9 10 end 11 12 private 13 def comment_params 14 params.require(:comment).permit(:text).merge(user_id: current_user.id, prototype_id: params[:prototype_id]) 15 end 16end 17

prototypesコントローラ-rbです

ruby

1class PrototypesController < ApplicationController 2 3 def index 4 @prototypes = Prototype.all 5 end 6 7 def new 8 @prototype = Prototype.new 9 end 10 11 def create 12 @prototype = Prototype.new(prototype_params) 13 if @prototype.save 14 redirect_to root_path 15 else 16 render :new 17 end 18 end 19 20 def show 21 @prototype = Prototype.find(params[:id]) 22 @comment = Comment.new 23 24 end 25 26 def edit 27 @prototype = Prototype.find(params[:id]) 28 end 29 30 def update 31 prototype = Prototype.find(params[:id]) 32 if prototype.update(prototype_params) 33 redirect_to prototype_path 34 else 35 render :edit 36 end 37 end 38 39 def destroy 40 prototype = Prototype.find(params[:id]) 41 prototype.destroy 42 redirect_to root_path 43 end 44 45 private 46 def prototype_params 47 params.require(:prototype).permit(:title, :catct_copy, :concept, :image).merge(user_id: current_user.id) 48 end 49 50end

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

"/prototype/にsをつけたらできました

投稿2020/10/26 04:11

yozakura10

総合スコア8

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問