-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
We'll now walk thorough the complete process for converting a node prototype, and then configuring the journey, for a new site dealing with a Cycle Licence.
Users will register via the site for a new cycle licence. To register we need to collect data from the user, over a number of pages.
This guide assumes a Rails app is already in place, with a basic model for collecting the data, called `Registration'
First, add these 2 gems into your Gemfile
gem "copy_kit",
git: "https://github.com/EnvironmentAgency/copykit",
branch: "master"
gem "datashift_journey",
git: "https://github.com/autotelik/datashift_journey",
branch: "master"Spend some time, working out what you want in terms of directory structure, modules and model
e.g top level module called CycleLicence
Use the copykit generator to create a project specific thor task, with a Copykit configuration block ready to be implemented
bundle exec thor copykit:generate_task_with_config cli cycle_licence_tasks -m CycleLicenceThis will create a convert CLI task,in module CycleLicence, with class Cli, for converting your node app :
`lib/tasks/cycle_licence_tasks.thor`
Which will be runnable as :
`bundle exec thor cycle_licence:cli:convert`
Edit the file to setup the Copykit configuration for your project
You can also set the thor method_option defaults for input and/or output paths to save specifying them each time.
For example
method_option :input, :aliases => '-i', default: '../my-prototype/app/views/' method_option :output, :aliases => '-o', default: './tmp/copy_kit/output'
Now you can generate your Rails prototype from node by running from your Rails app root
You will see lots of output detailing which files are being generated and the different locations they are copied to.
Now you can add the datashift journey planner
The app must inform datashift_journey of the model to host the journey plan and to store data collected on the journey.
This will be the parent model off which all the data to be collected should hang, the concept is like a Registration or Enrollment
So create a normal Rails model and associated migration
N.B Your journey class must have a string column called state i.e
class CreateEnrollments < ActiveRecord::Migration def change create_table :enrollments do |t| t.string :state t.timestamps null: false end
end end
Now inform datashift of the class to use
In config/initializers/datashift_journey.rb
DatashiftJourney.journey_plan_class = "Enrollment"
Ideas
Some good code here for adding code to a class via module_eval and code templates
https://github.com/refinery/refinerycms/blob/master/core/lib/refinery/crud.rb#L51
FLow
New - render initial state -> create