Sha256: 78d4decb4490195f2479daca3141a0f8f4fcc647673f2fb33def8211c6e48d52

Contents?: true

Size: 720 Bytes

Versions: 3

Compression:

Stored size: 720 Bytes

Contents

module Theblog
  class Admin::AccountsController < AdminController
    include Theblog::Itemable

    MODEL = Theblog::Account
    INDEX = [:user_name, :email, :first_name, :middle_name, :last_name, {roles: :name, link: true}]
    ATTRIBUTES = [:first_name, :middle_name, :last_name, :user_name, :email]
    ASSOCIATIONS = [:roles]

    def create
      @item = model.new(permitted_params)
      generated_password = Devise.friendly_token.first(8)
      @item.password = generated_password
      if @item.save
        # TODO: notify user
        flash[:notice] = "Item created"
        redirect_to action: :index
      else
        flash.now[:alert] = "Fix errors below"
        render 'new'
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
theblog-0.0.2.3 app/controllers/theblog/admin/accounts_controller.rb
theblog-0.0.2.2 app/controllers/theblog/admin/accounts_controller.rb
theblog-0.0.2.1 app/controllers/theblog/admin/accounts_controller.rb