Class: Admin::Api::LanguagesController

Inherits:
Admin::ApiController
  • Object
show all
Defined in:
app/controllers/admin/api/languages_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/admin/api/languages_controller.rb', line 11

def create
	@language = Odania::Language.new(language_params)

	if @language.save
		flash[:notice] = t('created')
		render action: :show
	else
		render json: {errors: @language.errors}, status: :bad_request
	end
end

#destroyObject



31
32
33
34
35
36
# File 'app/controllers/admin/api/languages_controller.rb', line 31

def destroy
	@language.destroy

	flash[:notice] = t('deleted')
	render json: {message: 'deleted'}
end

#indexObject



4
5
6
# File 'app/controllers/admin/api/languages_controller.rb', line 4

def index
	@languages = Odania::Language.order('iso_639_1 ASC')
end

#showObject



8
9
# File 'app/controllers/admin/api/languages_controller.rb', line 8

def show
end

#updateObject



22
23
24
25
26
27
28
29
# File 'app/controllers/admin/api/languages_controller.rb', line 22

def update
	if @language.update(language_params)
		flash[:notice] = t('updated')
		render action: :show
	else
		render json: {errors: @language.errors}, status: :bad_request
	end
end