Class: PhrasingPhrasesController
- Inherits:
-
Object
- Object
- PhrasingPhrasesController
- Includes:
- PhrasingHelper
- Defined in:
- app/controllers/phrasing_phrases_controller.rb
Instance Method Summary collapse
- #destroy ⇒ Object
- #download ⇒ Object
- #edit ⇒ Object
- #help ⇒ Object
- #import_export ⇒ Object
- #index ⇒ Object
- #update ⇒ Object
- #upload ⇒ Object
Methods included from PhrasingHelper
Instance Method Details
#destroy ⇒ Object
55 56 57 58 59 |
# File 'app/controllers/phrasing_phrases_controller.rb', line 55 def destroy phrasing_phrase = PhrasingPhrase.find(params[:id]) phrasing_phrase.destroy redirect_to phrasing_phrases_path, notice: "#{phrasing_phrase.key} deleted!" end |
#download ⇒ Object
33 34 35 36 37 38 39 |
# File 'app/controllers/phrasing_phrases_controller.rb', line 33 def download app_name = Rails.application.class.to_s.split("::").first app_env = Rails.env time = Time.now.strftime('%Y_%m_%d_%H_%M_%S') filename = "phrasing_phrases_#{app_name}_#{app_env}_#{time}.yml" send_data Phrasing::Serializer.export_yaml(phrasing_phrases), filename: filename end |
#edit ⇒ Object
25 26 27 |
# File 'app/controllers/phrasing_phrases_controller.rb', line 25 def edit @phrasing_phrase = PhrasingPhrase.find(params[:id]) end |
#help ⇒ Object
16 17 |
# File 'app/controllers/phrasing_phrases_controller.rb', line 16 def help end |
#import_export ⇒ Object
13 14 |
# File 'app/controllers/phrasing_phrases_controller.rb', line 13 def import_export end |
#index ⇒ Object
19 20 21 22 23 |
# File 'app/controllers/phrasing_phrases_controller.rb', line 19 def index params[:locale] ||= I18n.default_locale @phrasing_phrases = phrasing_phrases @locale_names = PhrasingPhrase.distinct.pluck(:locale) end |
#update ⇒ Object
29 30 31 |
# File 'app/controllers/phrasing_phrases_controller.rb', line 29 def update request.xhr? ? xhr_phrase_update : phrase_update end |
#upload ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/controllers/phrasing_phrases_controller.rb', line 41 def upload number_of_changes = Phrasing::Serializer.import_yaml(params["file"].tempfile) redirect_to phrasing_phrases_path, notice: "YAML file uploaded successfully! Number of phrases changed: #{number_of_changes}." rescue => e = if params[:file].nil? 'Please choose a file.' else 'Please upload a valid YAML file.' end flash[:alert] = "There was an error processing your upload! #{}" render action: 'import_export', status: 400 end |