前提
Ruby on Railsチュートリアルでエラーの解決ができなくて困ってます。
AWSのcloud9を利用しています。
railsサーバーを開き、/signupの画面で送信ボタンを押すとこのエラーが表示されます。
分かりにくくなってしまいすみません。
実現したいこと
エラーを解決したいです。
発生している問題・エラーメッセージ
ActionController::RoutingError (No route matches [POST] "/users/new"): actionpack (6.0.4) lib/action_dispatch/middleware/debug_exceptions.rb:36:in `call' web-console (4.0.1) lib/web_console/middleware.rb:132:in `call_app' web-console (4.0.1) lib/web_console/middleware.rb:19:in `block in call' web-console (4.0.1) lib/web_console/middleware.rb:17:in `catch' web-console (4.0.1) lib/web_console/middleware.rb:17:in `call' actionpack (6.0.4) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call' railties (6.0.4) lib/rails/rack/logger.rb:37:in `call_app' railties (6.0.4) lib/rails/rack/logger.rb:26:in `block in call' activesupport (6.0.4) lib/active_support/tagged_logging.rb:80:in `block in tagged' activesupport (6.0.4) lib/active_support/tagged_logging.rb:28:in `tagged' activesupport (6.0.4) lib/active_support/tagged_logging.rb:80:in `tagged' railties (6.0.4) lib/rails/rack/logger.rb:26:in `call' sprockets-rails (3.4.2) lib/sprockets/rails/quiet_assets.rb:13:in `call' actionpack (6.0.4) lib/action_dispatch/middleware/remote_ip.rb:81:in `call' actionpack (6.0.4) lib/action_dispatch/middleware/request_id.rb:27:in `call' rack (2.2.3) lib/rack/method_override.rb:24:in `call' rack (2.2.3) lib/rack/runtime.rb:22:in `call' activesupport (6.0.4) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call' actionpack (6.0.4) lib/action_dispatch/middleware/executor.rb:14:in `call' actionpack (6.0.4) lib/action_dispatch/middleware/static.rb:126:in `call' rack (2.2.3) lib/rack/sendfile.rb:110:in `call' actionpack (6.0.4) lib/action_dispatch/middleware/host_authorization.rb:76:in `call' webpacker (4.0.7) lib/webpacker/dev_server_proxy.rb:29:in `perform_request' rack-proxy (0.7.2) lib/rack/proxy.rb:67:in `call' railties (6.0.4) lib/rails/engine.rb:527:in `call' puma (4.3.6) lib/puma/configuration.rb:228:in `call' puma (4.3.6) lib/puma/server.rb:713:in `handle_request' puma (4.3.6) lib/puma/server.rb:472:in `process_client' puma (4.3.6) lib/puma/server.rb:328:in `block in run' puma (4.3.6) lib/puma/thread_pool.rb:134:in `block in spawn_thread'
該当のソースコード
まだ学習中でどこが該当コードなのかわかっていないので、自分でそうだと思うところを記載します。教えていただけると助かります。
Ruby
1Rails.application.routes.draw do 2 get 'users/new' 3 root 'static_pages#home' 4 get '/help', to: 'static_pages#help' 5 get '/about', to: 'static_pages#about' 6 get '/contact', to: 'static_pages#contact' 7 get '/signup', to: 'users#new' 8 resources :users 9end
Ruby
1module UsersHelper 2 3 # 引数で与えられたユーザーのGravatar画像を返す 4 def gravatar_for(user, size: 80) 5 gravatar_id = Digest::MD5::hexdigest(user.email.downcase) 6 gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}?s=#{size}" 7 image_tag(gravatar_url, alt: user.name, class: "gravatar") 8 end 9end
Ruby
1class UsersController < ApplicationController 2 3 def show 4 @user = User.find(params[:id]) 5 end 6 7 def new 8 @User = User.new 9 end 10 11 def create 12 @user = User.new(user_params) 13 if @user.save 14 # 保存の成功をここで扱う。 15 else 16 render 'new' 17 end 18 end 19 20 private 21 22 def user_params 23 params.require(:user).permit(:name, :email, :password, 24 :password_confirmation) 25 end 26end
Ruby
1<% provide(:title, 'Sign up') %> 2<h1>Sign up</h1> 3 4<div class="row"> 5 <div class="col-md-6 col-md-offset-3"> 6 <%= form_with(model: @user, local: true) do |f| %> 7 <%= f.label :name %> 8 <%= f.text_field :name %> 9 10 <%= f.label :email %> 11 <%= f.email_field :email %> 12 13 <%= f.label :password %> 14 <%= f.password_field :password %> 15 16 <%= f.label :password_confirmation, "Confirmation" %> 17 <%= f.password_field :password_confirmation %> 18 19 <%= f.submit "Create my account", class: "btn btn-primary" %> 20 <% end %> 21 </div> 22</div>
Ruby
1<% provide(:title, @user.name) %> 2<div class="row"> 3 <aside class="col-md-4"> 4 <section class="user_info"> 5 <h1> 6 <%= gravatar_for @user %> 7 <%= @user.name %> 8 </h1> 9 </section> 10 </aside> 11</div>
試したこと
googleで検索などしてみましたが解決できませんでした。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答3件
あなたの回答
tips
プレビュー