0

Как локализировать devise в rails приложении? у меня почему то при добавлении

В файле config/application.rb:

config.i18n.default_locale = :ru config.i18n.locale = :ru

Крашится при старте сервера с такой ошибкой

config/application.rb:16:in `<top (required)>': undefined local variable or method `config' for main:Object (NameError)

application.rb

require_relative 'boot'

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module AirPikachu
  class Application < Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.
  end
end
config.i18n.default_locale = :ru 
config.i18n.locale = :ru
4
  • Вы же эти два конфига написали в две разных строки, а не так, как в вопросе? 28 апр 2018 в 10:40
  • Да в две разные строки 28 апр 2018 в 11:04
  • А выложите весь код application.rb в вопрос, пожалуйста 28 апр 2018 в 11:21
  • @Василиса добавил 28 апр 2018 в 11:40

1 ответ 1

0

config должен быть внутри класса Application

module AirPikachu
  class Application < Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.   
    config.i18n.default_locale = :ru 
    config.i18n.locale = :ru
  end
end

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.