No commit activity in last 3 years
No release in over 3 years
Makes it easy to add and edit forms programatically, specifying select, radio, checkbox, or string input, and recordings users' answers. Questions can be associated with specific objects or with string labels. A form template and controller are including for displaying questions and recording answers, and ActiveAdmin is supported for editing the questions and options on the back-end.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0
>= 3.2.11
 Project Readme

Questionable¶ ↑

Questionable is a Rails engine that make it easier to create and answer surveys through a web interface.

After creating assignments, questions and options, you can use the included partial template and controller for displaying the questions and recording your users’ answers.

Installation¶ ↑

Add Questionable to your Gemfile:

gem 'questionable_surveys'

or for the latest:

gem 'questionable_surveys', :git => 'git://github.com/bespokepost/questionable.git'

Then run:

bundle install
rake questionable:install:migrations
rake db:migrate

Add Questionable to your config/routes.rb:

mount Questionable::Engine, :at => 'questions'

Optionally add the following to app/assets/stylesheet/application.css:

*= require questionable

Usage¶ ↑

Create some questions¶ ↑

Create one or more Questions. Supported input_types include select, multiselect, radio, checkboxes, date, and string.

# input_type may be select, multiselect, radio, checkboxes, date, or string.
q = Questionable::Question.create(title: 'What is your favorite color?', input_type: 'select', note: 'This is important')

Add Options, unless input_type is ‘string’

q.options.create(title: 'Red',   position: 1)
q.options.create(title: 'Green', position: 2)
q.options.create(title: 'Blue',  position: 3)

Questions must be assigned a ‘subject’ before they are used. They subject can be either an object, via a polymorphic association, or something general like “preferences”, which we can pass here as a symbol or string.

e.g.

@product = Product.find(123)
Questionable::Assignment.create(question_id: q.id, subject: @product)

or

Questionable::Assignment.create(question_id: q.id, subject_type: 'preferences')

In your controller¶ ↑

Here’s how we fetch question-assignments for a particular symbol:

@assignments = Questionable::Assignment.with_subject(:preferences)

and here, for a product object:

@product = Product.find(params[:id])
@assignments = Questionable::Assignment.with_subject(@product)

In your view ¶ ↑

With HAML

= render partial: 'questionable/assignments/form', locals: { assignments: @assignments }

Or ERB

<%= render partial: 'questionable/assignments/form', locals: { assignments: @assignments } %>

Running Tests¶ ↑

rake spec

Author¶ ↑

Written by Nick Urban at Bespoke Post.

Licence¶ ↑

This project uses the MIT-LICENSE.