Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. class Profile < ApplicationRecord
  2. belongs_to :user
  3. has_and_belongs_to_many :skills
  4. has_and_belongs_to_many :jobs
  5. has_and_belongs_to_many :industries
  6. end
  7.  
  8. class Industry < ApplicationRecord
  9. has_and_belongs_to_many :profiles
  10. end
  11.  
  12. class Job < ApplicationRecord
  13. has_and_belongs_to_many :profiles
  14. end
  15.  
  16. class Skill < ApplicationRecord
  17. has_and_belongs_to_many :profiles
  18. end
  19.  
  20. profiles/index.html
  21.  
  22. <section class="top-search">
  23. <div class="container">
  24. <%= form_tag @filter, :method => :get do %>
  25. <%= select_tag "skills_id", options_from_collection_for_select(Skill.all, "id", "name"), prompt: "Specialized Skills" %>
  26. <%= select_tag "industries_id", options_from_collection_for_select(Industry.all, "id", "name"), prompt: "Industries" %>
  27. <%= select_tag "jobs_id", options_from_collection_for_select(Job.all, "id", "name"), prompt: "Job Functions" %>
  28. <%= submit_tag "Filter", name: nil, class:"btn btn-primary" %>
  29. <% end %>
  30. </div>
  31. </section>
  32.  
  33. <section class="search-result">
  34. <div class="container">
  35. <div class="row flex-container">
  36. <% @profiles.each do |profile| %>
  37. <div class="col-md-5 mentor-profile">
  38. <div class="media">
  39. <div class="media-left">
  40. <%= link_to profile do %>
  41. <%= image_tag profile.avatar.url(:thumb) %>
  42. <% end %>
  43. </div>
  44. <div class="media-body">
  45. <h4 class="media-heading">
  46. <%=link_to profile do %>
  47. <%= "#{profile.first_name }" " #{ profile.last_name}" %>
  48. <% end %>
  49. </h4>
  50. <strong>Works at <%= profile.company %></strong>
  51. <p><%= profile.city %>, <%= profile.country %></p>
  52. </div>
  53. </div>
  54. <div class="dvider"></div>
  55. <div class="profile-section">
  56. <h5>SUMMARY</h5>
  57. <p><%= profile.summary %></p>
  58. </div>
  59. <div class="profile-section">
  60. <h5>SPECIALIZED SKILLS</h5>
  61. <p><%= profile.skills.map(&:name).join(', ') %></p>
  62. </div>
  63. <div class="profile-section">
  64. <h5>CRITERIA MET</h5>
  65. <p>NEED TO WORK ON IT....</p>
  66. </div>
  67.  
  68. </div>
  69. <% end %>
  70. </div>
  71. </div>
  72. </section>
  73.  
  74. def filter
  75. @profiles = Profile.all
  76. @profiles = Profile.joins(:skills).where('skills.name = ?', params[:skill])
  77. @profiles = Profile.joins(:industries).where('industries.name = ?', params[:industry])
  78. @profiles = Profile.joins(:jobs).where('job.name = ?', params[:job])
  79. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement