├── .gitignore ├── .rspec ├── Gemfile ├── Gemfile.lock ├── README.md ├── Rakefile ├── app.json ├── app ├── assets │ ├── config │ │ └── manifest.js │ ├── images │ │ └── .keep │ ├── javascripts │ │ ├── application.js │ │ ├── cable.js │ │ └── channels │ │ │ └── .keep │ └── stylesheets │ │ └── application.scss ├── channels │ └── application_cable │ │ ├── channel.rb │ │ └── connection.rb ├── controllers │ ├── application_controller.rb │ ├── concerns │ │ └── .keep │ ├── home_controller.rb │ └── wizards_controller.rb ├── form_models │ └── wizard │ │ └── user.rb ├── helpers │ └── application_helper.rb ├── jobs │ └── application_job.rb ├── mailers │ └── application_mailer.rb ├── models │ ├── application_record.rb │ ├── concerns │ │ └── .keep │ └── user.rb └── views │ ├── home │ └── index.html.erb │ ├── layouts │ ├── application.html.erb │ ├── mailer.html.erb │ └── mailer.text.erb │ └── wizards │ ├── step1.html.erb │ ├── step2.html.erb │ ├── step3.html.erb │ └── step4.html.erb ├── bin ├── bundle ├── rails ├── rake ├── rspec ├── setup └── update ├── config.ru ├── config ├── application.rb ├── boot.rb ├── cable.yml ├── database.yml ├── environment.rb ├── environments │ ├── development.rb │ ├── production.rb │ └── test.rb ├── initializers │ ├── application_controller_renderer.rb │ ├── assets.rb │ ├── backtrace_silencers.rb │ ├── cookies_serializer.rb │ ├── filter_parameter_logging.rb │ ├── inflections.rb │ ├── mime_types.rb │ ├── new_framework_defaults.rb │ ├── session_store.rb │ ├── simple_form.rb │ ├── simple_form_bootstrap.rb │ └── wrap_parameters.rb ├── locales │ ├── countries.en.rb │ ├── en.yml │ └── simple_form.en.yml ├── puma.rb ├── routes.rb ├── secrets.yml └── spring.rb ├── db ├── migrate │ └── 20161129002314_create_users.rb ├── schema.rb └── seeds.rb ├── lib ├── assets │ └── .keep ├── tasks │ └── .keep └── templates │ └── erb │ └── scaffold │ └── _form.html.erb ├── log └── .keep ├── public ├── 404.html ├── 422.html ├── 500.html ├── apple-touch-icon-precomposed.png ├── apple-touch-icon.png ├── favicon.ico └── robots.txt ├── spec ├── features │ └── user_creates_a_user_spec.rb ├── form_models │ └── wizard │ │ └── user_spec.rb ├── models │ └── user_spec.rb ├── rails_helper.rb └── spec_helper.rb ├── tmp └── .keep └── vendor └── assets ├── javascripts └── .keep └── stylesheets └── .keep /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore all logfiles and tempfiles. 11 | /log/* 12 | /tmp/* 13 | !/log/.keep 14 | !/tmp/.keep 15 | 16 | # Ignore Byebug command history file. 17 | .byebug_history 18 | 19 | db/*.sqlite3 20 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --require spec_helper 3 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | 4 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 5 | gem 'rails', '~> 5.0.0', '>= 5.0.0.1' 6 | 7 | # Use Puma as the app server 8 | gem 'puma', '~> 3.0' 9 | # Use SCSS for stylesheets 10 | gem 'sass-rails', '~> 5.0' 11 | # Use Uglifier as compressor for JavaScript assets 12 | gem 'uglifier', '>= 1.3.0' 13 | # Use CoffeeScript for .coffee assets and views 14 | gem 'coffee-rails', '~> 4.2' 15 | # See https://github.com/rails/execjs#readme for more supported runtimes 16 | # gem 'therubyracer', platforms: :ruby 17 | 18 | # Use jquery as the JavaScript library 19 | gem 'jquery-rails' 20 | # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 21 | gem 'turbolinks', '~> 5' 22 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 23 | gem 'jbuilder', '~> 2.5' 24 | 25 | gem 'bootstrap-sass', '~> 3.3.6' 26 | gem 'simple_form', '~> 3.3.1' 27 | gem 'localized_country_select' 28 | # Use Redis adapter to run Action Cable in production 29 | # gem 'redis', '~> 3.0' 30 | # Use ActiveModel has_secure_password 31 | # gem 'bcrypt', '~> 3.1.7' 32 | 33 | # Use Capistrano for deployment 34 | # gem 'capistrano-rails', group: :development 35 | 36 | group :production do 37 | gem 'pg' 38 | end 39 | 40 | group :development, :test do 41 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console 42 | gem 'byebug', platform: :mri 43 | gem 'rspec-rails', '~> 3.5' 44 | gem 'shoulda-matchers' 45 | gem 'capybara' 46 | gem 'sqlite3' 47 | end 48 | 49 | group :development do 50 | # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. 51 | gem 'web-console' 52 | gem 'listen', '~> 3.0.5' 53 | # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 54 | gem 'spring' 55 | gem 'spring-watcher-listen', '~> 2.0.0' 56 | end 57 | 58 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 59 | gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 60 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actioncable (5.0.0.1) 5 | actionpack (= 5.0.0.1) 6 | nio4r (~> 1.2) 7 | websocket-driver (~> 0.6.1) 8 | actionmailer (5.0.0.1) 9 | actionpack (= 5.0.0.1) 10 | actionview (= 5.0.0.1) 11 | activejob (= 5.0.0.1) 12 | mail (~> 2.5, >= 2.5.4) 13 | rails-dom-testing (~> 2.0) 14 | actionpack (5.0.0.1) 15 | actionview (= 5.0.0.1) 16 | activesupport (= 5.0.0.1) 17 | rack (~> 2.0) 18 | rack-test (~> 0.6.3) 19 | rails-dom-testing (~> 2.0) 20 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 21 | actionview (5.0.0.1) 22 | activesupport (= 5.0.0.1) 23 | builder (~> 3.1) 24 | erubis (~> 2.7.0) 25 | rails-dom-testing (~> 2.0) 26 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 27 | activejob (5.0.0.1) 28 | activesupport (= 5.0.0.1) 29 | globalid (>= 0.3.6) 30 | activemodel (5.0.0.1) 31 | activesupport (= 5.0.0.1) 32 | activerecord (5.0.0.1) 33 | activemodel (= 5.0.0.1) 34 | activesupport (= 5.0.0.1) 35 | arel (~> 7.0) 36 | activesupport (5.0.0.1) 37 | concurrent-ruby (~> 1.0, >= 1.0.2) 38 | i18n (~> 0.7) 39 | minitest (~> 5.1) 40 | tzinfo (~> 1.1) 41 | addressable (2.5.0) 42 | public_suffix (~> 2.0, >= 2.0.2) 43 | arel (7.1.4) 44 | autoprefixer-rails (6.5.3) 45 | execjs 46 | bootstrap-sass (3.3.7) 47 | autoprefixer-rails (>= 5.2.1) 48 | sass (>= 3.3.4) 49 | builder (3.2.2) 50 | byebug (9.0.6) 51 | capybara (2.10.1) 52 | addressable 53 | mime-types (>= 1.16) 54 | nokogiri (>= 1.3.3) 55 | rack (>= 1.0.0) 56 | rack-test (>= 0.5.4) 57 | xpath (~> 2.0) 58 | coffee-rails (4.2.1) 59 | coffee-script (>= 2.2.0) 60 | railties (>= 4.0.0, < 5.2.x) 61 | coffee-script (2.4.1) 62 | coffee-script-source 63 | execjs 64 | coffee-script-source (1.11.1) 65 | concurrent-ruby (1.0.2) 66 | debug_inspector (0.0.2) 67 | diff-lcs (1.2.5) 68 | erubis (2.7.0) 69 | execjs (2.7.0) 70 | ffi (1.9.14) 71 | globalid (0.3.7) 72 | activesupport (>= 4.1.0) 73 | i18n (0.7.0) 74 | jbuilder (2.6.1) 75 | activesupport (>= 3.0.0, < 5.1) 76 | multi_json (~> 1.2) 77 | jquery-rails (4.2.1) 78 | rails-dom-testing (>= 1, < 3) 79 | railties (>= 4.2.0) 80 | thor (>= 0.14, < 2.0) 81 | listen (3.0.8) 82 | rb-fsevent (~> 0.9, >= 0.9.4) 83 | rb-inotify (~> 0.9, >= 0.9.7) 84 | localized_country_select (0.9.11) 85 | actionpack (>= 3.0) 86 | loofah (2.0.3) 87 | nokogiri (>= 1.5.9) 88 | mail (2.6.4) 89 | mime-types (>= 1.16, < 4) 90 | method_source (0.8.2) 91 | mime-types (3.1) 92 | mime-types-data (~> 3.2015) 93 | mime-types-data (3.2016.0521) 94 | mini_portile2 (2.1.0) 95 | minitest (5.9.1) 96 | multi_json (1.12.1) 97 | nio4r (1.2.1) 98 | nokogiri (1.6.8.1) 99 | mini_portile2 (~> 2.1.0) 100 | pg (0.19.0) 101 | public_suffix (2.0.4) 102 | puma (3.6.2) 103 | rack (2.0.1) 104 | rack-test (0.6.3) 105 | rack (>= 1.0) 106 | rails (5.0.0.1) 107 | actioncable (= 5.0.0.1) 108 | actionmailer (= 5.0.0.1) 109 | actionpack (= 5.0.0.1) 110 | actionview (= 5.0.0.1) 111 | activejob (= 5.0.0.1) 112 | activemodel (= 5.0.0.1) 113 | activerecord (= 5.0.0.1) 114 | activesupport (= 5.0.0.1) 115 | bundler (>= 1.3.0, < 2.0) 116 | railties (= 5.0.0.1) 117 | sprockets-rails (>= 2.0.0) 118 | rails-dom-testing (2.0.1) 119 | activesupport (>= 4.2.0, < 6.0) 120 | nokogiri (~> 1.6.0) 121 | rails-html-sanitizer (1.0.3) 122 | loofah (~> 2.0) 123 | railties (5.0.0.1) 124 | actionpack (= 5.0.0.1) 125 | activesupport (= 5.0.0.1) 126 | method_source 127 | rake (>= 0.8.7) 128 | thor (>= 0.18.1, < 2.0) 129 | rake (11.3.0) 130 | rb-fsevent (0.9.8) 131 | rb-inotify (0.9.7) 132 | ffi (>= 0.5.0) 133 | rspec-core (3.5.4) 134 | rspec-support (~> 3.5.0) 135 | rspec-expectations (3.5.0) 136 | diff-lcs (>= 1.2.0, < 2.0) 137 | rspec-support (~> 3.5.0) 138 | rspec-mocks (3.5.0) 139 | diff-lcs (>= 1.2.0, < 2.0) 140 | rspec-support (~> 3.5.0) 141 | rspec-rails (3.5.2) 142 | actionpack (>= 3.0) 143 | activesupport (>= 3.0) 144 | railties (>= 3.0) 145 | rspec-core (~> 3.5.0) 146 | rspec-expectations (~> 3.5.0) 147 | rspec-mocks (~> 3.5.0) 148 | rspec-support (~> 3.5.0) 149 | rspec-support (3.5.0) 150 | sass (3.4.22) 151 | sass-rails (5.0.6) 152 | railties (>= 4.0.0, < 6) 153 | sass (~> 3.1) 154 | sprockets (>= 2.8, < 4.0) 155 | sprockets-rails (>= 2.0, < 4.0) 156 | tilt (>= 1.1, < 3) 157 | shoulda-matchers (3.1.1) 158 | activesupport (>= 4.0.0) 159 | simple_form (3.3.1) 160 | actionpack (> 4, < 5.1) 161 | activemodel (> 4, < 5.1) 162 | spring (2.0.0) 163 | activesupport (>= 4.2) 164 | spring-watcher-listen (2.0.1) 165 | listen (>= 2.7, < 4.0) 166 | spring (>= 1.2, < 3.0) 167 | sprockets (3.7.0) 168 | concurrent-ruby (~> 1.0) 169 | rack (> 1, < 3) 170 | sprockets-rails (3.2.0) 171 | actionpack (>= 4.0) 172 | activesupport (>= 4.0) 173 | sprockets (>= 3.0.0) 174 | sqlite3 (1.3.12) 175 | thor (0.19.4) 176 | thread_safe (0.3.5) 177 | tilt (2.0.5) 178 | turbolinks (5.0.1) 179 | turbolinks-source (~> 5) 180 | turbolinks-source (5.0.0) 181 | tzinfo (1.2.2) 182 | thread_safe (~> 0.1) 183 | uglifier (3.0.3) 184 | execjs (>= 0.3.0, < 3) 185 | web-console (3.4.0) 186 | actionview (>= 5.0) 187 | activemodel (>= 5.0) 188 | debug_inspector 189 | railties (>= 5.0) 190 | websocket-driver (0.6.4) 191 | websocket-extensions (>= 0.1.0) 192 | websocket-extensions (0.1.2) 193 | xpath (2.0.0) 194 | nokogiri (~> 1.3) 195 | 196 | PLATFORMS 197 | ruby 198 | 199 | DEPENDENCIES 200 | bootstrap-sass (~> 3.3.6) 201 | byebug 202 | capybara 203 | coffee-rails (~> 4.2) 204 | jbuilder (~> 2.5) 205 | jquery-rails 206 | listen (~> 3.0.5) 207 | localized_country_select 208 | pg 209 | puma (~> 3.0) 210 | rails (~> 5.0.0, >= 5.0.0.1) 211 | rspec-rails (~> 3.5) 212 | sass-rails (~> 5.0) 213 | shoulda-matchers 214 | simple_form (~> 3.3.1) 215 | spring 216 | spring-watcher-listen (~> 2.0.0) 217 | sqlite3 218 | turbolinks (~> 5) 219 | tzinfo-data 220 | uglifier (>= 1.3.0) 221 | web-console 222 | 223 | BUNDLED WITH 224 | 1.13.6 225 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | Wizard app example using session storage until the last step of the wizard is completed. 4 | 5 | Deploy this app for free in one click on your Heroku account to test it by clicking this button: 6 | 7 | [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/nicolasblanco/wizard_app) 8 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require_relative 'config/application' 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Rails Wizard App Sample", 3 | "description": "An example of a static wizard using Rails 5", 4 | "repository": "https://github.com/nicolasblanco/wizard_app", 5 | "keywords": ["ruby", "rails"], 6 | "success_url": "/", 7 | "scripts": { 8 | "postdeploy": "bundle exec rails db:migrate" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /app/assets/config/manifest.js: -------------------------------------------------------------------------------- 1 | //= link_tree ../images 2 | //= link_directory ../javascripts .js 3 | //= link_directory ../stylesheets .css 4 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicolasblanco/wizard_app/6f0ba8fbc67d6e68afdd0a1767b93aa86c30732a/app/assets/images/.keep -------------------------------------------------------------------------------- /app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files 2 | // listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 5 | // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. 6 | // 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8 | // compiled file. JavaScript code in this file should be added after the last require_* statement. 9 | // 10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 11 | // about supported directives. 12 | // 13 | //= require jquery 14 | //= require jquery_ujs 15 | //= require bootstrap-sprockets 16 | -------------------------------------------------------------------------------- /app/assets/javascripts/cable.js: -------------------------------------------------------------------------------- 1 | // Action Cable provides the framework to deal with WebSockets in Rails. 2 | // You can generate new channels where WebSocket features live using the rails generate channel command. 3 | // 4 | //= require action_cable 5 | //= require_self 6 | //= require_tree ./channels 7 | 8 | (function() { 9 | this.App || (this.App = {}); 10 | 11 | App.cable = ActionCable.createConsumer(); 12 | 13 | }).call(this); 14 | -------------------------------------------------------------------------------- /app/assets/javascripts/channels/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicolasblanco/wizard_app/6f0ba8fbc67d6e68afdd0a1767b93aa86c30732a/app/assets/javascripts/channels/.keep -------------------------------------------------------------------------------- /app/assets/stylesheets/application.scss: -------------------------------------------------------------------------------- 1 | @import "bootstrap-sprockets"; 2 | @import "bootstrap"; 3 | -------------------------------------------------------------------------------- /app/channels/application_cable/channel.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Channel < ActionCable::Channel::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/channels/application_cable/connection.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Connection < ActionCable::Connection::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | protect_from_forgery with: :exception 3 | end 4 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicolasblanco/wizard_app/6f0ba8fbc67d6e68afdd0a1767b93aa86c30732a/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /app/controllers/home_controller.rb: -------------------------------------------------------------------------------- 1 | class HomeController < ApplicationController 2 | def index 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/controllers/wizards_controller.rb: -------------------------------------------------------------------------------- 1 | class WizardsController < ApplicationController 2 | before_action :load_user_wizard, except: %i(validate_step) 3 | 4 | def validate_step 5 | current_step = params[:current_step] 6 | 7 | @user_wizard = wizard_user_for_step(current_step) 8 | @user_wizard.user.attributes = user_wizard_params 9 | session[:user_attributes] = @user_wizard.user.attributes 10 | 11 | if @user_wizard.valid? 12 | next_step = wizard_user_next_step(current_step) 13 | create and return unless next_step 14 | 15 | redirect_to action: next_step 16 | else 17 | render current_step 18 | end 19 | end 20 | 21 | def create 22 | if @user_wizard.user.save 23 | session[:user_attributes] = nil 24 | redirect_to root_path, notice: 'User succesfully created!' 25 | else 26 | redirect_to({ action: Wizard::User::STEPS.first }, alert: 'There were a problem when creating the user.') 27 | end 28 | end 29 | 30 | private 31 | 32 | def load_user_wizard 33 | @user_wizard = wizard_user_for_step(action_name) 34 | end 35 | 36 | def wizard_user_next_step(step) 37 | Wizard::User::STEPS[Wizard::User::STEPS.index(step) + 1] 38 | end 39 | 40 | def wizard_user_for_step(step) 41 | raise InvalidStep unless step.in?(Wizard::User::STEPS) 42 | 43 | "Wizard::User::#{step.camelize}".constantize.new(session[:user_attributes]) 44 | end 45 | 46 | def user_wizard_params 47 | params.require(:user_wizard).permit(:email, :first_name, :last_name, :address_1, :address_2, :zip_code, :city, :country, :phone_number) 48 | end 49 | 50 | class InvalidStep < StandardError; end 51 | end 52 | -------------------------------------------------------------------------------- /app/form_models/wizard/user.rb: -------------------------------------------------------------------------------- 1 | module Wizard 2 | module User 3 | STEPS = %w(step1 step2 step3 step4).freeze 4 | 5 | class Base 6 | include ActiveModel::Model 7 | attr_accessor :user 8 | 9 | delegate *::User.attribute_names.map { |attr| [attr, "#{attr}="] }.flatten, to: :user 10 | 11 | def initialize(user_attributes) 12 | @user = ::User.new(user_attributes) 13 | end 14 | end 15 | 16 | class Step1 < Base 17 | validates :email, presence: true, format: { with: /@/ } 18 | end 19 | 20 | class Step2 < Step1 21 | validates :first_name, presence: true 22 | validates :last_name, presence: true 23 | end 24 | 25 | class Step3 < Step2 26 | validates :address_1, presence: true 27 | validates :zip_code, presence: true 28 | validates :city, presence: true 29 | validates :country, presence: true 30 | end 31 | 32 | class Step4 < Step3 33 | validates :phone_number, presence: true 34 | end 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | end 3 | -------------------------------------------------------------------------------- /app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: 'from@example.com' 3 | layout 'mailer' 4 | end 5 | -------------------------------------------------------------------------------- /app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | self.abstract_class = true 3 | end 4 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicolasblanco/wizard_app/6f0ba8fbc67d6e68afdd0a1767b93aa86c30732a/app/models/concerns/.keep -------------------------------------------------------------------------------- /app/models/user.rb: -------------------------------------------------------------------------------- 1 | class User < ApplicationRecord 2 | validates :email, presence: true, format: { with: /@/ } 3 | validates :first_name, presence: true 4 | validates :last_name, presence: true 5 | validates :address_1, presence: true 6 | validates :zip_code, presence: true 7 | validates :city, presence: true 8 | validates :country, presence: true 9 | validates :phone_number, presence: true 10 | end 11 | -------------------------------------------------------------------------------- /app/views/home/index.html.erb: -------------------------------------------------------------------------------- 1 |

User wizard

2 | 3 | <%= link_to "Create a user", step1_wizard_path, class: 'btn btn-success' %> 4 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WizardApp 5 | <%= csrf_meta_tags %> 6 | 7 | <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> 8 | <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> 9 | 10 | 11 | 12 |
13 | <% if flash[:alert] %>
<%= flash[:alert] %>
<% end %> 14 | <% if flash[:notice] %>
<%= flash[:notice] %>
<% end %> 15 | 16 | <%= yield %> 17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | -------------------------------------------------------------------------------- /app/views/wizards/step1.html.erb: -------------------------------------------------------------------------------- 1 | 7 | 8 | <%= simple_form_for @user_wizard, as: :user_wizard, url: validate_step_wizard_path do |f| %> 9 | <%= f.error_notification %> 10 | 11 | <%= hidden_field_tag :current_step, 'step1' %> 12 | <%= f.input :email %> 13 | 14 | <%= f.submit 'Continue' %> 15 | <% end %> 16 | -------------------------------------------------------------------------------- /app/views/wizards/step2.html.erb: -------------------------------------------------------------------------------- 1 | 7 | 8 | <%= simple_form_for @user_wizard, as: :user_wizard, url: validate_step_wizard_path do |f| %> 9 | <%= f.error_notification %> 10 | 11 | <%= hidden_field_tag :current_step, 'step2' %> 12 | <%= f.input :first_name %> 13 | <%= f.input :last_name %> 14 | 15 | <%= f.submit 'Continue' %> 16 | <% end %> 17 | -------------------------------------------------------------------------------- /app/views/wizards/step3.html.erb: -------------------------------------------------------------------------------- 1 | 7 | 8 | <%= simple_form_for @user_wizard, as: :user_wizard, url: validate_step_wizard_path do |f| %> 9 | <%= f.error_notification %> 10 | 11 | <%= hidden_field_tag :current_step, 'step3' %> 12 | <%= f.input :address_1 %> 13 | <%= f.input :address_2 %> 14 | <%= f.input :zip_code %> 15 | <%= f.input :city %> 16 | <%= f.input :country %> 17 | 18 | <%= f.submit 'Continue' %> 19 | <% end %> 20 | -------------------------------------------------------------------------------- /app/views/wizards/step4.html.erb: -------------------------------------------------------------------------------- 1 | 7 | 8 | <%= simple_form_for @user_wizard, as: :user_wizard, url: validate_step_wizard_path do |f| %> 9 | <%= f.error_notification %> 10 | 11 | <%= hidden_field_tag :current_step, 'step4' %> 12 | <%= f.input :phone_number %> 13 | 14 | <%= f.submit 'Finish' %> 15 | <% end %> 16 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path('../config/application', __dir__) 3 | require_relative '../config/boot' 4 | require 'rails/commands' 5 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative '../config/boot' 3 | require 'rake' 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /bin/rspec: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | # 4 | # This file was generated by Bundler. 5 | # 6 | # The application 'rspec' is installed as part of a gem, and 7 | # this file is here to facilitate running it. 8 | # 9 | 10 | require "pathname" 11 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", 12 | Pathname.new(__FILE__).realpath) 13 | 14 | require "rubygems" 15 | require "bundler/setup" 16 | 17 | load Gem.bin_path("rspec-core", "rspec") 18 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pathname' 3 | require 'fileutils' 4 | include FileUtils 5 | 6 | # path to your application root. 7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) 8 | 9 | def system!(*args) 10 | system(*args) || abort("\n== Command #{args} failed ==") 11 | end 12 | 13 | chdir APP_ROOT do 14 | # This script is a starting point to setup your application. 15 | # Add necessary setup steps to this file. 16 | 17 | puts '== Installing dependencies ==' 18 | system! 'gem install bundler --conservative' 19 | system('bundle check') || system!('bundle install') 20 | 21 | # puts "\n== Copying sample files ==" 22 | # unless File.exist?('config/database.yml') 23 | # cp 'config/database.yml.sample', 'config/database.yml' 24 | # end 25 | 26 | puts "\n== Preparing database ==" 27 | system! 'bin/rails db:setup' 28 | 29 | puts "\n== Removing old logs and tempfiles ==" 30 | system! 'bin/rails log:clear tmp:clear' 31 | 32 | puts "\n== Restarting application server ==" 33 | system! 'bin/rails restart' 34 | end 35 | -------------------------------------------------------------------------------- /bin/update: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pathname' 3 | require 'fileutils' 4 | include FileUtils 5 | 6 | # path to your application root. 7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) 8 | 9 | def system!(*args) 10 | system(*args) || abort("\n== Command #{args} failed ==") 11 | end 12 | 13 | chdir APP_ROOT do 14 | # This script is a way to update your development environment automatically. 15 | # Add necessary update steps to this file. 16 | 17 | puts '== Installing dependencies ==' 18 | system! 'gem install bundler --conservative' 19 | system('bundle check') || system!('bundle install') 20 | 21 | puts "\n== Updating database ==" 22 | system! 'bin/rails db:migrate' 23 | 24 | puts "\n== Removing old logs and tempfiles ==" 25 | system! 'bin/rails log:clear tmp:clear' 26 | 27 | puts "\n== Restarting application server ==" 28 | system! 'bin/rails restart' 29 | end 30 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative 'config/environment' 4 | 5 | run Rails.application 6 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative 'boot' 2 | 3 | require 'rails/all' 4 | 5 | # Require the gems listed in Gemfile, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(*Rails.groups) 8 | 9 | module WizardApp 10 | class Application < Rails::Application 11 | # Settings in config/environments/* take precedence over those specified here. 12 | # Application configuration should go into files in config/initializers 13 | # -- all .rb files in that directory are automatically loaded. 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: async 6 | 7 | production: 8 | adapter: redis 9 | url: redis://localhost:6379/1 10 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite version 3.x 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem 'sqlite3' 6 | # 7 | default: &default 8 | adapter: sqlite3 9 | pool: 5 10 | timeout: 5000 11 | 12 | development: 13 | <<: *default 14 | database: db/development.sqlite3 15 | 16 | # Warning: The database defined as "test" will be erased and 17 | # re-generated from your development database when you run "rake". 18 | # Do not set this db to the same as development or production. 19 | test: 20 | <<: *default 21 | database: db/test.sqlite3 22 | 23 | production: 24 | <<: *default 25 | database: db/production.sqlite3 26 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative 'application' 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports. 13 | config.consider_all_requests_local = true 14 | 15 | # Enable/disable caching. By default caching is disabled. 16 | if Rails.root.join('tmp/caching-dev.txt').exist? 17 | config.action_controller.perform_caching = true 18 | 19 | config.cache_store = :memory_store 20 | config.public_file_server.headers = { 21 | 'Cache-Control' => 'public, max-age=172800' 22 | } 23 | else 24 | config.action_controller.perform_caching = false 25 | 26 | config.cache_store = :null_store 27 | end 28 | 29 | # Don't care if the mailer can't send. 30 | config.action_mailer.raise_delivery_errors = false 31 | 32 | config.action_mailer.perform_caching = false 33 | 34 | # Print deprecation notices to the Rails logger. 35 | config.active_support.deprecation = :log 36 | 37 | # Debug mode disables concatenation and preprocessing of assets. 38 | # This option may cause significant delays in view rendering with a large 39 | # number of complex assets. 40 | config.assets.debug = true 41 | 42 | # Suppress logger output for asset requests. 43 | config.assets.quiet = true 44 | 45 | # Raises error for missing translations 46 | # config.action_view.raise_on_missing_translations = true 47 | 48 | # Use an evented file watcher to asynchronously detect changes in source code, 49 | # routes, locales, etc. This feature depends on the listen gem. 50 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker 51 | end 52 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Code is not reloaded between requests. 5 | config.cache_classes = true 6 | 7 | # Eager load code on boot. This eager loads most of Rails and 8 | # your application in memory, allowing both threaded web servers 9 | # and those relying on copy on write to perform better. 10 | # Rake tasks automatically ignore this option for performance. 11 | config.eager_load = true 12 | 13 | # Full error reports are disabled and caching is turned on. 14 | config.consider_all_requests_local = false 15 | config.action_controller.perform_caching = true 16 | 17 | # Disable serving static files from the `/public` folder by default since 18 | # Apache or NGINX already handles this. 19 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? 20 | 21 | # Compress JavaScripts and CSS. 22 | config.assets.js_compressor = :uglifier 23 | # config.assets.css_compressor = :sass 24 | 25 | # Do not fallback to assets pipeline if a precompiled asset is missed. 26 | config.assets.compile = false 27 | 28 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb 29 | 30 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 31 | # config.action_controller.asset_host = 'http://assets.example.com' 32 | 33 | # Specifies the header that your server uses for sending files. 34 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 35 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 36 | 37 | # Mount Action Cable outside main process or domain 38 | # config.action_cable.mount_path = nil 39 | # config.action_cable.url = 'wss://example.com/cable' 40 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] 41 | 42 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 43 | # config.force_ssl = true 44 | 45 | # Use the lowest log level to ensure availability of diagnostic information 46 | # when problems arise. 47 | config.log_level = :debug 48 | 49 | # Prepend all log lines with the following tags. 50 | config.log_tags = [ :request_id ] 51 | 52 | # Use a different cache store in production. 53 | # config.cache_store = :mem_cache_store 54 | 55 | # Use a real queuing backend for Active Job (and separate queues per environment) 56 | # config.active_job.queue_adapter = :resque 57 | # config.active_job.queue_name_prefix = "wizard_app_#{Rails.env}" 58 | config.action_mailer.perform_caching = false 59 | 60 | # Ignore bad email addresses and do not raise email delivery errors. 61 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 62 | # config.action_mailer.raise_delivery_errors = false 63 | 64 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 65 | # the I18n.default_locale when a translation cannot be found). 66 | config.i18n.fallbacks = true 67 | 68 | # Send deprecation notices to registered listeners. 69 | config.active_support.deprecation = :notify 70 | 71 | # Use default logging formatter so that PID and timestamp are not suppressed. 72 | config.log_formatter = ::Logger::Formatter.new 73 | 74 | # Use a different logger for distributed setups. 75 | # require 'syslog/logger' 76 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') 77 | 78 | if ENV["RAILS_LOG_TO_STDOUT"].present? 79 | logger = ActiveSupport::Logger.new(STDOUT) 80 | logger.formatter = config.log_formatter 81 | config.logger = ActiveSupport::TaggedLogging.new(logger) 82 | end 83 | end 84 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure public file server for tests with Cache-Control for performance. 16 | config.public_file_server.enabled = true 17 | config.public_file_server.headers = { 18 | 'Cache-Control' => 'public, max-age=3600' 19 | } 20 | 21 | # Show full error reports and disable caching. 22 | config.consider_all_requests_local = true 23 | config.action_controller.perform_caching = false 24 | 25 | # Raise exceptions instead of rendering exception templates. 26 | config.action_dispatch.show_exceptions = false 27 | 28 | # Disable request forgery protection in test environment. 29 | config.action_controller.allow_forgery_protection = false 30 | config.action_mailer.perform_caching = false 31 | 32 | # Tell Action Mailer not to deliver emails to the real world. 33 | # The :test delivery method accumulates sent emails in the 34 | # ActionMailer::Base.deliveries array. 35 | config.action_mailer.delivery_method = :test 36 | 37 | # Print deprecation notices to the stderr. 38 | config.active_support.deprecation = :stderr 39 | 40 | # Raises error for missing translations 41 | # config.action_view.raise_on_missing_translations = true 42 | end 43 | -------------------------------------------------------------------------------- /config/initializers/application_controller_renderer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # ApplicationController.renderer.defaults.merge!( 4 | # http_host: 'example.org', 5 | # https: false 6 | # ) 7 | -------------------------------------------------------------------------------- /config/initializers/assets.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Version of your assets, change this if you want to expire all your assets. 4 | Rails.application.config.assets.version = '1.0' 5 | 6 | # Add additional assets to the asset load path 7 | # Rails.application.config.assets.paths << Emoji.images_path 8 | 9 | # Precompile additional assets. 10 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. 11 | # Rails.application.config.assets.precompile += %w( search.js ) 12 | -------------------------------------------------------------------------------- /config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Specify a serializer for the signed and encrypted cookie jars. 4 | # Valid options are :json, :marshal, and :hybrid. 5 | Rails.application.config.action_dispatch.cookies_serializer = :json 6 | -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /config/initializers/new_framework_defaults.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | # 3 | # This file contains migration options to ease your Rails 5.0 upgrade. 4 | # 5 | # Read the Rails 5.0 release notes for more info on each option. 6 | 7 | # Enable per-form CSRF tokens. Previous versions had false. 8 | Rails.application.config.action_controller.per_form_csrf_tokens = true 9 | 10 | # Enable origin-checking CSRF mitigation. Previous versions had false. 11 | Rails.application.config.action_controller.forgery_protection_origin_check = true 12 | 13 | # Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`. 14 | # Previous versions had false. 15 | ActiveSupport.to_time_preserves_timezone = true 16 | 17 | # Do not halt callback chains when a callback returns false. Previous versions had true. 18 | ActiveSupport.halt_callback_chains_on_return_false = false 19 | 20 | # Configure SSL options to enable HSTS with subdomains. Previous versions had false. 21 | Rails.application.config.ssl_options = { hsts: { subdomains: true } } 22 | -------------------------------------------------------------------------------- /config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_wizard_app_session' 4 | -------------------------------------------------------------------------------- /config/initializers/simple_form.rb: -------------------------------------------------------------------------------- 1 | # Use this setup block to configure all options available in SimpleForm. 2 | SimpleForm.setup do |config| 3 | # Wrappers are used by the form builder to generate a 4 | # complete input. You can remove any component from the 5 | # wrapper, change the order or even add your own to the 6 | # stack. The options given below are used to wrap the 7 | # whole input. 8 | config.wrappers :default, class: :input, 9 | hint_class: :field_with_hint, error_class: :field_with_errors do |b| 10 | ## Extensions enabled by default 11 | # Any of these extensions can be disabled for a 12 | # given input by passing: `f.input EXTENSION_NAME => false`. 13 | # You can make any of these extensions optional by 14 | # renaming `b.use` to `b.optional`. 15 | 16 | # Determines whether to use HTML5 (:email, :url, ...) 17 | # and required attributes 18 | b.use :html5 19 | 20 | # Calculates placeholders automatically from I18n 21 | # You can also pass a string as f.input placeholder: "Placeholder" 22 | b.use :placeholder 23 | 24 | ## Optional extensions 25 | # They are disabled unless you pass `f.input EXTENSION_NAME => true` 26 | # to the input. If so, they will retrieve the values from the model 27 | # if any exists. If you want to enable any of those 28 | # extensions by default, you can change `b.optional` to `b.use`. 29 | 30 | # Calculates maxlength from length validations for string inputs 31 | b.optional :maxlength 32 | 33 | # Calculates pattern from format validations for string inputs 34 | b.optional :pattern 35 | 36 | # Calculates min and max from length validations for numeric inputs 37 | b.optional :min_max 38 | 39 | # Calculates readonly automatically from readonly attributes 40 | b.optional :readonly 41 | 42 | ## Inputs 43 | b.use :label_input 44 | b.use :hint, wrap_with: { tag: :span, class: :hint } 45 | b.use :error, wrap_with: { tag: :span, class: :error } 46 | 47 | ## full_messages_for 48 | # If you want to display the full error message for the attribute, you can 49 | # use the component :full_error, like: 50 | # 51 | # b.use :full_error, wrap_with: { tag: :span, class: :error } 52 | end 53 | 54 | # The default wrapper to be used by the FormBuilder. 55 | config.default_wrapper = :default 56 | 57 | # Define the way to render check boxes / radio buttons with labels. 58 | # Defaults to :nested for bootstrap config. 59 | # inline: input + label 60 | # nested: label > input 61 | config.boolean_style = :nested 62 | 63 | # Default class for buttons 64 | config.button_class = 'btn' 65 | 66 | # Method used to tidy up errors. Specify any Rails Array method. 67 | # :first lists the first message for each field. 68 | # Use :to_sentence to list all errors for each field. 69 | # config.error_method = :first 70 | 71 | # Default tag used for error notification helper. 72 | config.error_notification_tag = :div 73 | 74 | # CSS class to add for error notification helper. 75 | config.error_notification_class = 'error_notification' 76 | 77 | # ID to add for error notification helper. 78 | # config.error_notification_id = nil 79 | 80 | # Series of attempts to detect a default label method for collection. 81 | # config.collection_label_methods = [ :to_label, :name, :title, :to_s ] 82 | 83 | # Series of attempts to detect a default value method for collection. 84 | # config.collection_value_methods = [ :id, :to_s ] 85 | 86 | # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none. 87 | # config.collection_wrapper_tag = nil 88 | 89 | # You can define the class to use on all collection wrappers. Defaulting to none. 90 | # config.collection_wrapper_class = nil 91 | 92 | # You can wrap each item in a collection of radio/check boxes with a tag, 93 | # defaulting to :span. 94 | # config.item_wrapper_tag = :span 95 | 96 | # You can define a class to use in all item wrappers. Defaulting to none. 97 | # config.item_wrapper_class = nil 98 | 99 | # How the label text should be generated altogether with the required text. 100 | # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" } 101 | 102 | # You can define the class to use on all labels. Default is nil. 103 | # config.label_class = nil 104 | 105 | # You can define the default class to be used on forms. Can be overriden 106 | # with `html: { :class }`. Defaulting to none. 107 | # config.default_form_class = nil 108 | 109 | # You can define which elements should obtain additional classes 110 | # config.generate_additional_classes_for = [:wrapper, :label, :input] 111 | 112 | # Whether attributes are required by default (or not). Default is true. 113 | # config.required_by_default = true 114 | 115 | # Tell browsers whether to use the native HTML5 validations (novalidate form option). 116 | # These validations are enabled in SimpleForm's internal config but disabled by default 117 | # in this configuration, which is recommended due to some quirks from different browsers. 118 | # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations, 119 | # change this configuration to true. 120 | config.browser_validations = false 121 | 122 | # Collection of methods to detect if a file type was given. 123 | # config.file_methods = [ :mounted_as, :file?, :public_filename ] 124 | 125 | # Custom mappings for input types. This should be a hash containing a regexp 126 | # to match as key, and the input type that will be used when the field name 127 | # matches the regexp as value. 128 | # config.input_mappings = { /count/ => :integer } 129 | 130 | # Custom wrappers for input types. This should be a hash containing an input 131 | # type as key and the wrapper that will be used for all inputs with specified type. 132 | # config.wrapper_mappings = { string: :prepend } 133 | 134 | # Namespaces where SimpleForm should look for custom input classes that 135 | # override default inputs. 136 | # config.custom_inputs_namespaces << "CustomInputs" 137 | 138 | # Default priority for time_zone inputs. 139 | # config.time_zone_priority = nil 140 | 141 | # Default priority for country inputs. 142 | # config.country_priority = nil 143 | 144 | # When false, do not use translations for labels. 145 | # config.translate_labels = true 146 | 147 | # Automatically discover new inputs in Rails' autoload path. 148 | # config.inputs_discovery = true 149 | 150 | # Cache SimpleForm inputs discovery 151 | # config.cache_discovery = !Rails.env.development? 152 | 153 | # Default class for inputs 154 | # config.input_class = nil 155 | 156 | # Define the default class of the input wrapper of the boolean input. 157 | config.boolean_label_class = 'checkbox' 158 | 159 | # Defines if the default input wrapper class should be included in radio 160 | # collection wrappers. 161 | # config.include_default_input_wrapper_class = true 162 | 163 | # Defines which i18n scope will be used in Simple Form. 164 | # config.i18n_scope = 'simple_form' 165 | end 166 | -------------------------------------------------------------------------------- /config/initializers/simple_form_bootstrap.rb: -------------------------------------------------------------------------------- 1 | # Use this setup block to configure all options available in SimpleForm. 2 | SimpleForm.setup do |config| 3 | config.error_notification_class = 'alert alert-danger' 4 | config.button_class = 'btn btn-default' 5 | config.boolean_label_class = nil 6 | 7 | config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| 8 | b.use :html5 9 | b.use :placeholder 10 | b.optional :maxlength 11 | b.optional :pattern 12 | b.optional :min_max 13 | b.optional :readonly 14 | b.use :label, class: 'control-label' 15 | 16 | b.use :input, class: 'form-control' 17 | b.use :error, wrap_with: { tag: 'span', class: 'help-block' } 18 | b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } 19 | end 20 | 21 | config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| 22 | b.use :html5 23 | b.use :placeholder 24 | b.optional :maxlength 25 | b.optional :readonly 26 | b.use :label, class: 'control-label' 27 | 28 | b.use :input 29 | b.use :error, wrap_with: { tag: 'span', class: 'help-block' } 30 | b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } 31 | end 32 | 33 | config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| 34 | b.use :html5 35 | b.optional :readonly 36 | 37 | b.wrapper tag: 'div', class: 'checkbox' do |ba| 38 | ba.use :label_input 39 | end 40 | 41 | b.use :error, wrap_with: { tag: 'span', class: 'help-block' } 42 | b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } 43 | end 44 | 45 | config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| 46 | b.use :html5 47 | b.optional :readonly 48 | b.use :label, class: 'control-label' 49 | b.use :input 50 | b.use :error, wrap_with: { tag: 'span', class: 'help-block' } 51 | b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } 52 | end 53 | 54 | config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| 55 | b.use :html5 56 | b.use :placeholder 57 | b.optional :maxlength 58 | b.optional :pattern 59 | b.optional :min_max 60 | b.optional :readonly 61 | b.use :label, class: 'col-sm-3 control-label' 62 | 63 | b.wrapper tag: 'div', class: 'col-sm-9' do |ba| 64 | ba.use :input, class: 'form-control' 65 | ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } 66 | ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } 67 | end 68 | end 69 | 70 | config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| 71 | b.use :html5 72 | b.use :placeholder 73 | b.optional :maxlength 74 | b.optional :readonly 75 | b.use :label, class: 'col-sm-3 control-label' 76 | 77 | b.wrapper tag: 'div', class: 'col-sm-9' do |ba| 78 | ba.use :input 79 | ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } 80 | ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } 81 | end 82 | end 83 | 84 | config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| 85 | b.use :html5 86 | b.optional :readonly 87 | 88 | b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr| 89 | wr.wrapper tag: 'div', class: 'checkbox' do |ba| 90 | ba.use :label_input 91 | end 92 | 93 | wr.use :error, wrap_with: { tag: 'span', class: 'help-block' } 94 | wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' } 95 | end 96 | end 97 | 98 | config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| 99 | b.use :html5 100 | b.optional :readonly 101 | 102 | b.use :label, class: 'col-sm-3 control-label' 103 | 104 | b.wrapper tag: 'div', class: 'col-sm-9' do |ba| 105 | ba.use :input 106 | ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } 107 | ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } 108 | end 109 | end 110 | 111 | config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| 112 | b.use :html5 113 | b.use :placeholder 114 | b.optional :maxlength 115 | b.optional :pattern 116 | b.optional :min_max 117 | b.optional :readonly 118 | b.use :label, class: 'sr-only' 119 | 120 | b.use :input, class: 'form-control' 121 | b.use :error, wrap_with: { tag: 'span', class: 'help-block' } 122 | b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } 123 | end 124 | 125 | config.wrappers :multi_select, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| 126 | b.use :html5 127 | b.optional :readonly 128 | b.use :label, class: 'control-label' 129 | b.wrapper tag: 'div', class: 'form-inline' do |ba| 130 | ba.use :input, class: 'form-control' 131 | ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } 132 | ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } 133 | end 134 | end 135 | # Wrappers for forms and inputs using the Bootstrap toolkit. 136 | # Check the Bootstrap docs (http://getbootstrap.com) 137 | # to learn about the different styles for forms and inputs, 138 | # buttons and other elements. 139 | config.default_wrapper = :vertical_form 140 | config.wrapper_mappings = { 141 | check_boxes: :vertical_radio_and_checkboxes, 142 | radio_buttons: :vertical_radio_and_checkboxes, 143 | file: :vertical_file_input, 144 | boolean: :vertical_boolean, 145 | datetime: :multi_select, 146 | date: :multi_select, 147 | time: :multi_select 148 | } 149 | end 150 | -------------------------------------------------------------------------------- /config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] 9 | end 10 | -------------------------------------------------------------------------------- /config/locales/countries.en.rb: -------------------------------------------------------------------------------- 1 | #encoding: UTF-8 2 | { :en => { 3 | 4 | :countries => { 5 | :AD => "Andorra", 6 | :AE => "United Arab Emirates", 7 | :AF => "Afghanistan", 8 | :AG => "Antigua & Barbuda", 9 | :AI => "Anguilla", 10 | :AL => "Albania", 11 | :AM => "Armenia", 12 | :AO => "Angola", 13 | :AQ => "Antarctica", 14 | :AR => "Argentina", 15 | :AS => "American Samoa", 16 | :AT => "Austria", 17 | :AU => "Australia", 18 | :AW => "Aruba", 19 | :AX => "Åland Islands", 20 | :AZ => "Azerbaijan", 21 | :BA => "Bosnia & Herzegovina", 22 | :BB => "Barbados", 23 | :BD => "Bangladesh", 24 | :BE => "Belgium", 25 | :BF => "Burkina Faso", 26 | :BG => "Bulgaria", 27 | :BH => "Bahrain", 28 | :BI => "Burundi", 29 | :BJ => "Benin", 30 | :BL => "St. Barthélemy", 31 | :BM => "Bermuda", 32 | :BN => "Brunei", 33 | :BO => "Bolivia", 34 | :BQ => "Caribbean Netherlands", 35 | :BR => "Brazil", 36 | :BS => "Bahamas", 37 | :BT => "Bhutan", 38 | :BW => "Botswana", 39 | :BY => "Belarus", 40 | :BZ => "Belize", 41 | :CA => "Canada", 42 | :CC => "Cocos (Keeling) Islands", 43 | :CD => "Congo - Kinshasa", 44 | :CF => "Central African Republic", 45 | :CG => "Congo - Brazzaville", 46 | :CH => "Switzerland", 47 | :CI => "Côte d’Ivoire", 48 | :CK => "Cook Islands", 49 | :CL => "Chile", 50 | :CM => "Cameroon", 51 | :CN => "China", 52 | :CO => "Colombia", 53 | :CR => "Costa Rica", 54 | :CU => "Cuba", 55 | :CV => "Cape Verde", 56 | :CW => "Curaçao", 57 | :CX => "Christmas Island", 58 | :CY => "Cyprus", 59 | :CZ => "Czech Republic", 60 | :DE => "Germany", 61 | :DJ => "Djibouti", 62 | :DK => "Denmark", 63 | :DM => "Dominica", 64 | :DO => "Dominican Republic", 65 | :DZ => "Algeria", 66 | :EC => "Ecuador", 67 | :EE => "Estonia", 68 | :EG => "Egypt", 69 | :EH => "Western Sahara", 70 | :ER => "Eritrea", 71 | :ES => "Spain", 72 | :ET => "Ethiopia", 73 | :FI => "Finland", 74 | :FJ => "Fiji", 75 | :FK => "Falkland Islands", 76 | :FM => "Micronesia", 77 | :FO => "Faroe Islands", 78 | :FR => "France", 79 | :GA => "Gabon", 80 | :GB => "United Kingdom", 81 | :GD => "Grenada", 82 | :GE => "Georgia", 83 | :GF => "French Guiana", 84 | :GG => "Guernsey", 85 | :GH => "Ghana", 86 | :GI => "Gibraltar", 87 | :GL => "Greenland", 88 | :GM => "Gambia", 89 | :GN => "Guinea", 90 | :GP => "Guadeloupe", 91 | :GQ => "Equatorial Guinea", 92 | :GR => "Greece", 93 | :GS => "South Georgia & South Sandwich Islands", 94 | :GT => "Guatemala", 95 | :GU => "Guam", 96 | :GW => "Guinea-Bissau", 97 | :GY => "Guyana", 98 | :HK => "Hong Kong SAR China", 99 | :HM => "Heard & McDonald Islands", 100 | :HN => "Honduras", 101 | :HR => "Croatia", 102 | :HT => "Haiti", 103 | :HU => "Hungary", 104 | :ID => "Indonesia", 105 | :IE => "Ireland", 106 | :IL => "Israel", 107 | :IM => "Isle of Man", 108 | :IN => "India", 109 | :IO => "British Indian Ocean Territory", 110 | :IQ => "Iraq", 111 | :IR => "Iran", 112 | :IS => "Iceland", 113 | :IT => "Italy", 114 | :JE => "Jersey", 115 | :JM => "Jamaica", 116 | :JO => "Jordan", 117 | :JP => "Japan", 118 | :KE => "Kenya", 119 | :KG => "Kyrgyzstan", 120 | :KH => "Cambodia", 121 | :KI => "Kiribati", 122 | :KM => "Comoros", 123 | :KN => "St. Kitts & Nevis", 124 | :KP => "North Korea", 125 | :KR => "South Korea", 126 | :KW => "Kuwait", 127 | :KY => "Cayman Islands", 128 | :KZ => "Kazakhstan", 129 | :LA => "Laos", 130 | :LB => "Lebanon", 131 | :LC => "St. Lucia", 132 | :LI => "Liechtenstein", 133 | :LK => "Sri Lanka", 134 | :LR => "Liberia", 135 | :LS => "Lesotho", 136 | :LT => "Lithuania", 137 | :LU => "Luxembourg", 138 | :LV => "Latvia", 139 | :LY => "Libya", 140 | :MA => "Morocco", 141 | :MC => "Monaco", 142 | :MD => "Moldova", 143 | :ME => "Montenegro", 144 | :MF => "St. Martin", 145 | :MG => "Madagascar", 146 | :MH => "Marshall Islands", 147 | :MK => "Macedonia", 148 | :ML => "Mali", 149 | :MM => "Myanmar (Burma)", 150 | :MN => "Mongolia", 151 | :MO => "Macau SAR China", 152 | :MP => "Northern Mariana Islands", 153 | :MQ => "Martinique", 154 | :MR => "Mauritania", 155 | :MS => "Montserrat", 156 | :MT => "Malta", 157 | :MU => "Mauritius", 158 | :MV => "Maldives", 159 | :MW => "Malawi", 160 | :MX => "Mexico", 161 | :MY => "Malaysia", 162 | :MZ => "Mozambique", 163 | :NA => "Namibia", 164 | :NC => "New Caledonia", 165 | :NE => "Niger", 166 | :NF => "Norfolk Island", 167 | :NG => "Nigeria", 168 | :NI => "Nicaragua", 169 | :NL => "Netherlands", 170 | :NO => "Norway", 171 | :NP => "Nepal", 172 | :NR => "Nauru", 173 | :NU => "Niue", 174 | :NZ => "New Zealand", 175 | :OM => "Oman", 176 | :PA => "Panama", 177 | :PE => "Peru", 178 | :PF => "French Polynesia", 179 | :PG => "Papua New Guinea", 180 | :PH => "Philippines", 181 | :PK => "Pakistan", 182 | :PL => "Poland", 183 | :PM => "St. Pierre & Miquelon", 184 | :PN => "Pitcairn Islands", 185 | :PR => "Puerto Rico", 186 | :PS => "Palestinian Territories", 187 | :PT => "Portugal", 188 | :PW => "Palau", 189 | :PY => "Paraguay", 190 | :QA => "Qatar", 191 | :RE => "Réunion", 192 | :RO => "Romania", 193 | :RS => "Serbia", 194 | :RU => "Russia", 195 | :RW => "Rwanda", 196 | :SA => "Saudi Arabia", 197 | :SB => "Solomon Islands", 198 | :SC => "Seychelles", 199 | :SD => "Sudan", 200 | :SE => "Sweden", 201 | :SG => "Singapore", 202 | :SH => "St. Helena", 203 | :SI => "Slovenia", 204 | :SJ => "Svalbard & Jan Mayen", 205 | :SK => "Slovakia", 206 | :SL => "Sierra Leone", 207 | :SM => "San Marino", 208 | :SN => "Senegal", 209 | :SO => "Somalia", 210 | :SR => "Suriname", 211 | :SS => "South Sudan", 212 | :ST => "São Tomé & Príncipe", 213 | :SV => "El Salvador", 214 | :SX => "Sint Maarten", 215 | :SY => "Syria", 216 | :SZ => "Swaziland", 217 | :TC => "Turks & Caicos Islands", 218 | :TD => "Chad", 219 | :TF => "French Southern Territories", 220 | :TG => "Togo", 221 | :TH => "Thailand", 222 | :TJ => "Tajikistan", 223 | :TK => "Tokelau", 224 | :TL => "Timor-Leste", 225 | :TM => "Turkmenistan", 226 | :TN => "Tunisia", 227 | :TO => "Tonga", 228 | :TR => "Turkey", 229 | :TT => "Trinidad & Tobago", 230 | :TV => "Tuvalu", 231 | :TW => "Taiwan", 232 | :TZ => "Tanzania", 233 | :UA => "Ukraine", 234 | :UG => "Uganda", 235 | :UM => "U.S. Outlying Islands", 236 | :US => "United States", 237 | :UY => "Uruguay", 238 | :UZ => "Uzbekistan", 239 | :VA => "Vatican City", 240 | :VC => "St. Vincent & Grenadines", 241 | :VE => "Venezuela", 242 | :VG => "British Virgin Islands", 243 | :VI => "U.S. Virgin Islands", 244 | :VN => "Vietnam", 245 | :VU => "Vanuatu", 246 | :WF => "Wallis & Futuna", 247 | :WS => "Samoa", 248 | :YE => "Yemen", 249 | :YT => "Mayotte", 250 | :ZA => "South Africa", 251 | :ZM => "Zambia", 252 | :ZW => "Zimbabwe", 253 | } 254 | 255 | } 256 | } 257 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # To learn more, please read the Rails Internationalization guide 20 | # available at http://guides.rubyonrails.org/i18n.html. 21 | 22 | en: 23 | hello: "Hello world" 24 | -------------------------------------------------------------------------------- /config/locales/simple_form.en.yml: -------------------------------------------------------------------------------- 1 | en: 2 | simple_form: 3 | "yes": 'Yes' 4 | "no": 'No' 5 | required: 6 | text: 'required' 7 | mark: '*' 8 | # You can uncomment the line below if you need to overwrite the whole required html. 9 | # When using html, text and mark won't be used. 10 | # html: '*' 11 | error_notification: 12 | default_message: "Please review the problems below:" 13 | # Examples 14 | # labels: 15 | # defaults: 16 | # password: 'Password' 17 | # user: 18 | # new: 19 | # email: 'E-mail to sign in.' 20 | # edit: 21 | # email: 'E-mail.' 22 | # hints: 23 | # defaults: 24 | # username: 'User name to sign in.' 25 | # password: 'No special characters, please.' 26 | # include_blanks: 27 | # defaults: 28 | # age: 'Rather not say' 29 | # prompts: 30 | # defaults: 31 | # age: 'Select your age' 32 | -------------------------------------------------------------------------------- /config/puma.rb: -------------------------------------------------------------------------------- 1 | # Puma can serve each request in a thread from an internal thread pool. 2 | # The `threads` method setting takes two numbers a minimum and maximum. 3 | # Any libraries that use thread pools should be configured to match 4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum 5 | # and maximum, this matches the default thread size of Active Record. 6 | # 7 | threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i 8 | threads threads_count, threads_count 9 | 10 | # Specifies the `port` that Puma will listen on to receive requests, default is 3000. 11 | # 12 | port ENV.fetch("PORT") { 3000 } 13 | 14 | # Specifies the `environment` that Puma will run in. 15 | # 16 | environment ENV.fetch("RAILS_ENV") { "development" } 17 | 18 | # Specifies the number of `workers` to boot in clustered mode. 19 | # Workers are forked webserver processes. If using threads and workers together 20 | # the concurrency of the application would be max `threads` * `workers`. 21 | # Workers do not work on JRuby or Windows (both of which do not support 22 | # processes). 23 | # 24 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 } 25 | 26 | # Use the `preload_app!` method when specifying a `workers` number. 27 | # This directive tells Puma to first boot the application and load code 28 | # before forking the application. This takes advantage of Copy On Write 29 | # process behavior so workers use less memory. If you use this option 30 | # you need to make sure to reconnect any threads in the `on_worker_boot` 31 | # block. 32 | # 33 | # preload_app! 34 | 35 | # The code in the `on_worker_boot` will be called if you are using 36 | # clustered mode by specifying a number of `workers`. After each worker 37 | # process is booted this block will be run, if you are using `preload_app!` 38 | # option you will want to use this block to reconnect to any threads 39 | # or connections that may have been created at application boot, Ruby 40 | # cannot share connections between processes. 41 | # 42 | # on_worker_boot do 43 | # ActiveRecord::Base.establish_connection if defined?(ActiveRecord) 44 | # end 45 | 46 | # Allow puma to be restarted by `rails restart` command. 47 | plugin :tmp_restart 48 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | resource :wizard do 3 | get :step1 4 | get :step2 5 | get :step3 6 | get :step4 7 | 8 | post :validate_step 9 | end 10 | 11 | root 'home#index' 12 | # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html 13 | end 14 | -------------------------------------------------------------------------------- /config/secrets.yml: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key is used for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | # You can use `rails secret` to generate a secure secret key. 9 | 10 | # Make sure the secrets in this file are kept private 11 | # if you're sharing your code publicly. 12 | 13 | development: 14 | secret_key_base: c3f56c363599c0c94012c5f571130a8e5d291b51299e4a78e878775a643336f90e46c74b1fcb585d83f6a9f8e6b6f0bb161b6f1fc12618ef2b7a3ad9cd0df27b 15 | 16 | test: 17 | secret_key_base: b7b2cae369f476406ea19b15d6ab7d3d1c79298c99e068e9f2dcbabb6514a956850832e99659bff1675da675d2c6884c701eb0176374100a5a6af7b7e88aaca1 18 | 19 | # Do not keep production secrets in the repository, 20 | # instead read values from the environment. 21 | production: 22 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> 23 | -------------------------------------------------------------------------------- /config/spring.rb: -------------------------------------------------------------------------------- 1 | %w( 2 | .ruby-version 3 | .rbenv-vars 4 | tmp/restart.txt 5 | tmp/caching-dev.txt 6 | ).each { |path| Spring.watch(path) } 7 | -------------------------------------------------------------------------------- /db/migrate/20161129002314_create_users.rb: -------------------------------------------------------------------------------- 1 | class CreateUsers < ActiveRecord::Migration[5.0] 2 | def change 3 | create_table :users do |t| 4 | t.string :first_name 5 | t.string :last_name 6 | t.string :email 7 | t.string :address_1 8 | t.string :address_2 9 | t.string :zip_code 10 | t.string :city 11 | t.string :country 12 | t.string :phone_number 13 | 14 | t.timestamps 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 1 | # This file is auto-generated from the current state of the database. Instead 2 | # of editing this file, please use the migrations feature of Active Record to 3 | # incrementally modify your database, and then regenerate this schema definition. 4 | # 5 | # Note that this schema.rb definition is the authoritative source for your 6 | # database schema. If you need to create the application database on another 7 | # system, you should be using db:schema:load, not running all the migrations 8 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations 9 | # you'll amass, the slower it'll run and the greater likelihood for issues). 10 | # 11 | # It's strongly recommended that you check this file into your version control system. 12 | 13 | ActiveRecord::Schema.define(version: 20161129002314) do 14 | 15 | create_table "users", force: :cascade do |t| 16 | t.string "first_name" 17 | t.string "last_name" 18 | t.string "email" 19 | t.string "address_1" 20 | t.string "address_2" 21 | t.string "zip_code" 22 | t.string "city" 23 | t.string "country" 24 | t.string "phone_number" 25 | t.datetime "created_at", null: false 26 | t.datetime "updated_at", null: false 27 | end 28 | 29 | end 30 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) 7 | # Character.create(name: 'Luke', movie: movies.first) 8 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicolasblanco/wizard_app/6f0ba8fbc67d6e68afdd0a1767b93aa86c30732a/lib/assets/.keep -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicolasblanco/wizard_app/6f0ba8fbc67d6e68afdd0a1767b93aa86c30732a/lib/tasks/.keep -------------------------------------------------------------------------------- /lib/templates/erb/scaffold/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%%= simple_form_for(@<%= singular_table_name %>) do |f| %> 2 | <%%= f.error_notification %> 3 | 4 |
5 | <%- attributes.each do |attribute| -%> 6 | <%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %> 7 | <%- end -%> 8 |
9 | 10 |
11 | <%%= f.button :submit %> 12 |
13 | <%% end %> 14 | -------------------------------------------------------------------------------- /log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicolasblanco/wizard_app/6f0ba8fbc67d6e68afdd0a1767b93aa86c30732a/log/.keep -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The page you were looking for doesn't exist.

62 |

You may have mistyped the address or the page may have moved.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The change you wanted was rejected.

62 |

Maybe you tried to change something you didn't have access to.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

We're sorry, but something went wrong.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /public/apple-touch-icon-precomposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicolasblanco/wizard_app/6f0ba8fbc67d6e68afdd0a1767b93aa86c30732a/public/apple-touch-icon-precomposed.png -------------------------------------------------------------------------------- /public/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicolasblanco/wizard_app/6f0ba8fbc67d6e68afdd0a1767b93aa86c30732a/public/apple-touch-icon.png -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicolasblanco/wizard_app/6f0ba8fbc67d6e68afdd0a1767b93aa86c30732a/public/favicon.ico -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /spec/features/user_creates_a_user_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe 'the user creation success path' do 4 | it 'creates the user' do 5 | visit '/' 6 | click_link 'Create a user' 7 | 8 | # Step 1 9 | fill_in 'Email', with: 'user@example.com' 10 | click_button 'Continue' 11 | 12 | # Step 2 13 | fill_in 'First name', with: 'Foo' 14 | fill_in 'Last name', with: 'Bar' 15 | click_button 'Continue' 16 | 17 | # Step 3 18 | fill_in 'Address 1', with: 'Bla bla Bla' 19 | fill_in 'Zip code', with: 'XYZ1234' 20 | fill_in 'City', with: 'FoobarCity' 21 | select('France', from: 'Country') 22 | click_button 'Continue' 23 | 24 | # Step 4 25 | fill_in 'Phone number', with: '+3366666666' 26 | click_button 'Finish' 27 | 28 | expect(page).to have_content('User succesfully created!') 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /spec/form_models/wizard/user_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe Wizard::User::Base, type: :model do 4 | subject { Wizard::User::Base.new({ first_name: 'foo', last_name: 'bar' }) } 5 | 6 | describe '#user' do 7 | it 'returns the User instance' do 8 | expect(subject.user).to be_a(User) 9 | end 10 | end 11 | 12 | describe 'delegate user attributes' do 13 | it 'delegates the user attributes to the user instance' do 14 | subject.first_name = 'Foo' 15 | subject.last_name = 'Bar' 16 | expect(subject.user.first_name).to eq('Foo') 17 | expect(subject.user.last_name).to eq('Bar') 18 | end 19 | end 20 | end 21 | 22 | RSpec.describe Wizard::User::Step1, type: :model do 23 | subject { Wizard::User::Step1.new({ first_name: 'foo', last_name: 'bar' }) } 24 | 25 | it { is_expected.to validate_presence_of(:email) } 26 | it { is_expected.to allow_value('foo@bar.com').for(:email) } 27 | it { is_expected.not_to allow_value('foobar.com').for(:email) } 28 | end 29 | 30 | RSpec.describe Wizard::User::Step2, type: :model do 31 | subject { Wizard::User::Step2.new({ first_name: 'foo', last_name: 'bar' }) } 32 | 33 | it { is_expected.to validate_presence_of(:email) } 34 | it { is_expected.to allow_value('foo@bar.com').for(:email) } 35 | it { is_expected.not_to allow_value('foobar.com').for(:email) } 36 | it { is_expected.to validate_presence_of(:first_name) } 37 | it { is_expected.to validate_presence_of(:last_name) } 38 | end 39 | 40 | RSpec.describe Wizard::User::Step3, type: :model do 41 | subject { Wizard::User::Step3.new({ first_name: 'foo', last_name: 'bar' }) } 42 | 43 | it { is_expected.to validate_presence_of(:email) } 44 | it { is_expected.to allow_value('foo@bar.com').for(:email) } 45 | it { is_expected.not_to allow_value('foobar.com').for(:email) } 46 | it { is_expected.to validate_presence_of(:first_name) } 47 | it { is_expected.to validate_presence_of(:last_name) } 48 | it { is_expected.to validate_presence_of(:address_1) } 49 | it { is_expected.to validate_presence_of(:zip_code) } 50 | it { is_expected.to validate_presence_of(:country) } 51 | end 52 | 53 | RSpec.describe Wizard::User::Step4, type: :model do 54 | subject { Wizard::User::Step4.new({ first_name: 'foo', last_name: 'bar' }) } 55 | 56 | it { is_expected.to validate_presence_of(:email) } 57 | it { is_expected.to allow_value('foo@bar.com').for(:email) } 58 | it { is_expected.not_to allow_value('foobar.com').for(:email) } 59 | it { is_expected.to validate_presence_of(:first_name) } 60 | it { is_expected.to validate_presence_of(:last_name) } 61 | it { is_expected.to validate_presence_of(:address_1) } 62 | it { is_expected.to validate_presence_of(:zip_code) } 63 | it { is_expected.to validate_presence_of(:country) } 64 | it { is_expected.to validate_presence_of(:phone_number) } 65 | end 66 | -------------------------------------------------------------------------------- /spec/models/user_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe User do 4 | it { is_expected.to validate_presence_of(:email) } 5 | it { is_expected.to allow_value('foo@bar.com').for(:email) } 6 | it { is_expected.not_to allow_value('foobar.com').for(:email) } 7 | it { is_expected.to validate_presence_of(:first_name) } 8 | it { is_expected.to validate_presence_of(:last_name) } 9 | it { is_expected.to validate_presence_of(:address_1) } 10 | it { is_expected.to validate_presence_of(:zip_code) } 11 | it { is_expected.to validate_presence_of(:country) } 12 | it { is_expected.to validate_presence_of(:phone_number) } 13 | end 14 | -------------------------------------------------------------------------------- /spec/rails_helper.rb: -------------------------------------------------------------------------------- 1 | # This file is copied to spec/ when you run 'rails generate rspec:install' 2 | ENV['RAILS_ENV'] ||= 'test' 3 | require File.expand_path('../../config/environment', __FILE__) 4 | # Prevent database truncation if the environment is production 5 | abort("The Rails environment is running in production mode!") if Rails.env.production? 6 | require 'spec_helper' 7 | require 'rspec/rails' 8 | require 'capybara/rails' 9 | require 'capybara/rspec' 10 | # Add additional requires below this line. Rails is not loaded until this point! 11 | 12 | # Requires supporting ruby files with custom matchers and macros, etc, in 13 | # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are 14 | # run as spec files by default. This means that files in spec/support that end 15 | # in _spec.rb will both be required and run as specs, causing the specs to be 16 | # run twice. It is recommended that you do not name files matching this glob to 17 | # end with _spec.rb. You can configure this pattern with the --pattern 18 | # option on the command line or in ~/.rspec, .rspec or `.rspec-local`. 19 | # 20 | # The following line is provided for convenience purposes. It has the downside 21 | # of increasing the boot-up time by auto-requiring all files in the support 22 | # directory. Alternatively, in the individual `*_spec.rb` files, manually 23 | # require only the support files necessary. 24 | # 25 | # Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } 26 | 27 | RSpec.configure do |config| 28 | # RSpec Rails can automatically mix in different behaviours to your tests 29 | # based on their file location, for example enabling you to call `get` and 30 | # `post` in specs under `spec/controllers`. 31 | # 32 | # You can disable this behaviour by removing the line below, and instead 33 | # explicitly tag your specs with their type, e.g.: 34 | # 35 | # RSpec.describe UsersController, :type => :controller do 36 | # # ... 37 | # end 38 | # 39 | # The different available types are documented in the features, such as in 40 | # https://relishapp.com/rspec/rspec-rails/docs 41 | config.infer_spec_type_from_file_location! 42 | 43 | # Filter lines from Rails gems in backtraces. 44 | config.filter_rails_from_backtrace! 45 | # arbitrary gems may also be filtered via: 46 | # config.filter_gems_from_backtrace("gem name") 47 | end 48 | 49 | Shoulda::Matchers.configure do |config| 50 | config.integrate do |with| 51 | with.test_framework :rspec 52 | with.library :rails 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # This file was generated by the `rails generate rspec:install` command. Conventionally, all 2 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. 3 | # The generated `.rspec` file contains `--require spec_helper` which will cause 4 | # this file to always be loaded, without a need to explicitly require it in any 5 | # files. 6 | # 7 | # Given that it is always loaded, you are encouraged to keep this file as 8 | # light-weight as possible. Requiring heavyweight dependencies from this file 9 | # will add to the boot time of your test suite on EVERY test run, even for an 10 | # individual file that may not need all of that loaded. Instead, consider making 11 | # a separate helper file that requires the additional dependencies and performs 12 | # the additional setup, and require it from the spec files that actually need 13 | # it. 14 | # 15 | # The `.rspec` file also contains a few flags that are not defaults but that 16 | # users commonly want. 17 | # 18 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration 19 | RSpec.configure do |config| 20 | # rspec-expectations config goes here. You can use an alternate 21 | # assertion/expectation library such as wrong or the stdlib/minitest 22 | # assertions if you prefer. 23 | config.expect_with :rspec do |expectations| 24 | # This option will default to `true` in RSpec 4. It makes the `description` 25 | # and `failure_message` of custom matchers include text for helper methods 26 | # defined using `chain`, e.g.: 27 | # be_bigger_than(2).and_smaller_than(4).description 28 | # # => "be bigger than 2 and smaller than 4" 29 | # ...rather than: 30 | # # => "be bigger than 2" 31 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true 32 | end 33 | 34 | # rspec-mocks config goes here. You can use an alternate test double 35 | # library (such as bogus or mocha) by changing the `mock_with` option here. 36 | config.mock_with :rspec do |mocks| 37 | # Prevents you from mocking or stubbing a method that does not exist on 38 | # a real object. This is generally recommended, and will default to 39 | # `true` in RSpec 4. 40 | mocks.verify_partial_doubles = true 41 | end 42 | 43 | # This option will default to `:apply_to_host_groups` in RSpec 4 (and will 44 | # have no way to turn it off -- the option exists only for backwards 45 | # compatibility in RSpec 3). It causes shared context metadata to be 46 | # inherited by the metadata hash of host groups and examples, rather than 47 | # triggering implicit auto-inclusion in groups with matching metadata. 48 | config.shared_context_metadata_behavior = :apply_to_host_groups 49 | config.disable_monkey_patching! 50 | 51 | 52 | # The settings below are suggested to provide a good initial experience 53 | # with RSpec, but feel free to customize to your heart's content. 54 | =begin 55 | # This allows you to limit a spec run to individual examples or groups 56 | # you care about by tagging them with `:focus` metadata. When nothing 57 | # is tagged with `:focus`, all examples get run. RSpec also provides 58 | # aliases for `it`, `describe`, and `context` that include `:focus` 59 | # metadata: `fit`, `fdescribe` and `fcontext`, respectively. 60 | config.filter_run_when_matching :focus 61 | 62 | # Allows RSpec to persist some state between runs in order to support 63 | # the `--only-failures` and `--next-failure` CLI options. We recommend 64 | # you configure your source control system to ignore this file. 65 | config.example_status_persistence_file_path = "spec/examples.txt" 66 | 67 | # Limits the available syntax to the non-monkey patched syntax that is 68 | # recommended. For more details, see: 69 | # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ 70 | # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ 71 | # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode 72 | config.disable_monkey_patching! 73 | 74 | # Many RSpec users commonly either run the entire suite or an individual 75 | # file, and it's useful to allow more verbose output when running an 76 | # individual spec file. 77 | if config.files_to_run.one? 78 | # Use the documentation formatter for detailed output, 79 | # unless a formatter has already been configured 80 | # (e.g. via a command-line flag). 81 | config.default_formatter = 'doc' 82 | end 83 | 84 | # Print the 10 slowest examples and example groups at the 85 | # end of the spec run, to help surface which specs are running 86 | # particularly slow. 87 | config.profile_examples = 10 88 | 89 | # Run specs in random order to surface order dependencies. If you find an 90 | # order dependency and want to debug it, you can fix the order by providing 91 | # the seed, which is printed after each run. 92 | # --seed 1234 93 | config.order = :random 94 | 95 | # Seed global randomization in this process using the `--seed` CLI option. 96 | # Setting this allows you to use `--seed` to deterministically reproduce 97 | # test failures related to randomization by passing the same `--seed` value 98 | # as the one that triggered the failure. 99 | Kernel.srand config.seed 100 | =end 101 | end 102 | -------------------------------------------------------------------------------- /tmp/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicolasblanco/wizard_app/6f0ba8fbc67d6e68afdd0a1767b93aa86c30732a/tmp/.keep -------------------------------------------------------------------------------- /vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicolasblanco/wizard_app/6f0ba8fbc67d6e68afdd0a1767b93aa86c30732a/vendor/assets/javascripts/.keep -------------------------------------------------------------------------------- /vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicolasblanco/wizard_app/6f0ba8fbc67d6e68afdd0a1767b93aa86c30732a/vendor/assets/stylesheets/.keep --------------------------------------------------------------------------------