7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'app/controllers/copycat_translations_controller.rb', line 7
def index
params[:locale] = I18n.default_locale unless params.has_key?(:locale)
query = CopycatTranslation
query = query.where(locale: params[:locale]) unless params[:locale].blank?
if params.has_key?(:search)
if params[:search].blank?
@copycat_translations = query.all
else
key_like = CopycatTranslation.arel_table[:key].matches("%#{params[:search]}%")
value_like = CopycatTranslation.arel_table[:value].matches("%#{params[:search]}%")
@copycat_translations = query.where(key_like.or(value_like))
end
else
@copycat_translations = []
end
@locale_names = CopycatTranslation.find(:all, select: 'distinct locale').map(&:locale)
end
|