app/controllers/rosetta/locales_controller.rb in rosetta-rails-0.1.1 vs app/controllers/rosetta/locales_controller.rb in rosetta-rails-0.2.0
- old
+ new
@@ -1,9 +1,11 @@
module Rosetta
class LocalesController < ApplicationController
+ before_action :ensure_default_locale_exists, only: :index
+
def index
- @locales = [ Locale.default_locale ] + Locale.all
+ @locales = Locale.order(default: :desc)
end
def new
@locale = Locale.new
end
@@ -21,9 +23,13 @@
)
end
end
private
+
+ def ensure_default_locale_exists
+ redirect_to new_default_locale_path unless Locale.default_locale
+ end
def locale_params
params.require(:locale).permit(:name, :code)
end
end