Edifice for Rails

CSS & JS the Rails way

Edifice makes your Rails life easier. It's designed to simplify CSS & JS integration in your Rails app by following the principle of DRY, less obtrusive markup. Stop writing unnecessary javascript boilerplate, stop wasting time namespacing view CSS and start enjoying rails again.

But really now, what is Edifice?

Edifice is a Rails gem that simplifies the way you manage your CSS and Javascript. Edifice is the part they left out of Rails; it makes your JS/CSS as elegant as your ruby by bridging the gap between your views and your styles.

Edifice-forms and edifice-widgets are companion gems that improve Rails' remote forms and unobtrusive javascript.

Namespacing CSS

Automatically generate a namespace for each of your views. Use it to fine tune styling on a page-by-page basis without worrying about altering your global names. After all thinking of names is hard, why not just use the view's name? Let edifice handle that for you:

Rather than:
<body id="user_profile">
<body class="<%= edifice_body_classes %>">
And you'll see something like:
<body class="c_users v_show l_application">
Page-level JS

Page-level Javascript

Condensing your sites javascript assets into one master file is a performance requirement these days. It gets pretty confusing when you only want to run certain bits of code on different pages. Edifice solves this problem by enabling view specific JS.

Just add:
userShow = {
  onReady: function() {
    alert('The users#show page is ready!');

The rest will be taken care of.

Global JS Widgets

Site-wide Javascript

Reluctant to separate your JS by views? Edifice-widgets & traits unobtrusively hook up standard behaviors for you

Just add:
<select name="country" data-widget="styled_select">
<input type="text" name="zipcode" data-trait="only_allow_numbers">

We'll take care of the rest (you'll have to tell us what a styled_select is and what only_allow_numbers means).

Simple forms with Edifice

Avoid form boilerplate

Tired of writing standard JS code to deal with form validation errors? Wondering why rails' UJS remote forms don't handle it for you? Let edifice-forms help you out:

Just add:
<form data-remote="true" data-form="show_errors">

And things will just work™.

Check it out

There's more! View the full documentation and instructions on github.

Rails 3+

Edifice is crafted by @tmeasday, @zolatme, and @domyen. It's released under the MIT license
See it in action on Bindle.me