MZaragoza
MZaragoza

Reputation: 10111

Rails engine extends config/application.rb

I am in the process of writing a Rails engine but i am not sure how to extend my the config/application.rb

I guess i have to get to the application name somehow any ideas?

require File.expand_path('../boot', __FILE__)

require 'rails/all'

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

module application_name
  class Application < Rails::Application
  end
end

Upvotes: 7

Views: 1171

Answers (1)

Aaron Mitchell
Aaron Mitchell

Reputation: 21

For a --full and --mountable engine

This will be generated for you.

module engine_name
  class Engine < ::Rails::Engine
  end
end

In you main applications gemfile add

gem 'engine_name', path: "/path/to/engine_name"

And in your applications config/routes.rb file

mount engine_name::Engine, at: "/<mount_point_you_choose>"

http://guides.rubyonrails.org/engines.html

Taken from the link above...

The --mountable option tells the generator that you want to create a "mountable" and namespace-isolated engine. This generator will provide the same skeleton structure as would the --full option, and will add:

Asset manifest files (application.js and application.css) A namespaced ApplicationController stub A namespaced ApplicationHelper stub A layout view template for the engine Namespace isolation to config/routes.rb:

Upvotes: 2

Related Questions