Taking advantage of Ruby on Rails Asset Compiler

Hello Everyone,

We would like to place our pure HTML+CSS with Javascript application
into a Ruby on Rails project within eclipse using Aptana. What we are
trying to take advantage of is Ruby on Rails Asset Pipeline.

Our project uses JQuery, Backbone and Bootstrap. So starting from the
top:

  1. I placed all 3rd part libraries in vendor/assets/javascripts
    (backbone-min.js, jquery-1.7.1.min.js,underscroe-min.js)
  2. Placed our javascript implementation in app/javascripts/
    (application.js, main.js, utils.js)
  3. Images in app/assets/images

Now this is where I want to make sure of a few things.

i) Where do we place the pure HTML code?
ii) As mentioned we are using backbone and not sure if:

Models:

window.Wine = Backbone.Model.extend({
urlRoot: “rs/wines”,
defaults: {
“id”: null,
“name”: “”,
“grapes”: “”,
“country”: “USA”,
“region”: “California”,
“year”: “”,
“description”: “”,
“picture”: “”
}
});

Views:

window.Wine = Backbone.Model.extend({
urlRoot: “rs/wines”,
defaults: {
“id”: null,
“name”: “”,
“grapes”: “”,
“country”: “USA”,
“region”: “California”,
“year”: “”,
“description”: “”,
“picture”: “”
}
});

window.WineCollection = Backbone.Collection.extend({
model: Wine,
url: “rs/wines”
});

Backbone Templates (HTML Fragments):

  • <%= name %>
  • Should be placed to take full advantage of what Asset Pipeline has to
    offer
    our HTML project. Things like
    minify etc…

    PS We do not use any ruby or rails code in our project.

    Your Help is Greatly Appreciated,

    Nick

    On Aug 5, 2013, at 10:01 AM, Nick K. wrote:

    1. Placed our javascript implementation in app/javascripts/ (application.js,
      main.js, utils.js)
      urlRoot: “rs/wines”,
      });
      “country”: “USA”,
      });

    Your Help is Greatly Appreciated,

    Nick

    Wow. This seems like an awful lot of extra work to get the benefits of
    the asset pipeline. Have you looked at any of the recent crop of
    static-site compiler desktop apps? See https://incident57.com/codekit/
    for one example (these seem to be popping up like daisies lately).

    Or the huge crop of command-line tools to do the same thing? See
    https://iwantmyname.com/blog/2011/02/list-static-website-generators.html
    for one list I found immediately.

    If you enable GZIP compression on your server, you could get a lot of
    these benefits for nearly no effort. See, the thing about the asset
    pipeline is that it is designed to give a highly dynamic Ruby-generated
    site the same sort of tools that the static site crowd already enjoy. I
    think you may be barking up the wrong tree here.

    Walter

    Hello Walter,

    Thank you so much for your response. Actually, a lot of people are
    migrating their front-end (HTML+CSS, JS, JQuery, Backbone…)to the
    rails
    style structure and using the asset pipeline, while their back end is
    implemented in Scala, Java…

    After discovering backbone-rails, we even managed to maintain our
    existing
    file structure for models, views, templates. We almost have everything
    structured the way we like except for a few things that we need some
    extra
    clarity on:

    1. Can we have a meaningful file structure for HTML pages within
      appand
      have them transferred over to public during compile, and have the
      pages
      served to us by redbrick. For deployment everything will be moved to
      apache…
    2. How to properly link to css and and js within our html pages to stay
      up-to-date with the newly compiled md5 fingerprinting scheme of the
      files
      i.e.:

    application-e3d92b1fc1ca1b0b4945dc0fd6ee932e.css
    application-1dcf4ccd0085287987410b49ebd8722c.js

    We tried adding the following to our html code:

    <%= javascript_include_tag “application” %>
    <%= stylesheet_link_tag “application” %>

    Thinking it would generate

    but it did not. Rails asset pipleine is one of the most mature out there and worth the little bit of "extra work".... Kind Regards, Nick.