Class: GlobalizeTranslationSuggestionsController

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

Instance Method Summary collapse

Instance Method Details

#feedbackObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/globalize_translation_suggestions_controller.rb', line 19

def feedback
  @current_locale = params[:locale].blank? ? I18n.default_locale : params[:locale]

  @translations = GlobalizeTranslation.includes(:globalize_translation_suggestions).
                                       where(:locale => @current_locale).
                                       order(:key)

  unless params[:query].blank?
    @translations = @translations.where("value like ?", "%#{params[:query]}%")
  end

  @translations = @translations.offset(params[:page].to_i * 20).limit(40).all

  if request.xhr?
    render :partial => "globalize_translation", :collection => @translations
  else
    render :layout => 'globalize_feedback'
  end
end

#send_feedbackObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/globalize_translation_suggestions_controller.rb', line 4

def send_feedback
  if @translation_suggestion
    @translation_suggestion.increment!(:votes)
  else
    suggestion = @globalize_translation.globalize_translation_suggestions.build(:value => params[:body])

    if !suggestion.save
      render :json => { :errors => suggestion.errors.full_messages }, :format => "json", :status => :unprocessable_entity
      return
    end
  end

  render :nothing => true, :status => :ok
end