Module: Ixtlan::Controllers::LocalesController

Defined in:
lib/ixtlan/controllers/locales_controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
# File 'lib/ixtlan/controllers/locales_controller.rb', line 5

def self.included(base)
  base.send(:include, Ixtlan::Controllers::SearchQuery)
  base.skip_before_filter :authenticate, :guard, :only => [:index,:show]
  base.cache_headers :public, true # no_store == true
end

Instance Method Details

#createObject

POST /locales POST /locales.xml



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/ixtlan/controllers/locales_controller.rb', line 57

def create
  @locale = LOCALE.new(params[:locale])
  @locale.current_user = current_user

  respond_to do |format|
    if @locale.save
      flash[:notice] = 'Locale was successfully created.'
      format.html { redirect_to(locale_url(@locale.id)) }
      format.xml  { render :xml => @locale, :status => :created, :location => locale_url(@locale.id) + ".xml" }
    else
      format.html { render :action => "new" }
      format.xml  { render :xml => @locale.errors, :status => :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /locales/1 DELETE /locales/1.xml



93
94
95
96
97
98
99
100
101
102
# File 'lib/ixtlan/controllers/locales_controller.rb', line 93

def destroy
  @locale = LOCALE.first_or_get(params[:id])
  @locale.destroy if @locale

  respond_to do |format|
    flash[:notice] = 'Locale was successfully deleted.'
    format.html { redirect_to(locales_url) }
    format.xml  { head :ok }
  end
end

#editObject

GET /locales/1/edit



51
52
53
# File 'lib/ixtlan/controllers/locales_controller.rb', line 51

def edit
  @locale = LOCALE.first_or_get!(params[:id])
end

#indexObject

GET /locales GET /locales.xml



19
20
21
22
23
24
25
26
# File 'lib/ixtlan/controllers/locales_controller.rb', line 19

def index
  @locales = query(LOCALE, :code)

  respond_to do |format|
    format.html
    format.xml  { render :xml => @locales }
  end
end

#newObject

GET /locales/new GET /locales/new.xml



41
42
43
44
45
46
47
48
# File 'lib/ixtlan/controllers/locales_controller.rb', line 41

def new
  @locale = LOCALE.new

  respond_to do |format|
    format.html # new.html.erb
    format.xml  { render :xml => @locale }
  end
end

#showObject

GET /locales/1 GET /locales/1.xml



30
31
32
33
34
35
36
37
# File 'lib/ixtlan/controllers/locales_controller.rb', line 30

def show
  @locale = LOCALE.first_or_get!(params[:id])

  respond_to do |format|
    format.html # show.html.erb
    format.xml  { render :xml => @locale }
  end
end

#updateObject

PUT /locales/1 PUT /locales/1.xml



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/ixtlan/controllers/locales_controller.rb', line 75

def update
  @locale = LOCALE.first_or_get!(params[:id])
  @locale.current_user = current_user

  respond_to do |format|
    if @locale.update(params[:locale]) or not @locale.dirty?
      flash[:notice] = 'Locale was successfully updated.'
      format.html { redirect_to(locale_url(@locale.id)) }
      format.xml  { render :xml => @locale }
    else
      format.html { render :action => "edit" }
      format.xml  { render :xml => @locale.errors, :status => :unprocessable_entity }
    end
  end
end