Relative Content

Tag Archive for ruby-on-railsruby

【Rails】There is method that can be called on the rails console but not on the test code and app

Rails 6.1.4.7 ruby 3.1.4p223 (2023-03-30 revision 957bb7cb81) [x86_64-linux] code RegularEvent’s holding_today? method calls the EventSchedule module (original). app/models/regular_event.rb class RegularEvent < ApplicationRecord scope :holding, -> { where(finished: false) } def self.today_events holding.select(&:holding_today?) end def holding_today? schedule = EventSchedule.load(self) # EventSchedule is original module. schedule.held_next_event_date.to_date == Time.zone.today end end Then, load method of the EventSchedule module […]