Warning: Creating default object from empty value in /homepages/39/d161420129/htdocs/p373.net/wp/wp-content/themes/p373b/admin/functions.php on line 183
ActiveScaffold and Rails 3.1.x without Asset pipeline

ActiveScaffold and Rails 3.1.x without Asset pipeline

We have recently upgraded an app to rails 3.1.3 and to keep things simple(or so we thought) we avoided jumping into the asset pipeline.

As expected, with rails, whenever you go against the grain, expect problems.

The app was working mostly, until we tested ActiveScaffold.  First off, I despise AS.  It has definitely caused me more headaches than it purportedly saves.  In rails 3 land, scaffolding is dead simple anyway, so why not build from scratch?

But alas, this is a legacy system, and we don’t have the luxury of ripping AS out and starting from scratch.

So, the first error, that we came across is:

undefined local variable or method `active_scaffold_includes'

I’ll spare you what it took to get this to work…Almost all of the tutorials say to use Vhocstein’s fork.  But as it turned out, this solved the initial problem, but I was getting a ton of other random issues like “ActiveRecord::InverseOfAssociationNotFoundError” errors.

In the end, I’m resorting to monkey patching until the official gem catches up.  I copied the “lib/active_scaffold/helpers/view_helpers.rb” file into “/lib/active_scaffold_monkeypatch.rb” and required it in application.rb

That solved the first issue.

To really get up and running I had to also do the following:

  1. We also were moving away from Prototype, and because I’m not using the assets pipeline, I had to make sure the proper jquery files were located in “public/javascripts/active_scaffold/default”.  You can find them in  the AS gem under “app/assets/javascripts/jquery” and just copy them over and remove the old Prototype files.
  2. Also, you cannot rely on
    javascript_include_tag :defaults

    You must explicitly include the jquery files(we use google cdn, cuz we’re cool like that)

        = javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js", "application.js"
  3. We updated our config/locals/en.yml to have
     en:
       hello: "Hello world"
    +  time:
    +    formats:
    +      default: "%a, %d %b %Y %H:%M:%S"

 

And that’s it, I think…our spec’s are passing as of now.

    This entry was posted in Coding, Ruby/Rails, Technology. Bookmark the permalink. Both comments and trackbacks are currently closed.