Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. class Job < ActiveRecord::Base
  2. validates :title, presence: true
  3. validates :company, presence: true
  4. validates :url, presence: true
  5.  
  6. has_many :position_type_joins
  7. has_many :position_types, through: :position_type_joins
  8.  
  9. accepts_nested_attributes_for :position_types, :allow_destroy => true
  10.  
  11. end
  12.  
  13. class PositionType < ApplicationRecord
  14.  
  15. has_many :position_type_joins
  16. has_many :jobs, through: :position_type_joins
  17.  
  18. end
  19.  
  20. class PositionTypeJoin < ApplicationRecord
  21. belongs_to :job
  22. belongs_to :position_type
  23. end
  24.  
  25. +-------------------+----------------------+
  26. | Job title | Position Type |
  27. +-------------------+----------------------+
  28. | Painter | Contract, Part time |
  29. | Library Assistant | Part time, Volunteer |
  30. +-------------------+----------------------+
  31.  
  32. index do
  33. column :code
  34. column 'Sales Agent' do |client|
  35. client.sales_agent.agent_name if !client.sales_agent.nil?
  36. end
  37. end
  38.  
  39. index do
  40. column 'Position type' do |job|
  41. job.position_type.name if !job.position_type.name?
  42. end
  43. end
  44.  
  45. undefined method `position_type'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement