Class: Admin::SettingsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/admin/settings_controller.rb', line 42

def create
    @setting = Setting.new(params[:setting])
    
    if @setting.respond_to?(:author)
      @setting.author ||= current_user
    end
    
    @setting.save
    respond_with(@setting)
end

#destroyObject



59
60
61
62
# File 'app/controllers/admin/settings_controller.rb', line 59

def destroy
  @setting.destroy
  respond_with(@setting)
end

#editObject



39
40
# File 'app/controllers/admin/settings_controller.rb', line 39

def edit
end

#indexObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/admin/settings_controller.rb', line 4

def index
  @skip_filter = true
  @settings = Setting.order("key")
  
  if Fullstack::Cms.localized?
    @settings = @settings.where(:locale => params[:locale]) 
    @locale = params[:locale]
  end

  @groups = {}

  @settings.each {|s|
    @groups[s.group] ||= []
    @groups[s.group] << s
  }
 

  @groups = @groups.to_a

  @groups.sort! do |g1, g2|    
    if g1.first.to_s == "global"
      -1
    elsif g2.first.to_s == "global"
      1
    else  
      g1.first.to_s <=> g2.first.to_s
    end
  end
  
end

#newObject



35
36
37
# File 'app/controllers/admin/settings_controller.rb', line 35

def new
  @setting = Setting.new  
end

#updateObject



53
54
55
56
57
# File 'app/controllers/admin/settings_controller.rb', line 53

def update
  @setting.attributes = params[:setting]
  @setting.save
  respond_with(@setting)
end