Class: I18nFeedback::SuggestionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/i18n_feedback/suggestions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/i18n_feedback/suggestions_controller.rb', line 16

def create
  suggestion = Suggestion.new(suggestion_params)
  attribute_author(suggestion)

  if suggestion.save
    head :created
  else
    render json: { errors: suggestion.errors.full_messages }, status: :unprocessable_entity
  end
end

#indexObject

Pending suggestions for one key/locale, shown as read-only context when the proofreader reopens the popover for a string someone already flagged.



7
8
9
10
11
12
13
14
# File 'app/controllers/i18n_feedback/suggestions_controller.rb', line 7

def index
  suggestions = Suggestion
                .where(translation_key: params[:key], locale: params[:locale])
                .order(id: :desc)
                .limit(20)

  render json: suggestions.map { |suggestion| suggestion_json(suggestion) }
end