こんにちは。
現在開発を行なっている中でルーティングエラーが発生し、原因が分からずにいます。
エラー発生のタイミングはcreate、updateの時に発生しており更新・リダイレクト共に出来ていない状況です。
Started PATCH "/mypage/companies" for 127.0.0.1 at 2019-06-20 14:16:32 +0900 ActionController::RoutingError (No route matches [PATCH] "/mypage/companies"): actionpack (5.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:65:in `call' web-console (3.7.0) lib/web_console/middleware.rb:135:in `call_app' web-console (3.7.0) lib/web_console/middleware.rb:30:in `block in call' web-console (3.7.0) lib/web_console/middleware.rb:20:in `catch' web-console (3.7.0) lib/web_console/middleware.rb:20:in `call' actionpack (5.2.3) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call' railties (5.2.3) lib/rails/rack/logger.rb:38:in `call_app' railties (5.2.3) lib/rails/rack/logger.rb:26:in `block in call' activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `block in tagged' activesupport (5.2.3) lib/active_support/tagged_logging.rb:28:in `tagged' activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `tagged' railties (5.2.3) lib/rails/rack/logger.rb:26:in `call' sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call' actionpack (5.2.3) lib/action_dispatch/middleware/remote_ip.rb:81:in `call' actionpack (5.2.3) lib/action_dispatch/middleware/request_id.rb:27:in `call' rack (2.0.7) lib/rack/method_override.rb:22:in `call' rack (2.0.7) lib/rack/runtime.rb:22:in `call' activesupport (5.2.3) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call' actionpack (5.2.3) lib/action_dispatch/middleware/executor.rb:14:in `call' actionpack (5.2.3) lib/action_dispatch/middleware/static.rb:127:in `call' rack (2.0.7) lib/rack/sendfile.rb:111:in `call' railties (5.2.3) lib/rails/engine.rb:524:in `call' puma (3.12.1) lib/puma/configuration.rb:227:in `call' puma (3.12.1) lib/puma/server.rb:660:in `handle_request' puma (3.12.1) lib/puma/server.rb:474:in `process_client' puma (3.12.1) lib/puma/server.rb:334:in `block in run' puma (3.12.1) lib/puma/thread_pool.rb:135:in `block in spawn_thread'
routes
1 #user mypage 2 namespace :mypage do 3 get "" => "dashbord#index" 4 get "/" => "dashbord#index" 5 get "/choice" => "dashbord#choice" #決済ページ 6 7 resources :companies do 8 resources :comments, :blocks 9 resources :attachments 10 member do 11 get 'attachments/view' 12 get 'attachments/download/:id' => 'attachments#download', as: :attachments_pdf 13 end 14 end 15...
controller
1class Mypage::CompaniesController < Mypage::BaseController 2 # set_company 再構成 :new :create を除外する 3 skip_before_action :set_company 4 before_action :set_company, except: [:new, :create] 5 6 def index 7 @companies = Company.all 8 end 9 10 def show 11 @company = current_user.company 12 add_breadcrumb "マイページ", "/mypage" 13 end 14 15 def new 16# @company = Company.new(company_params.merge(user_id: current_user.id)) 17 @company = current_user.company 18 #render :layout => 'application' 19 end 20 21 def create 22# @company = Company.new(company_params) 23 @company = current_user.build_company(company_params) 24 if @company.save 25 # redirect 26 flash[:notice] = "編集を完了しました。" 27 redirect_to mypage_company_path 28 else 29 render 'new' 30 end 31 end 32 33 def edit 34 @company = @current_company 35 add_breadcrumb "マイページ", "/mypage" 36 add_breadcrumb "企業情報編集", "/mypage/company/edit" 37 end 38 39 def update 40 @company = @current_company 41 if @company.update(company_params) 42 flash[:notice] = "編集を完了しました。" 43 redirect_to mypage_company_path 44 else 45 render 'edit' 46 end 47 end
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/06/20 05:40
2019/06/20 05:56
2019/06/21 03:26
2019/06/21 06:34
2019/06/22 08:16