Sha256: fc791da3f3f19f64bf41325e5d5575804c90c0632efe33e0e52d5abc1b377aed

Contents?: true

Size: 1.34 KB

Versions: 12

Compression:

Stored size: 1.34 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: 'application'
    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

12 entries across 12 versions & 1 rubygems

Version Path
wbase-0.1.0 app/controllers/wbase/users_controller.rb
wbase-0.0.15 app/controllers/wbase/users_controller.rb
wbase-0.0.14 app/controllers/wbase/users_controller.rb
wbase-0.0.13 app/controllers/wbase/users_controller.rb
wbase-0.0.12 app/controllers/wbase/users_controller.rb
wbase-0.0.11 app/controllers/wbase/users_controller.rb
wbase-0.0.10 app/controllers/wbase/users_controller.rb
wbase-0.0.9 app/controllers/wbase/users_controller.rb
wbase-0.0.8 app/controllers/wbase/users_controller.rb
wbase-0.0.7 app/controllers/wbase/users_controller.rb
wbase-0.0.6 app/controllers/wbase/users_controller.rb
wbase-0.0.5 app/controllers/wbase/users_controller.rb