rails-engines

Difference between add_dependency and add_runtime_dependency?

白昼怎懂夜的黑 提交于 2019-12-03 08:28:38
问题 What is the difference between using add_dependency and add_runtime_dependency in a Rails engine's gemspec? For example: Gem::Specification.new do |s| s.add_dependency 'jquery-rails' s.add_runtime_dependency 'jquery-rails' end What's the difference between them? 回答1: They are the same. add_dependency is just an alias for add_runtime_dependency . 来源: https://stackoverflow.com/questions/24333152/difference-between-add-dependency-and-add-runtime-dependency

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

时间秒杀一切 提交于 2019-12-03 08:12:43
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 As of 5/10/2011 and Rails 3.1 beta, it's now Rails::Application::Railties.engines This has changed with Rails 4.1. The accepted answer is deprecated

Ruby on Rails 3.1 Blog Engines

喜欢而已 提交于 2019-12-03 06:13:55
I see a lot of people asking about Blog Engines, but most of the questions & answers are rather old. Or if they aren't old most of the projects are old. I'm wondering if anyone knows of any Blog Engines that currently support Rails 3.1 or are at least being actively developed to support Rails 3.1. I would also be interested in seeing any sample applications or blog posts written for Rails 3.1 Blogs. I am going to be adding a blog to one of my websites, and would prefer to simply use a Rails Engine or sample code if there are any good ones out there. I hate reinventing the wheel. Looking for

How can I make routes from a Rails 3 engine available to the host application?

梦想的初衷 提交于 2019-12-03 05:34:42
I have a Rails 3 application with several engines containing additional functionality. Each engine is a separate service that customers can purchase access to. I am, however, having a problem with routes from the engines that aren't readily available to the controllers and views. controller: class ClassroomsController < ApplicationController .. respond_to :html def index respond_with(@classrooms = @company.classrooms.all) end def new respond_with(@classroom = @company.classrooms.build) end .. end app/views/classrooms/new.html.haml : = form_for @classroom do |f| .. f.submit config/routes.rb in

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

混江龙づ霸主 提交于 2019-12-03 03:51:25
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 behavior is broken, clearly something's wrong with the tests, but what? Am I mocking too much, or not

Rails Engine + Mongoid: No configuration could be found for a session named 'default'

你。 提交于 2019-12-03 03:02:32
I've created a Rails Mountable App and added 'mongoid' and 'rspec' gem's. If I try to run my specs now I get the following error: Mongoid::Errors::NoSessionConfig: Problem: No configuration could be found for a session named 'default'. Summary: When attempting to create the new session, Mongoid could not find a session configuration for the name: 'default'. This is necessary in order to know the host, port, and options needed to connect. Resolution: Double check your mongoid.yml to make sure under the sessions key that a configuration exists for 'default'. If you have set the configuration

Rails 3.0 Engine - Execute code in ActionController

丶灬走出姿态 提交于 2019-12-03 01:48:22
I am upgrading my Rails plugin to be an engine that works with the latest 3.0RC1 release and I'm having a bit of trouble figuring out the best (and most correct) way to extend ActionController . I've seen this post by DHH and this question here on SO, but my question is more about how to properly call code within the ActionController . For instance, I need to call the following within my engine's controller: class ApplicationController < ActionController::Base helper :all before_filter :require_one_user after_filter :store_location private def require_one_user # Code goes here end def store

Difference between add_dependency and add_runtime_dependency?

怎甘沉沦 提交于 2019-12-02 22:12:45
What is the difference between using add_dependency and add_runtime_dependency in a Rails engine's gemspec? For example: Gem::Specification.new do |s| s.add_dependency 'jquery-rails' s.add_runtime_dependency 'jquery-rails' end What's the difference between them? They are the same. add_dependency is just an alias for add_runtime_dependency . 来源: https://stackoverflow.com/questions/24333152/difference-between-add-dependency-and-add-runtime-dependency

How to test Rails 3 Engines with Cucumber & Rspec?

浪子不回头ぞ 提交于 2019-12-02 18:15:01
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 Add spec to the root directory of the gem: /myengine/spec Include the fixtures in /myengine/spec

Render engine within application layout

♀尐吖头ヾ 提交于 2019-12-02 17:30:46
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 handeling the session, although the login itself is done by a module. Problem I have yet to find a great