Class: Interpreter::TranslationsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/interpreter/translations_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
# File 'app/controllers/interpreter/translations_controller.rb', line 18

def create
  @translation = InterpreterTranslation.new params[:interpreter_translation]
  if @translation.save
    redirect_to interpreter_translations_url, :notice => "Translation added."
  else
    render :action => :new
  end
end

#destroyObject



41
42
43
44
# File 'app/controllers/interpreter/translations_controller.rb', line 41

def destroy
  count = InterpreterTranslation.destroy(params[:id].gsub('-','.'))
  redirect_to :back, :notice => "Translation destroyed."
end

#editObject



27
28
29
# File 'app/controllers/interpreter/translations_controller.rb', line 27

def edit
  @translation = InterpreterTranslation.find_by_key(params[:id].gsub('-','.'))
end

#indexObject



4
5
6
# File 'app/controllers/interpreter/translations_controller.rb', line 4

def index
  @translations = InterpreterTranslation.all
end

#newObject



14
15
16
# File 'app/controllers/interpreter/translations_controller.rb', line 14

def new
  @translation = InterpreterTranslation.new
end

#searchObject



8
9
10
11
12
# File 'app/controllers/interpreter/translations_controller.rb', line 8

def search
  @translations = InterpreterTranslation.find_all_by_value_like params[:query]
  @search_notice = "#{@translations.length} translation#{'s' if @translations.length > 1} found."
  render :action => :index
end

#updateObject



31
32
33
34
35
36
37
38
39
# File 'app/controllers/interpreter/translations_controller.rb', line 31

def update
  @translation = InterpreterTranslation.find_by_key(parse_id(params[:id]))
  @translation.update_attributes(params[:interpreter_translation])
  if @translation.save
    redirect_to interpreter_translations_url, :notice => "Translation updated."
  else
    render :action => :edit
  end
end