active_scaffold_acts_as_list issue with template_search_path

These days I am making an application using Active Scaffold.

I needed to have reordering functionality in my application and found a plugin for the same called "active_scaffold_acts_as_list". Getting it to work was really a tricky part. I kept on getting errors while starting my server:

/vendor/plugins/active_scaffold_acts_as_list/init.rb:5:in
`load’: wrong number of arguments (1 for 0) (ArgumentError)

After trying to look for a solution to this I first tried changing load with require and now I was getting a new error:

/vendor/rails/activesupport/lib/active_support/core_ext/module/aliasing.rb:
31:in `alias_method’: undefined method `template_search_path’
for class `Class’(NameError)

I was in doubt of this new problem being coming due to using require hence I tried looking for why load was not working and found that Rails::Plugin::Loader has already defined load method so a way to over come that was to use:

Kernel::load ‘config/core.rb’

I tried several things and thought that may be Active Scaffold was not getting loaded before active_scaffold_acts_as_list hence I tried to find out about the new feature I had heard recently in Rails on edge for specifying order or sequence for loading plguins.

I found a very useful article and even went through change logs on Rails trac after which I made changes to my environment.rb accordingly. But hard luck again it dint work :(

So I finally I went to Active Scaffold Google group and searched the discussion forum and found a thread that saved my life :)

It was more of a patch for fixing the exact problem I was facing and I followed what was suggested and viola now its working!!

Caching all the pages under a controller

I am working on a new Rails project these days and I was being asked to cache all the static pages displaying site’s static content. All the content was coming from one controller but I went crazy about implementing page caching by using caches_page, what I wanted to do was cache all the page in one go. Syntax for caching one or more pages is:

class WeblogController < ActionController::Base
 caches_page :show, :new
end

Now it is really a bad idea to go about writing all the content page names to ensure that they are cached. Even after looking for a solution to this on Internet  I was unable to work out anything un-till I landed on a blog which was talking about a similar kind of problem. In responses to that post I finally found the solution:

after_filter lambda { |c| c.cache_page }, :except => [:show]

You are basically required to add a after filter to your controller of which you wish to cache all the pages, inside the except configuration you can specify the names of actions which you don’t want to be cached. So in short this works exactly the opposite of caches_page syntax.

Next Page →