Guest User

Untitled

a guest
Sep 14th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. Can't figure out Has_many in select form
  2. class Position < ActiveRecord::Base
  3. #position attributes
  4. has_many :educations, :foreign_key => "position_id"
  5.  
  6.  
  7. class Education < ActiveRecord::Base
  8. belongs_to :position
  9.  
  10. EDUCATION_CHOICES = ([["Undergrad", "0"],["Master", 1],["PHD", 2]])
  11.  
  12. <%= f.select(:education_ids, Education::EDUCATION_CHOICES,{ :prompt => "Please select"},
  13. { :multiple => true, :size => 5 }) %>
  14.  
  15. <%= f.select(:education_ids, Education::EDUCATION_CHOICES,{ :prompt => "Please select"},
  16. { :multiple => true, :size => 5 }) %>
  17.  
  18. @position = Position.new(params[:position])
  19.  
  20. Processing by PositionsController#create as HTML
Add Comment
Please, Sign In to add comment