Class: Admin::RightsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/admin/rights_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/admin/rights_controller.rb', line 24

def create
  @right = Right.new(params[:right])
  if @right.save
    flash[:notice] = I18n.t('right.create.success').capitalize
    return request.xhr? ? (render :nothing => true) : redirect_to([forgeos_core, :admin, @right])
  else
    flash[:error] = I18n.t('right.create.failed').capitalize
    if request.xhr?
      render :nothing => true, :json => { :result => 'error' }
      return false
    else
      render :action => 'new'
    end
  end
end

#destroyObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'app/controllers/admin/rights_controller.rb', line 55

def destroy
  if @right.destroy
    flash[:notice] = I18n.t('right.destroy.success').capitalize
  else
    flash[:error] = I18n.t('right.destroy.failed').capitalize
  end

  respond_to do |wants|
    wants.html do
      redirect_to([forgeos_core, :admin, :rights])
    end
    wants.js
  end
end

#editObject



21
22
# File 'app/controllers/admin/rights_controller.rb', line 21

def edit
end

#indexObject



4
5
6
7
8
9
10
11
12
# File 'app/controllers/admin/rights_controller.rb', line 4

def index
  respond_to do |format|
    format.html # index.html.erb
    format.json do
      sort
      render :layout => false
    end
  end
end

#newObject



17
18
19
# File 'app/controllers/admin/rights_controller.rb', line 17

def new
  @right = Right.new(params[:right])
end

#showObject



14
15
# File 'app/controllers/admin/rights_controller.rb', line 14

def show
end

#updateObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/controllers/admin/rights_controller.rb', line 40

def update
  if @right.update_attributes(params[:right])
    flash[:notice] = I18n.t('right.update.success').capitalize
    return request.xhr? ? (render :nothing => true) : redirect_to([forgeos_core, :admin, @right])
  else
    flash[:error] = I18n.t('right.update.failed').capitalize
    if request.xhr?
      render :nothing => true, :json => { :result => 'error' }
      return false
    else
      render :action => 'edit'
    end
  end
end