Ruby on Rails Friday, January 29, 2016

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.




On Jan 29, 2016, at 9:46 AM, Mukto Mona <lists@ruby-forum.com> wrote:

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/.

--
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-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@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.

No comments:

Post a Comment