Class: Gluttonberg::Admin::Settings::LocalesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/gluttonberg/admin/settings/locales_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



31
32
33
34
35
36
37
38
39
# File 'app/controllers/gluttonberg/admin/settings/locales_controller.rb', line 31

def create
  @locale = Locale.new(params["gluttonberg_locale"])
  if @locale.save
    flash[:notice] = "The locale was successfully created."
    redirect_to admin_locales_path
  else
    render :new
  end
end

#deleteObject



22
23
24
25
26
27
28
29
# File 'app/controllers/gluttonberg/admin/settings/locales_controller.rb', line 22

def delete
  display_delete_confirmation(
    :title      => "Delete “#{@locale.name}” locale?",
    :url        => admin_locale_path(@locale),
    :return_url => admin_locales_path , 
    :warning    => "Page localizations of this locale will also be deleted."
  )        
end

#destroyObject



51
52
53
54
55
56
57
58
59
# File 'app/controllers/gluttonberg/admin/settings/locales_controller.rb', line 51

def destroy
  if @locale.destroy
    flash[:notice] = "The locale was successfully deleted."
    redirect_to admin_locales_path
  else
    flash[:error] = "There was an error deleting the locale."
    redirect_to admin_locales_path
  end
end

#editObject



19
20
# File 'app/controllers/gluttonberg/admin/settings/locales_controller.rb', line 19

def edit
end

#indexObject



11
12
13
# File 'app/controllers/gluttonberg/admin/settings/locales_controller.rb', line 11

def index
  @locales = Locale.all
end

#newObject



15
16
17
# File 'app/controllers/gluttonberg/admin/settings/locales_controller.rb', line 15

def new
  @locale   = Locale.new
end

#updateObject



41
42
43
44
45
46
47
48
49
# File 'app/controllers/gluttonberg/admin/settings/locales_controller.rb', line 41

def update
  if @locale.update_attributes(params["gluttonberg_locale"]) || !@locale.dirty?
    flash[:notice] = "The locale was successfully updated."
    redirect_to admin_locales_path
  else
    flash[:error] = "Sorry, The locale could not be updated."
    render :edit
  end
end