Sha256: 96fbf01e1e641b5a748e7ae9be99ba6ab9ca21380bc43e3979a958fd3ecd6dfe

Contents?: true

Size: 904 Bytes

Versions: 6

Compression:

Stored size: 904 Bytes

Contents

class WelcomeController < ApplicationController

  include MxitRails::Page

  def index
    input :phone_number, 'Enter your cellphone number'

    validate 'Custom validation message' do |input|
      logger.info "Validation: #{input.inspect}"
      # NB Don't put a return here - it causes much unhappiness
      input != 'custom'
    end
    validate :numeric, 'Please enter a numeric digits only'
    validate :min_length, 10, 'Numbers must be at least 10 digits long'
    validate :max_length, 11, 'Numbers cannot be longer than 11 digits'

    @time = Time.now.strftime '%H:%M:%S on %A'

    submit do
      if params[:phone_number] == '1234567890'
        redirect_to '/welcome/easter_egg' and return
      end
      logger.info "This won't execute if an error occurred or if error! or redirect! was called"
      redirect_to '/index/success' and return
    end
  end

  def easter_egg
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mxit-rails-0.2.5 test/dummy/app/controllers/welcome_controller.rb
mxit-rails-0.2.4 test/dummy/app/controllers/welcome_controller.rb
mxit-rails-0.2.3 test/dummy/app/controllers/welcome_controller.rb
mxit-rails-0.2.2 test/dummy/app/controllers/welcome_controller.rb
mxit-rails-0.2.1 test/dummy/app/controllers/welcome_controller.rb
mxit-rails-0.2.0 test/dummy/app/controllers/welcome_controller.rb