rails-engines

How to add dependency of a local gem to a rails plugin/engine, in .gemspec file

一曲冷凌霜 提交于 2019-11-30 16:26:05
问题 I had tried in this way: s.add_dependency 'gem', :path => '../gem' like add gem in the gemfile, but it doesn't work, and will cause this error: /Users/chenqh/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/requirement.rb:81:in `parse': Illformed requirement 回答1: It's likely not possible to add local dependencies because other users will not be able to access the gem as it is local dependent and hence of no use after publish. Instead of that, Add remote dependency in your own

Setting default_url_options for mounted Rails engine

爱⌒轻易说出口 提交于 2019-11-30 15:30:29
Using rails 3.2.13 and spree 2.0.2 I've encountered the similar problem as in Rails mountable engine under a dynamic scope My routes: scope ':locale', locale: /en|jp/ do mount Spree::Core::Engine, at: '/store' root to: 'home#index' end I want to output link to change locale: <%= link_to 'JP', url_for(locale: :jp) %> but this outputs: <a href="/en/store/?locale=jp">JP</a> instead of expected: <a href="/jp/store">JP</a> -- Edit -- When I put to ApplicationController : def default_url_options(options={}) { locale: I18n.locale } end it sets locale params in store twice instead of merging them:

Rails 3 Engine & Static assets

懵懂的女人 提交于 2019-11-30 13:05:53
问题 I'm building an engine I've bundled as a gem (gmaps4rails). I copied the /public of my engine in the /public of my rails app. Everything works fine in development but fails to work in production: it appears static assets (of my engine & my main app) aren't found. The logs tell the following (just an abstract): Started GET "/javascripts/application.js?1286294679" for 127.0.0.1 at Wed Nov 24 00:22:20 +0100 2010 ActionController::RoutingError (No route matches "/javascripts/application.js"):

Named routes in mounted rails engine

寵の児 提交于 2019-11-30 11:18:20
问题 I'm making a small rails engine which I mount like this: mount BasicApp::Engine => "/app" Using this answer I have verified that all the routes in the engine are as the should be: However - when I (inside the engine) link to a named route (defined inside the engine) I get this error undefined local variable or method `new_post_path' for #<#<Class:0x000000065e0c08>:0x000000065d71d0> Running "rake route" clearly verifies that "new_post" should be a named path, so I have no idea why Rails (3.1.0

How to call a parent app's helper method from a rails 3.1 engine

自古美人都是妖i 提交于 2019-11-29 23:53:02
问题 I'm building a rails engine that uses the "acts as" format to establish relationships with the parent application's User model. module Cornerstone module ActsAsCornerstoneUser extend ActiveSupport::Concern module ClassMethods def acts_as_cornerstone_user(options = {}) #= Associations has_many :cornerstone_discussions #= Options Cornerstone::Config.auth_with << options[:auth_with] if options[:auth_with] Cornerstone::Config.auth_with.flatten! end end module InstanceMethods end end ActiveRecord:

Named routes in mounted rails engine

时光怂恿深爱的人放手 提交于 2019-11-29 23:40:08
I'm making a small rails engine which I mount like this: mount BasicApp::Engine => "/app" Using this answer I have verified that all the routes in the engine are as the should be: However - when I (inside the engine) link to a named route (defined inside the engine) I get this error undefined local variable or method `new_post_path' for #<#<Class:0x000000065e0c08>:0x000000065d71d0> Running "rake route" clearly verifies that "new_post" should be a named path, so I have no idea why Rails (3.1.0) can't figure it out. Any help is welcome my config/route.rb (for the engine) look like this BasicApp:

Setting default_url_options for mounted Rails engine

流过昼夜 提交于 2019-11-29 22:02:35
问题 Using rails 3.2.13 and spree 2.0.2 I've encountered the similar problem as in Rails mountable engine under a dynamic scope My routes: scope ':locale', locale: /en|jp/ do mount Spree::Core::Engine, at: '/store' root to: 'home#index' end I want to output link to change locale: <%= link_to 'JP', url_for(locale: :jp) %> but this outputs: <a href="/en/store/?locale=jp">JP</a> instead of expected: <a href="/jp/store">JP</a> -- Edit -- When I put to ApplicationController : def default_url_options

Best way to require Haml on Rails3 engines

纵然是瞬间 提交于 2019-11-29 06:58:56
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 I was receiving template not found errors as it was not looking for the .haml views. I was thinking

i18n Routing To Mounted Engine - Ignoring locale

六眼飞鱼酱① 提交于 2019-11-29 04:32:25
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 language I choose, however, it always shows up in EN. Examining the parameters shows: --- !ruby/hash

Engine routes in Application Controller

房东的猫 提交于 2019-11-29 02:50:01
问题 I have a before_filter hook in my main app's application controller that does something like: (It doesn't just put a link in the flash, there is a message, but it isn't relevant to the question, it just accesses the route in the method) class ApplicationController < ActionController::Base before_filter :set_link def set_link flash[:notice] = items_path end end This works fine for the app, however when I go into the controllers for an engine I made I get the exception No route matches {