Guest User

Untitled

a guest
Jun 20th, 2018
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. Controllers:
  2.  
  3. def create
  4. render :action => "new"
  5. end
  6.  
  7. def new
  8. @profession_types = ProfessionType.all
  9. @professional = Professional.find(:first, :conditions => {:user_id => current_user.id})
  10. @speccies = ProfessionalSpecialty.first
  11. @active_specialties = @professional.professional_specialties.map do |spec|
  12. spec.profession_type_id
  13. end
  14. @specialty_forms = {}
  15. @profession_types.each do |pt|
  16. unless @active_specialties.include?(pt.id) then
  17. @professional.professional_specialties.build(attributes = {:profession_type_id => pt.id})
  18. end
  19. end
  20. @specialties = @professional.professional_specialties
  21. @industryTypes = Professional.first.professional_specialties.first.industry_bodies
  22. end
  23.  
  24.  
  25.  
  26. View:
  27.  
  28.  
  29. <% form_for(@professional, :url => '/professional_specialties/create') do |f| %>
  30. ...
  31.  
  32.  
  33. Routes:
  34. resources :pages, :page_image, :professionals, :profession_types, :languages, :plans, :professional_specialties
Add Comment
Please, Sign In to add comment