Search code examples
ruby-on-rails-3ruby-on-rails-plugins

Including assets and locales into gem Rails 3.2


I have smth like this in my Gemfile

gem 'plugin', :git => 'git://plugin.git'

And I want to add some assets and locales in my plugin, so I have to add pathes into Rails::Engine config. So I have smth like this in my init.rb

I18n.load_path += Dir[File.join(File.expand_path(File.dirname(__FILE__)), 'locales', '*.yml')]
Rails.application.class.config.assets.paths << File.join(File.expand_path(File.dirname(__FILE__)), 'assets')

And this works fine for locales, but not so I have an exception for assets (Rails.application.class.config is nil). So what is right way to do this?


Solution

  • Thank @phoet for the link. I look throw the code from his link and found this

    module JqueryMobileRails
      class Engine < ::Rails::Engine
      end
    end
    

    So I added this to lib/my_plugin.rb

    module MyPlugin
      class Engine < ::Rails::Engine
      end
    end
    

    And it works!