rails-engines

Using the correct url_for method in a Rails engine spec

天大地大妈咪最大 提交于 2019-11-29 01:28:45
I have a request spec in a Rails engine. The view that is rendered calls a route and passes in a hash, i.e. projects_path(:scope => "user") . A route like this will eventually call url_for , but url_for is defined in many places. When running the application or running a request spec in the main app (root level), the call chain ends up at ActionView::RoutingUrlFor#url_for ; when running a spec in the engine, however, the call chain ends up at ActionView::Helpers::UrlHelper#url_for . In Rails 4, the url_for method defined in UrlHelper no longer accepts hash arguments, so I'm left with this

Rails 3.2 Engine Layouts

…衆ロ難τιáo~ 提交于 2019-11-28 23:15:44
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 admin/dashboard_controller.rb module Myengine class Admin::DashboardController < ApplicationController

Listing 'rake routes' for a mountable Rails 3.1 engine

流过昼夜 提交于 2019-11-28 23:09:07
I'm working on a mountable engine for use with Rails 3.1, and I want to list the engine's routes. I created the engine using: $ rails plugin new rails_blog_engine --mountable And edited the 'test/dummy/config/routes' file to read: Rails.application.routes.draw do mount RailsBlogEngine::Engine => "/blog" end ...and 'config/routes' to read: RailsBlogEngine::Engine.routes.draw do resources :posts end I want to list the routes generated for ':posts', but it's not clear how I can do this. When I run 'rake app:routes', I get only the "/blog" route: $ rake app:routes rails_blog_engine /blog {:to=

Migrations in Rails Engine?

自古美人都是妖i 提交于 2019-11-28 15:39:55
I have multiple rails applications talking to the same backend and I'd like them to share some migrations. I setup a rails engine (with enginex), I can share anything (controllers, views, models,...) but no migrations. I can't make it work ! I tried to create a file db/migrate/my_migration.rb but in my main application if I do : rake db:migrate It doesn't load them. After some googling it appears there was some recent work on this and it seems this has been merge to rails master. I'm with rails 3.0.3 do you see any way to make this work ? Thanks ! What i do, is add an InstallGenerator that

How to load correct version of dynamic libraries and gems (libxml, Nokogiri) within a custom Rails engine gem?

风流意气都作罢 提交于 2019-11-28 05:45:00
问题 I am building a rails engine that uses the Nokogiri gem and I'm having trouble with my development setup in MacOS 10.7 and 10.8: In order for Nokogiri to work properly in my setup, I updated the libxml and libxslt libraries with: brew update brew install libxslt brew upgrade libxml2 gem uninstall nokogiri gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.0/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.0/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1

Testing Rails 3.1 mountable engine with Rspec

三世轮回 提交于 2019-11-28 03:12:09
I started making a Rails 3.1 engine, and I'm having a hard time testing it using rspec. First of all, if I run rails g integration_test whatever it creates a regular integration test in tests/integration instead of spec/requests (the rspec-rails gem is installed and required as a development dependency in the gemspec file) Also, when I run a spec test I get an error saying the table corresponding to the model I'm testing has not been created. I tried rake engine_name:install:migrations and running rake db:migrate from inside the dummy app, and I get a "table already exists" error. Everything

Best way to require Haml on Rails3 engines

若如初见. 提交于 2019-11-28 00:38:10
问题 I'm developing a Rails3 engine application, and I want to use Haml for the views. First, what I have done was to add this to the engine Gemfile: gem "haml" While I was testing my engine, it was working OK (I have used https://github.com/josevalim/enginex to generate the gem and test it with the dummy application). My problems started when I tried to use the engine on a real Rails application. The application does not have gem "haml" on it's own Gemfile, and so it was not initializing Haml, so

Rails 3.1: Better way to expose an engine's helper within the client app

做~自己de王妃 提交于 2019-11-27 19:22:42
I have found a few articles addressing the issue of helpers within an engine not being accessible to the consuming (parent) application. To make sure we are all on the same page, let's say we have this: module MyEngine module ImportantHelper def some_important_helper ...do something important... end end end If you look at the rails engine documentation in the "Isolated engine's helpers" (L293), it says: # Sometimes you may want to isolate engine, but use helpers that are defined for it. # If you want to share just a few specific helpers you can add them to application's # helpers in

i18n Routing To Mounted Engine - Ignoring locale

送分小仙女□ 提交于 2019-11-27 18:23:57
问题 I have an application (my_test_app) with working i18n support built. Currently, there are two language files available, FR & EN, and if I toggle back and forth between them, everything works as I expect to see it for non-engine functions such as the User index/show/edit/delete (ISED) options. Within my_test_app I have a Rails Engine mounted (my_engine) which has a controller & model set (engine_job). So, a workable URL should be http://0.0.0.0:3000/fr/my_engine/engine_job No matter what

Using the correct url_for method in a Rails engine spec

隐身守侯 提交于 2019-11-27 15:55:27
问题 I have a request spec in a Rails engine. The view that is rendered calls a route and passes in a hash, i.e. projects_path(:scope => "user") . A route like this will eventually call url_for , but url_for is defined in many places. When running the application or running a request spec in the main app (root level), the call chain ends up at ActionView::RoutingUrlFor#url_for ; when running a spec in the engine, however, the call chain ends up at ActionView::Helpers::UrlHelper#url_for . In Rails