rails-engines

How can I avoid Devise from requires authentication from within an engine?

蓝咒 提交于 2020-01-05 23:27:53
问题 I'm using Devise for athentication in my main application and I have built an API (for a PABX) using "http_basic_authenticate_with" and it's working well when I add before_action :authenticate_user!, except: [:method_name] to my controller. I'm doing that because except: [:method_name] will not require a logged user session on Devise and I just want to use basic authenticate for those API controllers. config/routes.rb (main application) scope module: 'api' do scope module: 'pabx' do scope '

how to override rails 3 engine models and controllers in the main application?

浪尽此生 提交于 2020-01-05 10:20:49
问题 I want to be able to override models and controllers of my rails 3 engine in the base app. Inspecting $LOAD_PATH, I found engine's 'app/{models,controllers}' there, but I can't explicitly require engine's model or controller file: require 'engine_name/model_name' fails with "no such file" (tried with both namespaced(app/controllers/enginename/*) and plain engine). So, what's the best way to extend engine's models/controllers in rails 3 without copying them to base app? Basically, it's a load

How to recongnise routes in a Rails App

寵の児 提交于 2020-01-04 05:04:21
问题 I have this very basic question. I am using this dashboard rails engine, and this gives me a views/layouts/dashing/dashboard.html.erb . This is the layout of the dashboard view. But I want to customize this view, like add a navigation bar, that has a link which point to my about_path . However, none of the routes are recognized in the dashboard view. It results in an error undefined method about_path . But the about_path route is defined in my routes file and is working fine in other views

Rails Engine Thread Safety - ActiveResource

ε祈祈猫儿з 提交于 2020-01-03 22:02:11
问题 My Rails 3.1 app uses an engine and I want to know if access to this engine is threadsafe. I have /lib/mymodule.rb in the engine and it looks something like this: module MyModule def self.my_method() begin data = WebResource.find(:all) # Where WebResource < ActiveResource::Base rescue data = nil end return data end end Then in my views/controllers, I call this method like this: MyModule::WebResource.headers[:some_id] = cookies[:some_id] MyModule::my_method() In my main app, I have the

Reopening Rails 3 engine classes from parent app

余生长醉 提交于 2020-01-02 03:27:08
问题 As it stands now, you can't reopen Engine classes contained within the engine's /app directory by simply adding the same class in the parent app's /app dir. For example: /my_engine/app/controllers/users_controller.rb /my_app/app/controllers/users_controller.rb The file from my_engine will not even load if there is a file with the same name in the parent app. More details here: http://www.cowboycoded.com/2011/02/28/why-you-cant-reopen-rails-3-engine-classes-from-the-parent-app/ I am looking

rails 3.1.1 engines - with mountable engines, is it possible to access parent app assets, default layout?

亡梦爱人 提交于 2020-01-01 05:22:16
问题 This is more for experimentation - I am aware that I can do this with --full but I wanted the functionality of namespacing in the app to avoid conflicts The idea is to have a main app - which handles authentication, common items, admin screens etc Then creating engines to add further functionality like crm cms blog wiki forum etc These engines I can pick and choose as I need for whatever kind of app I am building. Is this possible? Is it just the case of applying both --mountable and --full

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

谁说胖子不能爱 提交于 2020-01-01 01:53:08
问题 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 ..

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

浪子不回头ぞ 提交于 2020-01-01 01:53:07
问题 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 ..

Rails::Engine namespacing controller and models

别等时光非礼了梦想. 提交于 2019-12-24 18:59:53
问题 I followed the following tutorial: http://www.themodestrubyist.com/2010/03/05/rails-3-plugins---part-2---writing-an-engine/ And it all works great. I namespaced the controller using #app/controller/authr/accounts_controller.rb module Authr class AccountsController < ApplicationController unloadable def new @account = Account.new end def create @account = Account.new(params[:account]) if @account.save redirect_to '/' else render :action => :new end end end end And in the tutorial he didn't

How to use SASS, HAML, and CoffeeScript in Rails 3.2.x Engine?

此生再无相见时 提交于 2019-12-24 09:57:33
问题 Currently, I have a Rails 3.2.9 Engine which is using sass-rails . When I generate a controller with a couple actions, the assets are also generated (i.e., javascript and CSS). However, both the Javascript and SASS are *.js and *.css files. They're not CoffeeScript ( *.js.coffee ) or SASS ( *.css.sass ). Any ideas how to get this work? 回答1: Here's a different solution which will use the coffee-rails and sass-rails gems by default - also fixes haml-rails . I added this to the top of my engine