Guest User

Untitled

a guest
Nov 20th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. class Project < ApplicationRecord
  2. has_many :sales, -> { order(:date) }, inverse_of: :project, dependent: :destroy
  3. end
  4.  
  5. class Sale < ApplicationRecord
  6. belongs_to :project, inverse_of: :sales, touch: true
  7. validates :hours, numericality: { only_integer: true }
  8. end
  9.  
  10. class ProjectsController < ApplicationController
  11. def index
  12. @q = Project.ransack(params[:q])
  13. @projects = @q.result
  14. end
  15. end
  16.  
  17. <th><%= sort_link(@q, <SUM_OF_SOLD_HOURS>, 'Hours') %></th>
Add Comment
Please, Sign In to add comment