0
이 응용 프로그램에서 Resource_Estimations 모델은 회사에서 수행합니다. 회사 이름의 Resource_Estimations에 대한 기본 정렬 순서를 갖고 싶습니다.모델의 default_scope를 설정하려고하는 Rails 응용 프로그램
회사 모델
class Company < ActiveRecord::Base
include ActiveModel::ForbiddenAttributesProtection
...
has_many :resource_estimations, dependent: :destroy
...
validates :exchange_id, :name, :full_name, presence: true
Resource_Estimation 모델
class ResourceEstimation < ActiveRecord::Base
include ActiveModel::ForbiddenAttributesProtection
...
belongs_to :company
...
validates :company_id, :drill_id, :resource_type_id, :date,
:fill_to_spill,:p10, :p50, :p90, presence: true
...
default_scope { order(:company => :asc) }
Resource_Estimation 모델의 마지막 문 (default_scope는) 내가 변경하려고 것입니다. company_id의 현재 정렬 순서와 반대로 정렬 순서를 company.name으로 지정합니다. 여러 가지를 시도했지만 지금까지는 아무런 운이 없었습니다. 어떤 제안 컴백 기념 감사 피에르
멋진 - 감사 맥스. – user1854802