FAQ Database Discussion Community


Override an open source Rails APP views, without editing the original views

ruby-on-rails,ruby-on-rails-4,rails-engines
I am currently working with a ROR App. The problem is the app was not created with much customization in mind. Note: This is a ROR APP, and not an engine I would like to: over-ride the current views Avoid editing the views in the app source code Change the...

Overriding the devise registrations controller in a Rails mountable engine

ruby-on-rails,rspec,devise,controller,rails-engines
I'm using devise inside a Rails engine (my_app/components/base) and override the registrations controller in order to forward the user to another page upon successful signup. This works quite well if I launch my_app, but for whatever reason devise doesn't use my custom registrations controller when launching the engine from the...

Host app and engine with same model name, rendering host app's model from inside engine using host app's partial, rails

ruby-on-rails,ruby,rails-engines
I have a host app unicorn with the model Article. I also have a mountable engine hooked into the host app called blorgh. It also has a model: Article. It is namespaced, so the table name for the engine's Article is actually blorgh_articles. What I am trying to do is...

Devise in a mounted engine uses wrong url for a 401

ruby-on-rails,ruby,devise,rails-engines,warden
I'm using Devise in a mounted engine (my_engine) in my Rails application (my_application). This works quite well, but there's still one problem: if a user tries to access a restricted resource (i.e. a page that's protected with a before_filter authenticate_user!) Devise/Warden generates a 401 response and redirects to the sign_in...

how can I provide engine methods available to parent rails application?

ruby-on-rails,ruby,gem,rails-engines
I am writing a rails engine. I have two methods(authenticate and current_user) in the gem inside application controller. https://github.com/krunal/aadhar/blob/master/app/controllers/aadhar/application_controller.rb I want 'authenticate' method should be available as a before_filter in parent rails application. I want 'current_user' method should be available as a method and helper in parent rails application ....

Moving Models into a gem - Rails 4.1

ruby-on-rails-3,model,namespaces,gem,rails-engines
I have a an Engine, Called Xaaron. and a Gem called core_models. I am trying to move, as an experiment, the user model of Xaaron into the gem. Eventually I want to move all the models from the engine into the gem. This is what I did, In the gem...

How do you use regular routes over engine routes

ruby-on-rails,routing,rails-engines
I have a rails application that mounts an engine, to use the engine route Id do engine_name.route_name_from_said_engine_path And to use the regular applications routes I would do route_name_path. While this works for non tested code, the second I run my tests, the tests fail, because of the application route "not...

Should I add engine's code to the app itself if I'm going to modify it a lot (Spree, Rails)?

ruby-on-rails,e-commerce,spree,rails-engines
I'm starting a new app with Spree and I'm going to heavily modify it. It seems impractical to go to source every time I need to change something. Should I just copy paste contents of spree/front_end engine to my app or should I do: Spree::Product.class_eval do def some_method ... end...

`circular dependency` - inheritance in application controller of Rails 4.2.0 engine

ruby-on-rails,ruby-on-rails-4,rails-engines
When upgrading engine from rails 3.2 to rails 4.2.0, the following inheritance in application controller causes circular dependency error in rspec: class ApplicationController < ApplicationController end We have config.eager_load = false for config/development.rb. The error: activesupport-4.2.0/lib/active_support/dependencies.rb:492:in `load_missing_constant': Circular dependency detected while autoloading con stant Authentify::ApplicationController (RuntimeError) Here is the rails...

How can I use fixtures from “dummy” in my Rails engine tests?

ruby-on-rails,ruby-on-rails-4,testing,rails-engines
I've created a Rails engine > rails plugin new my_engine --mountable In the dummy app, I create a model and fixtures... > cd test/dummy > rails generate resource Owner name:string I ensure there is fixture data. I write a test in the dummy app to make sure fixtures are working....

How to make dynamically added methods visible to Rails 4.2.0 controller?

ruby-on-rails-3,ruby-on-rails-4,rails-engines
Here is the way dynamic methods are added to application controller in Rails 3.2.12: module WfHelper extend ActiveSupport::Concern included do before_action :load_wf_action_def end protected def load_wf_action_def #load methods with eval() end end In application controller, the module wf_helper is included: include WfHelper All methods defined in load_wf_action_defare available to application...

how to use declartive_Authorization in rails engine

ruby-on-rails-3,rails-engines
I have used declartive_Authorization in my app. But I want this is my rails engine as well without duplicating rules. Otherwise I have to use declartive_Authorization in rail engine again but that won't be DRY concept. Thanks in advance....