Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Profile < ApplicationRecord
- belongs_to :user
- has_and_belongs_to_many :skills
- has_and_belongs_to_many :jobs
- has_and_belongs_to_many :industries
- end
- class Industry < ApplicationRecord
- has_and_belongs_to_many :profiles
- end
- class Job < ApplicationRecord
- has_and_belongs_to_many :profiles
- end
- class Skill < ApplicationRecord
- has_and_belongs_to_many :profiles
- end
- profiles/index.html
- <section class="top-search">
- <div class="container">
- <%= form_tag @filter, :method => :get do %>
- <%= select_tag "skills_id", options_from_collection_for_select(Skill.all, "id", "name"), prompt: "Specialized Skills" %>
- <%= select_tag "industries_id", options_from_collection_for_select(Industry.all, "id", "name"), prompt: "Industries" %>
- <%= select_tag "jobs_id", options_from_collection_for_select(Job.all, "id", "name"), prompt: "Job Functions" %>
- <%= submit_tag "Filter", name: nil, class:"btn btn-primary" %>
- <% end %>
- </div>
- </section>
- <section class="search-result">
- <div class="container">
- <div class="row flex-container">
- <% @profiles.each do |profile| %>
- <div class="col-md-5 mentor-profile">
- <div class="media">
- <div class="media-left">
- <%= link_to profile do %>
- <%= image_tag profile.avatar.url(:thumb) %>
- <% end %>
- </div>
- <div class="media-body">
- <h4 class="media-heading">
- <%=link_to profile do %>
- <%= "#{profile.first_name }" " #{ profile.last_name}" %>
- <% end %>
- </h4>
- <strong>Works at <%= profile.company %></strong>
- <p><%= profile.city %>, <%= profile.country %></p>
- </div>
- </div>
- <div class="dvider"></div>
- <div class="profile-section">
- <h5>SUMMARY</h5>
- <p><%= profile.summary %></p>
- </div>
- <div class="profile-section">
- <h5>SPECIALIZED SKILLS</h5>
- <p><%= profile.skills.map(&:name).join(', ') %></p>
- </div>
- <div class="profile-section">
- <h5>CRITERIA MET</h5>
- <p>NEED TO WORK ON IT....</p>
- </div>
- </div>
- <% end %>
- </div>
- </div>
- </section>
- def filter
- @profiles = Profile.all
- @profiles = Profile.joins(:skills).where('skills.name = ?', params[:skill])
- @profiles = Profile.joins(:industries).where('industries.name = ?', params[:industry])
- @profiles = Profile.joins(:jobs).where('job.name = ?', params[:job])
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement