undefined method `render_component’ with ActiveScaffold and Rails 2.3.2

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem
When using a nested (or embedded) scaffold in ActiveScaffold with Rails 2.3.2 you have the error:

Solution
According to the issue here, in Rails 2.3 the render_component has been removed.

Install the render_component from:

and restart your server, and it should be working.

Using ActiveScaffold in Rails 2.2 after using default scaffolding

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem
You want to use ActiveScaffold in Rails 2.2, in a model that you have created using the standard Rails scaffolding script.

Solution

  1. Install the ActiveScaffold plugin:
  2. In your layout (model or application for all models) add the following:
  3. In your controller file delete all the standard scaffolding code and add one line, so that your new controller should look like:
  4. To configure a RESTful scaffold add the following to your route.rb file:
  5. Delete the views that were created from the standard rails scaffolding in the views/somethings folder (edit, show, index …)
  6. Restart your server

You should now have an active scaffold for your model.

Adding icons to ActiveScaffold’s actions

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem
You want to replace the standard text descriptions in ActiveScaffold’s actions with your icons.

Solution

  1. Create a file called active_scaffold_overrides.css in ror_project/public/stylesheets
  2. Copy the css code from ror_project/vendor/plugins/active_scaffold/frontends/default/stylesheets/stylesheet.css and paste it in to the file created in the previous step.
  3. Create a directory my_images in ror_project/public/images/activescaffold to hold your images.
  4. Copy to the new directory the images you want to use in the application.
  5. In the active_scaffold_overrides.css file find the section named:

    and for each action that you want to use an icon add (ie edit)
  6. In the application.rb, if you want the links to be the same for the whole application add:
  7. in your layout/application.rhtml (create one if you don’t already have one), include
  8. Restart webrick/mongrel

Controller testing in Active Scaffold

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

You need to have to functionally test your controller when you are using ActiveScaffold. There are pieces of code that tell you how to do that on a normal ror application (ie without ActiveScaffold), like recipe 7.17 on the Rails Cookbook, or a fragment of code in an Active Scaffold application, but they don’t have the full details.

Solution

Here is an attempt to give some more detailed step by step instructions on how to do it.

  1. The migration for the example customer model.
  2. The customer model, with the extra function to display the customer code
  3. The customer controller app/controllers/customers_controller.rb, using the Active Scaffold
  4. The fixtures YML file test/fixtures/customers.yml
  5. And here are some functions to test some pages and a full CRUD test

dhtmlcalendar in ActiveScaffold

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

To control the date format in dhtmlcalendar within ActiveScaffold in Ruby on Rails, to make the date of 2 November 2007 appear like 02-11-2007, use:

i) if you want to affect the settings in all the application add the following to the top of your controllers/application.rb

ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMAT[:default] = ‘%d-%m-%Y’

ii) If you only want to affect the settings of the calendar in one specific controller, then add the same line only to the controller that you want: