Sha256: 05d7558d934fc5a61f66f28cce19f9f084d3d8aeb61d11f1236bb884a05a7114

Contents?: true

Size: 1.17 KB

Versions: 11

Compression:

Stored size: 1.17 KB

Contents

class UsersController < ApplicationController
  include Applicat::Mvc::Controller::Resource
  
  before_filter :find_resource, only: [:show, :edit, :preferences, :update, :destroy]
  
  respond_to :html, :js, :json
  
  def index
    parent = find_parent User::PARENT_TYPES
    @users = parent ? parent.users : User.all
  end
  
  def languages
    render json: User.languages(params[:q]).to_json and return
  end
  
  def show
  end
  
  def edit
  end
  
  def preferences
    if params[:user] && current_user.update_attributes(params[:user])
      redirect_to preferences_user_path(current_user), notice: t('general.form.successfully_updated') and return
    end
  end
  
  def update
    if current_user.update_attributes(params[:user])
      redirect_to edit_user_path(current_user), notice: t('general.form.successfully_updated')
    else
      render :edit
    end
  end

  def destroy
    current_user.destroy
    redirect_to users_url, notice: t('general.form.destroyed')
  end
  
  def resource
    @user
  end
  
  private
  
  def find_resource
    @user = User.friendly.find(params[:id])
    @presenter = Resources::User::FormPresenter.new(self.view_context, resource: resource)
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
voluntary-0.6.0 app/controllers/users_controller.rb
voluntary-0.5.2 app/controllers/users_controller.rb
voluntary-0.5.1 app/controllers/users_controller.rb
voluntary-0.5.0 app/controllers/users_controller.rb
voluntary-0.4.0 app/controllers/users_controller.rb
voluntary-0.3.0 app/controllers/users_controller.rb
voluntary-0.2.4 app/controllers/users_controller.rb
voluntary-0.2.3 app/controllers/users_controller.rb
voluntary-0.2.2 app/controllers/users_controller.rb
voluntary-0.2.1 app/controllers/users_controller.rb
voluntary-0.2.0 app/controllers/users_controller.rb