Deface not working from engine - ruby-on-rails

I'm trying to use deface gem as a way to overwrite my core app views from a modules (engines). Deface works just great if i'm creating a .deface files in core_app/app/overrides/*. However, when i want to use it from my engine (by creating exact same files in core_app/engines/some_engine/app/overrides/*) it's not working anymore.
My engine is a "clean" engine created using rails plugin new command, trying to use deface was the first thing i've implemented there so there is nothing which can interfere with deface. At least from the plugin point of view.
I'm including my engine like this (in core app gemfile): gem 'some_engine', path: 'engines/some_engine'
Any help would be appreciated.

It was caused by the fact that i have used rails plugin new my_plugin_name without the
--mountable
flag. Add this flag and everything will work just fine.

Related

How to convert existing rails application to gem

I have a rails application that is kind of similar to the active_admin gem. I want to make this existing application into a gem.
I know that you can generate a gem with:
bundler gem gem_name_here
This command creates an empty gem. Which is fine I suppose, I just don't know where to put all my code.
You're ostensibly supposed to put all of your code in the /lib directory. However, my application has an assets pipeline and an app directory with all my models, controllers, and views. I don't know where to place all of these directories in the gem. Any thoughts or ideas?
If you need me to share any code, I'll gladly share it.
You're describing a rails engine. Engine is a miniature rails application that can be used inside other rails app. For more details see official rails guide

How to use react ecosystem with rails 3.2?

I just want to share with you an uncomfortable situation that I'm having right now and ask you for advice. It turns out that I'm developing a kind of old project by using rails 3.2 and ruby 2.0. Until now, as usual I've been creating the view layer with haml markup language. Recently I was assigned to implement a new set of UI requirements that seems to be a little complicated. So I was wondering if I could use the react library to do that. I'm using the react-rails gem to facilitate the integration and it works fine. But the problem comes in when I try to use a third party library like react-dropzone or react-modal or whatever react library. I have not been able to get it to work neither using rails-assets gems nor downloading directly the /dist files and require them with sprockets. Some of the errors that I get are:
typeError: undefined is not an object (evaluating 'webpack_require(3).unstable_renderSubtreeIntoContainer')
Can not find module 'react'
I don't know if I can easily setup a webpack server to compile these react libraries and then can be used along with react-rails and the specific version of rails 3.2. I've searched about the subject and I found the webpacker gem but it requires at least rails 4.2. I appreciate any comment or observation about what should I do.
I've finally solved my problem by using react_on_rails gem which allows an easy integration of React + Webpack + Rails, and also includes the server side rendering option.

Updating to Rails 3.2.2: How to properly move my plugin from the '/vendor' to '/lib' directory?

I am upgrading Ruby on Rails from 3.1 to 3.2.2 and I would like to know what I should make and at what I should be care in order to properly move my vendor plugin (note: it is not a gem and at this time I am not planning to make that a gem) from the directory /vendor to /lib as well as wrote in the official documentation:
Rails 3.2 deprecates vendor/plugins and Rails 4.0 will remove them completely. You can start replacing these plugins by extracting them as gems and adding them in your Gemfile. If you choose not to make them gems, you can move them into, say, lib/my_plugin/* and add an appropriate initializer in config/initializers/my_plugin.rb.
I refer mostly to the "an appropriate initializer in config/initializers/my_plugin.rb": What code should I put in that file?
More: Do you have some advice or alert on making the above process?
The initializer should contain the appropriate requires and other startup related tasks that are necessary for your plugin to work correctly. It's difficult to help you without real code examples from your app but this link should help you get started.
http://code.coneybeare.net/how-to-convert-simple-rails-23-style-plugins
The example in the link requires the plugin (now in the lib directory) and adds a module to ActiveRecord::Base.

Ruby On Rails CMS Framework

I want to create a framework for rails application. It will be a rails application but packed into gem (like a Radiant CMS).
It must work like this:
gem install cmsframework
and then:
cmsframework the_app
After that we have a skeleton framework for a rails app, without any controllers, etc. All controllers are loaded from cmsframework gem.
If I want to rewrite some files (for example public/styles.css), I must simply create it in my app (the_app).
If I want new functions in my app I can create a plugin. But the main functionalities must be loaded from cmsframework gem.
What is the best way to implement this?
Maybe start here: http://guides.rails.info/plugins.html. Pay close attention to the parts about adding custom generators and packaging as a gem. This may help as well: http://railscasts.com/episodes/218-making-generators-in-rails-3.
You can use this framework it is very good CamaleonCMS

Make Rails 2.3.5 aware of rails engine view path

According to the Ruby on Rails 2.3 Release Notes...
if your plugin has an app folder, then app/[models|controllers|helpers] will automatically be added to the Rails load path. Engines also support adding view paths now, and ActionMailer as well as Action View will use views from engines and other plugins.
There is supposed to be some way to make Rails aware of the app/views of your Rails engine, in 2.3. However, there is virtually no documentation on how this feature really works, that I can seem to find.
Can anyone help me get my view paths working from the context of a Rails Engine scenario?
IMPORTANT: The big issue is not with views as much as it is with partials. I need to be able to load partials from the view path of a rails engine.
Thanks!!
Turns out, I just needed to restart. This is done automatically by virtue of me defining a proper views directory within the nested app.
Durr!

Resources