ruby on rails - ransack proper filter of searches in association models -


i have 2 models universityand course. there has_many through relationship between both.

i using ranstack search queries on university model following:

<%= search_form_for @search |f| %>   <div class="field">     <%= f.label :title_cont, "university name" %>     <%= f.text_field :title_cont %>   </div>   <div class="field">     <%= f.label :courses_course_type_in, "course type" %>     <%= f.select :courses_course_type_in,  course.course_type.options, {} %>   </div> <% end %> 

and in controller have:

@search = university.search(params[:q]) @universities = @search.result 

the :courses_course_type_in understood in query in sense universities offer specific type of courses(let's graduate courses).

but in other hand, when come display courses, @universities.courses contains courses of types available(graduate , undergrade, certificate, continuing education...).

is there easy way ( in ransack preferably ) wanted courses in @universities.courses ? (graduate in case)

thanks!

did try :

<%= f.select :courses_course_type_eq,  course.all.collect{|c| [c.course_type, c.course_type]} %> 

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -