How to filter result dainamically in ruby on rails

38 views
Skip to first unread message

Mukto Mona

unread,
Jan 29, 2016, 9:47:40 AM1/29/16
to rubyonra...@googlegroups.com
I am a newbie in ruby on rails it's also my first ruby application.
I want to filter results by clicking on checkbox which is coming from
the database and showing on the right side of my webpage, the checkbox
is lying on the left side. In the below I attached my webpage's
screenshot for easy understanding. Anyone can help me, please, how can I
solve this issue.

Attachments:
http://www.ruby-forum.com/attachment/11247/FireShot_Pro_Screen_Capture__008_-__Total_Resumes_I_Hire_Bangladeshi__-_localhost_3000_resumes.png


--
Posted via http://www.ruby-forum.com/.

Scott Eisenberg

unread,
Jan 29, 2016, 9:58:11 AM1/29/16
to rubyonra...@googlegroups.com
Add some scopes to your model




The in the controller apply the scope if the parameters for the checkbox is present.

Not knowing your field names and form field names

model
 scope :education, ->(degree)  {where(education: degree)}


controller
@resumes = Resume.all
@resumes = @resumes.education(params[:degree]) if params[:degree].present?      #not really correct if you are using checkboxes I bet, but should give you an idea of where to start.




--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ac3900089c0b0bb48cb3a6734a44064d%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages