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
53 54 55 56 57 |
# File 'app/controllers/phrasing_phrases_controller.rb', line 53 def destroy phrasing_phrase = PhrasingPhrase.find(params[:id]) phrasing_phrase.destroy redirect_to phrasing_phrases_path, notice: "#{phrasing_phrase.key} deleted!" end |
#download ⇒ Object
31 32 33 34 35 36 37 |
# File 'app/controllers/phrasing_phrases_controller.rb', line 31 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
23 24 25 |
# File 'app/controllers/phrasing_phrases_controller.rb', line 23 def edit @phrasing_phrase = PhrasingPhrase.find(params[:id]) end |
#help ⇒ Object
14 15 |
# File 'app/controllers/phrasing_phrases_controller.rb', line 14 def help end |
#import_export ⇒ Object
11 12 |
# File 'app/controllers/phrasing_phrases_controller.rb', line 11 def import_export end |
#index ⇒ Object
17 18 19 20 21 |
# File 'app/controllers/phrasing_phrases_controller.rb', line 17 def index params[:locale] ||= I18n.default_locale @phrasing_phrases = phrasing_phrases @locale_names = PhrasingPhrase.distinct.pluck(:locale) end |
#update ⇒ Object
27 28 29 |
# File 'app/controllers/phrasing_phrases_controller.rb', line 27 def update request.xhr? ? xhr_phrase_update : phrase_update end |
#upload ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/phrasing_phrases_controller.rb', line 39 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 |