Rails5.1.3でWebアプリケーション制作の勉強をしています。
model/history.rbを新規に作成し、admin/histories_controller.rbを新規に作成しました。
history.rb class History < ActiveRecord::Base belongs_to :customer ORDER = %W(1), %w(2), %w(3), %w(4), %w(5), %w(6), %w(7), %w(8), %w(9), %w(10), %w(11), %w(12), %w(13), %w(14), %w(15), %w(16), %w(17), %w(18), %w(19), %w(20) end
histories_controller.rb class Admin::HistoriesController < Admin::Base def show @customer = Customer.find_by(id: params[:id]) @history = History.where(customer_id: params[:id]) end def order @order = History.where("created_at >= ?", Time.zone.now.beginning_of_day) end def order_history check = Check.find(1) year = check.check_year month = check.check_month day = check.check_day a = "-" @abc = year.to_s + a + month.to_s + a + day.to_s @history = History.where(created_at: @abc.in_time_zone.all_day) end def undispatched @undispatched = History.where(undispatched: "未発送") end end
routes.rb resource :history do get :order get :order_history get :undispatched end
以上のようにコードを記述しています。
orderアクションにアクセスしようとすると「RoutingError」が発生します。
エラー内容 ActionController::RoutingError (uninitialized constant HistoriesController)
HistoriesControllerがありません。ということだと思いますが、HistoriesControllerは
作成しているので原因と解決方法がわからず困っております。
どなたか教えていただけないでしょうか?宜しくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。