Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

questionable_surveys

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

questionable_surveys

  • 0.3.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= Questionable

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

You can create your questions and options through the included {ActiveAdmin}[https://github.com/gregbell/active_admin] interface. If ActiveAdmin is installed in your application, Questionable will automatically add admin pages.

Then you can use the included partial template and controller for displaying the questions and recording your users' answers.

== Installation

For Rails 4:

gem 'questionable_surveys', '>= 0.3.0'

For Rails 3:

gem 'questionable_surveys', '~> 0.2.3'

Or get the latest:

gem 'questionable_surveys', github: 'bespokepost/questionable'

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, 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 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}[https://github.com/nickurban/] at {Bespoke Post}[https://www.bespokepost.com/].

== Licence

This project uses the MIT-LICENSE.

FAQs

Package last updated on 13 Nov 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc