Sha256: 840dec94f0825d6d2e6182cf4e88090328e2a4708200367a9489fd22af03f884

Contents?: true

Size: 1.74 KB

Versions: 5

Compression:

Stored size: 1.74 KB

Contents

ActiveAdmin.register People::User do

  menu :label => "Users"
  config.per_page = 30

  form do |f|
    f.semantic_errors # shows errors on :base
    #f.inputs          # builds an input field for every attribute
    f.inputs do
      f.input :id
      f.input :username
      f.input :email
      f.input :password
      f.input :password_confirmation
      f.input :updated_at
      f.input :created_at
    end
    f.actions         # adds the 'Submit' and 'Cancel' buttons
  end

  controller do
    def create
      @user = ::People::V1::User.new(user_params)
      if @user.save
        flash[:notice] = "Created Successfully!"
        redirect_to resource_path @user
      else
        flash[:notice] = "#{@user.errors.full_messages}"
        redirect_to new_resource_path @user
        #super
        #render :new
      end
    end

    def update
      @user = ::People::V1::User.find(params[:id])
      if @user.update(user_params)
        flash[:notice] = "Updated Successfully!"
        redirect_to resource_path @user
      else
        flash.now[:notice] = "#{@user.errors.full_messages}"
        render :edit
        #super
      end
    end

    def destroy
      @user = ::People::V1::User.find(params[:id])
      flash.now[:notice] = "Deleted Successfully!"
      render :index
    end

    private

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

  index do
    column :id
    column :username
    column :email
    column :password_digest
    column :updated_at
    column :created_at
    actions
  end

  show do
    attributes_table do
      row :id
      row :username
      row :email
      row :password_digest
      row :updated_at
      row :created_at
    end
  end


end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
json_voorhees-0.4.6 lib/generators/json_voorhees/app_make_user/templates/active_admin_register.rb.erb
json_voorhees-0.4.5 lib/generators/json_voorhees/app_make_user/templates/active_admin_register.rb.erb
json_voorhees-0.4.4 lib/generators/json_voorhees/app_make_user/templates/active_admin_register.rb.erb
json_voorhees-0.4.3 lib/generators/json_voorhees/app_make_user/templates/active_admin_register.rb.erb
json_voorhees-0.4.2 lib/generators/json_voorhees/app_make_user/templates/active_admin_register.rb.erb