rails-engines

Helpers in Rails engine

懵懂的女人 提交于 2019-12-21 10:32:42
问题 I am working on a rails engine and I have a problem with the helpers. Apparently this is a known "problem" but there's not a lot of solutions out there. The problem is that I have an AuthenticationHelper which I want to access globally - but it's not working. I've read that you could add a few lines to your init.rb but it does not seem to have any effect. Any idea what the best way to make an application available in an engine? EDIT: Fixed it- Just put the code (from the link) in the engine

Helpers in Rails engine

假如想象 提交于 2019-12-21 10:32:31
问题 I am working on a rails engine and I have a problem with the helpers. Apparently this is a known "problem" but there's not a lot of solutions out there. The problem is that I have an AuthenticationHelper which I want to access globally - but it's not working. I've read that you could add a few lines to your init.rb but it does not seem to have any effect. Any idea what the best way to make an application available in an engine? EDIT: Fixed it- Just put the code (from the link) in the engine

How to get the list of all engines in Rails 3 app

落花浮王杯 提交于 2019-12-20 23:32:00
问题 According to Rails engines extending functionality in Rails 2.x one could do Rails::Initializer.new(Rails.configuration).plugin_loader.engines This code is not working in Rails 3 ActionController::RoutingError (undefined method `new' for Rails::Initializer:Module): config/application.rb:12:in `require_or_load' What do I need to do in Rails 3 to get such list of engines? This is needed for Extending controllers of a Rails 3 Engine in the main app 回答1: As of 5/10/2011 and Rails 3.1 beta, it's

How to get the list of all engines in Rails 3 app

蓝咒 提交于 2019-12-20 23:30:05
问题 According to Rails engines extending functionality in Rails 2.x one could do Rails::Initializer.new(Rails.configuration).plugin_loader.engines This code is not working in Rails 3 ActionController::RoutingError (undefined method `new' for Rails::Initializer:Module): config/application.rb:12:in `require_or_load' What do I need to do in Rails 3 to get such list of engines? This is needed for Extending controllers of a Rails 3 Engine in the main app 回答1: As of 5/10/2011 and Rails 3.1 beta, it's

Can I run a Rails engine's specs from a real app which mounts it?

妖精的绣舞 提交于 2019-12-20 12:37:08
问题 I have a Rails Engine meant to provide some models and controllers to a larger project of ours. There's a pretty decent set of specs for the Engine, using a bunch of mocks and some full-scale models and controllers within the engine's dummy app to make sure the Engine is doing what it's supposed to and working with the larger application. However, even with all tests passing, I frequently find broken behavior when I update the engine in the larger application. If my tests are passing but the

How to test Rails 3 Engines with Cucumber & Rspec?

烂漫一生 提交于 2019-12-20 09:18:33
问题 I apologize if this question is slightly subjective... I am trying to figure out the best way to test Rails 3 Engines with Cucumber & Rspec. In order to test the engine a rails 3 app is necessary. Here is what I am currently doing: Add a rails test app to the root of the gem (myengine) by running: rails new /myengine/rails_app Add Cucumber to /myengine/rails_app/features as you would in a normal Rails app Require the Rails Engine Gem (using :path=>"/myengine" ) in /myengine/rails_app/Gemfile

Render engine within application layout

回眸只為那壹抹淺笑 提交于 2019-12-20 08:57:22
问题 Background I am creating a application that is made up of a core and several modules. The modules are rails engines, and provide the actual functionality as the core itself only acts as a host. The engines are hosted from /lib and mounted at their respective paths. coreApp └──lib ├── module1 ├── module2 └── etc The modules are then mounted like this mount Module1::Engine => "/module1", :as => "module1" mount Module2::Engine => "/module2", :as => "module2" The core is also responsible for

Overriding named routes provided by Rails 3 Engines

◇◆丶佛笑我妖孽 提交于 2019-12-18 21:49:51
问题 I am working on a Ruby on Rails 3(.0) application that uses a Rails engine. However, in my local application, I want to override one of the routes provided by the Rails engine. From the engine config/routes.rb: match 'their_named_route' => 'controller#action', :as => 'the_route' From my application config/routes.rb: match 'my_named_route' => 'controller#action', :as => 'the_route' However, when I inspect the routes, both seem to be active (and their route appears to "win", at least within the

Rails 3.2 Engine Layouts

本秂侑毒 提交于 2019-12-18 02:15:02
问题 I'm struggling to understand how Rails 3.2 applies layouts when using mountable engines. Scenario: I'm building an engine which itself has a dashboard view and an admin view for various admin functions. I want the dashboard to have its layout overridable by the base application (if the user desires) but the admin should always use its own layout. Here's what I have at the moment inside my engine; application_controller.rb module Myengine class ApplicationController < ActionController::Base

Multiple Rails engine rspec controller test not work

徘徊边缘 提交于 2019-12-14 01:10:03
问题 I have multiple Rails engines in my Rails 4 beta1 application. I'm installed rspec-rails gem to every engines. And I created my engine following command: rails plugin new store_frontend --dummy-path=spec/dummy -d postgresql --skip-test-unit --mountable In my engine's dummy application I configured database and routes. Here is example routes.rb file: Rails.application.routes.draw do mount StoreFrontend::Engine => "/store" end When I run rspec inside first engine I get following errors: 1)