Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Project < ApplicationRecord
- has_many :sales, -> { order(:date) }, inverse_of: :project, dependent: :destroy
- end
- class Sale < ApplicationRecord
- belongs_to :project, inverse_of: :sales, touch: true
- validates :hours, numericality: { only_integer: true }
- end
- class ProjectsController < ApplicationController
- def index
- @q = Project.ransack(params[:q])
- @projects = @q.result
- end
- end
- <th><%= sort_link(@q, <SUM_OF_SOLD_HOURS>, 'Hours') %></th>
Add Comment
Please, Sign In to add comment