Skip to content

Code generating script to turn a typeform into a Rails model

Notifications You must be signed in to change notification settings

simondobson/typeform-on-rails

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Welcome To Typeform on Rails!

Typeform on Rails is a CLI tool that gives you a quick way to generate some code to live in your Rails project so that your typeform can act as an ActiveRecord model.

How it works

You run the script with a typeform ID and it uses the Typeform Create API to get a JSON definition of the typeform, then it goes through each block in the typeform and maps the block type to a Rails type. Next it creates code that will be ready to set up a new ActiveRecord model, then using the IDs of the blocks it can generate code ready to save a submission of the typeform as a new instance of the model. Then all that is needed is to run the generated commands in your Rails project, insert the generated code and set up your Typeform with a Webhook to the generated URL.

Use Cases

Provide a personalised, up to date insight of your typeform results on your website. There can be many specific use cases of this, for example:

  • Events
    • Typeform: Event registration
    • Rails: Display who is going, how many spaces are left etc.
  • Live poll
    • Typeform: Quiz or survey
    • Rails: Display the answers as they are received in a nice format

Limitations & Pre requisites

Limitations:

  • Does not work for the following Typeform blocks:
    • Payment
    • Group

Pre requisites:

  • Rails 4 or above using ActiveRecord
  • Postgres as the Rails DB

Usage

  1. Clone the repository
  2. Run bundle install
  3. Set the environment variable TYPEFORM_API_TOKEN to one of your tokens
  4. Run the script with your typeform's ID as an argument, e.g. ruby typeform-on-rails.rb r95x3p
  5. Follow the command line instructions

You can run the script in interactive or normal mode, to run it in interactive mode add -i to the end of the line executing the script (step 4). This is useful and recommended so that you can define the names of the attributes and the model itself.

Example

You can look at an example (with example commits) here : https://github.com/simondobson/typeform-on-rails-example

Contributing

Please feel free to open a pull request!

About

Code generating script to turn a typeform into a Rails model

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages