Sha256: 4794f087ba3ebe5ea21da34b2b2de6e484fc38fbcdd8caa866d7c922e650cd8d

Contents?: true

Size: 1.36 KB

Versions: 19

Compression:

Stored size: 1.36 KB

Contents

require_dependency "wbase/application_controller"

module Wbase
  class UsersController < ApplicationController
    before_action :require_login!, only: [:show, :update]

    def new
      @user = User.new
      render layout: 'wbase/auth'
    end

    def create
      @user = User.new(user_params)
      @user.verified = true
      if @user.save
        login(@user)
        AdminMailer.new_user(@user).deliver_later
        CreateDripSubscriberJob.perform_later(@user.id)
        redirect_to '/'
      else
        flash.now[:errors] = @user.errors.full_messages
        render :new, layout: 'wbase/auth'
      end
    end

    def edit
      @user = current_user
    end

    def update
      @user = current_user
      if !@user.update(update_params)
        flash[:errors] = @user.errors.full_messages
      end
      redirect_to '/user'
    end

    def show
      @time_zones = ActiveSupport::TimeZone.us_zones.map(&:name)
      render layout: 'wbase/admin'
    end

    private

    def update_params
      params
        .require(:user)
        .permit(
          :email,
          :name,
          :initial_investment,
          :reinvest_percent,
          :facebook_page,
          :time_zone,
          :phone,
          :notify_email,
          :notify_text
        )
    end

    def user_params
      params.require(:user).permit(:email, :password, :time_zone)
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
wbase-0.3.2 app/controllers/wbase/users_controller.rb
wbase-0.3.1 app/controllers/wbase/users_controller.rb
wbase-0.3.0 app/controllers/wbase/users_controller.rb
wbase-0.2.9 app/controllers/wbase/users_controller.rb
wbase-0.2.8 app/controllers/wbase/users_controller.rb
wbase-0.2.7 app/controllers/wbase/users_controller.rb
wbase-0.2.6 app/controllers/wbase/users_controller.rb
wbase-0.2.5 app/controllers/wbase/users_controller.rb
wbase-0.2.4 app/controllers/wbase/users_controller.rb
wbase-0.2.3 app/controllers/wbase/users_controller.rb
wbase-0.2.2 app/controllers/wbase/users_controller.rb
wbase-0.2.1 app/controllers/wbase/users_controller.rb
wbase-0.2.0 app/controllers/wbase/users_controller.rb
wbase-0.1.7 app/controllers/wbase/users_controller.rb
wbase-0.1.6 app/controllers/wbase/users_controller.rb
wbase-0.1.5 app/controllers/wbase/users_controller.rb
wbase-0.1.4 app/controllers/wbase/users_controller.rb
wbase-0.1.3 app/controllers/wbase/users_controller.rb
wbase-0.1.2 app/controllers/wbase/users_controller.rb