← Back to Upcase

How to create check box fields with Simple Form?


(Julie Kent) #1

Hi,

I’m working on a Rails project. I am using Simple Form as well as Cocoon for nested forms. Users will create a profile, and then once of the nested forms is for “Specialties” and “Locations.” Right now, I just have both of those built as string fields. However, ideally I would like to list out the options and then users would select via a check-box.

The end goal is that I want to be able to let users search based on specialty or location and then pull up the profiles that include that specialty and/or location.

Any help would be appreciated.

My github repo is located here: https://github.com/jkent2910/gopupgo

Thanks,
Julie


(Jones Agyemang) #2

If this is a search feature then I don’t think you necessarily need two forms to handle different search facets, in which case if you were to add a new searchable entity then you will have to create yet another input field to toggle between all those fields.

Use ThinkingSphinx to index all your searchable fields
http://pat.github.io/thinking-sphinx/

Regards,
Jones


(Julie Kent) #3

Hi Jones,

Thank you so much for your reply. I briefly read through the “Quickstart” for Sphinx and it looks really cool!!! I’m a newbie to Rails so I guess here is my question…

I have two nested forms when a user creates a profile. One for location and one for specialty. I want to already have the options for what the user can select as checkboxes (they can check multiple locations and multiple specialties.) I am not sure how to do this - to have the options already showing and then make sure that these are then tying back to the database. I am using simple form and cocoon.

Ultimately, I want to have index.html.haml and show.html.haml for both “Specialty” and “Locations” that would show a list of all of the options for each, and then if you clicked on Running, for example, it will then show all of the profiles that checked that as their specialty.

Does that make sense?

Is Sphinx still something I can use? I feel like it is, but that there may be steps I need to take before that happens.

Thanks!
Julie