Skip to content

iQvoc as a Rails Engine

mrreynolds edited this page Jun 20, 2012 · 18 revisions

To use iQvoc as a Rails Engine simply include the following into your Gemfile

gem 'iqvoc'

All models, controllers, views and routes iQvoc brings are automatically available in your app.

ApplicationController

iQvoc defines an ApplicationController on the top level namespace. At the moment you can't redefine it in your app without running into problems. One option would be to use another name.

Also remember to remove app/views/layouts/application.html.erb as iQvoc brings its own application layout file. Or, you can roll your own.

Asset pipeline

Probably your app comes with its own assets like CSS or JavaScript files. To properly use them in combination with iQvoc's core assets you have to structure your assets in a special manner to respect iQvoc's defaults; your asset directories have to look like this

app/assets/
|-- images
|-- javascripts
|   |-- iqvoc_your_app_name
|   |   |-- your_app_name.js
|   |   |-- foo.js
|   |   `-- manifest.js
|   `-- manifest.js
`-- stylesheets
    |-- iqvoc_your_app_name
    |   |-- your_app_name.css
    |   |-- bar.css
    |   `-- manifest.css
    `-- manifest.css

Your top-level manifest.[js|css] files should contain some defaults in order to load iQvoc's core assets. As an example, we show the expected contents for JavaScript assets. The same pattern must be applied to your CSS asset manifest.

app/assets/javascripts/manifest.js

//= require framework
//= require iqvoc/manifest

//= require your_app_name/manifest

app/assets/javascripts/your_app_name/manifest.js

//= require your_app_name/your_app_name
//= require your_app_name/foo
//= require your_app_name/bar

By suiting to this structure we are able to provide a sane and concise integration of both iQvoc's core assets as well as your custom assets within Rails 3.1 standards.