前提
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
Rails.application.routes.draw do get 'users/new' root 'static_pages#home' get '/help', to: 'static_pages#help' get '/about', to: 'static_pages#about' get '/contact', to: 'static_pages#contact' get '/signup', to: 'users#new' resources :users end
Ruby
module UsersHelper # 引数で与えられたユーザーのGravatar画像を返す def gravatar_for(user, size: 80) gravatar_id = Digest::MD5::hexdigest(user.email.downcase) gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}?s=#{size}" image_tag(gravatar_url, alt: user.name, class: "gravatar") end end
Ruby
class UsersController < ApplicationController def show @user = User.find(params[:id]) end def new @User = User.new end def create @user = User.new(user_params) if @user.save # 保存の成功をここで扱う。 else render 'new' end end private def user_params params.require(:user).permit(:name, :email, :password, :password_confirmation) end end
Ruby
<% provide(:title, 'Sign up') %> <h1>Sign up</h1> <div class="row"> <div class="col-md-6 col-md-offset-3"> <%= form_with(model: @user, local: true) do |f| %> <%= f.label :name %> <%= f.text_field :name %> <%= f.label :email %> <%= f.email_field :email %> <%= f.label :password %> <%= f.password_field :password %> <%= f.label :password_confirmation, "Confirmation" %> <%= f.password_field :password_confirmation %> <%= f.submit "Create my account", class: "btn btn-primary" %> <% end %> </div> </div>
Ruby
<% provide(:title, @user.name) %> <div class="row"> <aside class="col-md-4"> <section class="user_info"> <h1> <%= gravatar_for @user %> <%= @user.name %> </h1> </section> </aside> </div>
試したこと
googleで検索などしてみましたが解決できませんでした。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
まだ回答がついていません
会員登録して回答してみよう