<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>42 &#187; ActiveScaffold</title>
	<atom:link href="http://www.42.mach7x.com/tag/activescaffold/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.42.mach7x.com</link>
	<description>Thoughts and tips about programming with Ruby on Rails</description>
	<lastBuildDate>Wed, 01 Feb 2012 14:38:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>undefined method `render_component&#8217; with ActiveScaffold and Rails 2.3.2</title>
		<link>http://www.42.mach7x.com/2009/06/24/undefined-method-render_component-with-activescaffold-and-rails-2-3-2/</link>
		<comments>http://www.42.mach7x.com/2009/06/24/undefined-method-render_component-with-activescaffold-and-rails-2-3-2/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 15:32:03 +0000</pubDate>
		<dc:creator>kosmas</dc:creator>
				<category><![CDATA[ActiveScaffold]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[Rails 2.3.2]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=120</guid>
		<description><![CDATA[Problem When using a nested (or embedded) scaffold in ActiveScaffold with Rails 2.3.2 you have the error: undefined method `render_component' Solution According to the issue here, in Rails 2.3 the render_component has been removed. Install the render_component from: script/plugin install git://github.com/lackac/render_component.git -r rails-edge and restart your server, and it should be working.]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong><br />
When using a nested (or embedded) scaffold in ActiveScaffold with Rails 2.3.2 you have the error:</p>
<pre class="code">undefined method `render_component'</pre>
<p><strong>Solution</strong><br />
According to the issue <a href="http://code.google.com/p/activescaffold/issues/detail?id=685">here</a>, in Rails 2.3 the render_component has been removed.</p>
<p>Install the render_component from:</p>
<pre class="code">script/plugin install git://github.com/lackac/render_component.git -r rails-edge</pre>
<p>and restart your server, and it should be working.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2009/06/24/undefined-method-render_component-with-activescaffold-and-rails-2-3-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using ActiveScaffold in Rails 2.2 after using default scaffolding</title>
		<link>http://www.42.mach7x.com/2009/02/19/using-activescaffold-in-rails-22-after-using-default-scaffolding/</link>
		<comments>http://www.42.mach7x.com/2009/02/19/using-activescaffold-in-rails-22-after-using-default-scaffolding/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 10:05:05 +0000</pubDate>
		<dc:creator>kosmas</dc:creator>
				<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[ActiveScaffold]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=95</guid>
		<description><![CDATA[Problem You want to use ActiveScaffold in Rails 2.2, in a model that you have created using the standard Rails scaffolding script. Solution Install the ActiveScaffold plugin: script/plugin install git://github.com/activescaffold/active_scaffold.git -r rails-2.2 In your layout (model or application for all models) add the following: In your controller file delete all the standard scaffolding code and [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong><br />
You want to use ActiveScaffold in Rails 2.2, in a model that you have created using the standard Rails scaffolding script.</p>
<p><strong>Solution</strong></p>
<ol>
<li>Install the ActiveScaffold plugin:
<pre class="code">script/plugin install git://github.com/activescaffold/active_scaffold.git -r rails-2.2</pre>
</li>
<li>In your layout (model or application for all models) add the following:
<pre class="code"><%= javascript_include_tag :defaults %>
<%= active_scaffold_includes %></pre>
</li>
<li>In your controller file delete all the standard scaffolding code and add one line, so that your new controller should look like:
<pre class="code">class SomethingsController < ApplicationController
  active_scaffold :something
end</pre>
</li>
<li>To configure a RESTful scaffold add the following to your route.rb file:
<pre class="code">map.resources :somethings, :active_scaffold => true</pre>
</li>
<li>Delete the views that were created from the standard rails scaffolding in the views/somethings folder (edit, show, index ...)</li>
<li>Restart your server</li>
</ol>
<p>You should now have an active scaffold for your model.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2009/02/19/using-activescaffold-in-rails-22-after-using-default-scaffolding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding icons to ActiveScaffold&#8217;s actions</title>
		<link>http://www.42.mach7x.com/2007/11/16/adding-icons-to-activescaffolds-actions/</link>
		<comments>http://www.42.mach7x.com/2007/11/16/adding-icons-to-activescaffolds-actions/#comments</comments>
		<pubDate>Fri, 16 Nov 2007 16:26:57 +0000</pubDate>
		<dc:creator>kosmas</dc:creator>
				<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[ActiveScaffold]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/2007/11/16/adding-icons-to-activescaffolds-actions/</guid>
		<description><![CDATA[Problem You want to replace the standard text descriptions in ActiveScaffold&#8217;s actions with your icons. Solution Create a file called active_scaffold_overrides.css in ror_project/public/stylesheets 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. Create a directory my_images in ror_project/public/images/activescaffold to hold your images. Copy to the new [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong><br />
You want to replace the standard text descriptions in ActiveScaffold&#8217;s actions with your icons.</p>
<p><strong>Solution</strong></p>
<ol>
<li>Create a file called active_scaffold_overrides.css in ror_project/public/stylesheets</li>
<li>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.</li>
<li>Create a directory my_images in ror_project/public/images/activescaffold to hold your images.</li>
<li>Copy to the new directory the images you want to use in the application.</li>
<li>In the active_scaffold_overrides.css file find the section named:
<pre class="code">/* Table :: Actions (Edit,Delete) .... */</pre>
<p>and for each action that you want to use an icon add (ie edit)</p>
<pre class="code">.active_scaffold tr.record td.actions a.edit {
    display:     block;
    width:        16px;
    height:       16px;
    background: transparent url(../../../images/active_scaffold/my_images/image.png) no-repeat right 50%;
}</pre>
</li>
<li>In the application.rb, if you want the links to be the same for the whole application add:
<pre class="code">ActiveScaffold.set_defaults do |config|
    config.update.link.label =""
end</pre>
</li>
<li>in your layout/application.rhtml (create one if you don&#8217;t already have one), include
<pre class="code"><%= stylesheet_link_tag "active_scaffold_overrides" %></pre>
</li>
<li>Restart webrick/mongrel</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2007/11/16/adding-icons-to-activescaffolds-actions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Controller testing in Active Scaffold</title>
		<link>http://www.42.mach7x.com/2007/11/08/controller-testing-in-active-scaffold/</link>
		<comments>http://www.42.mach7x.com/2007/11/08/controller-testing-in-active-scaffold/#comments</comments>
		<pubDate>Thu, 08 Nov 2007 14:56:59 +0000</pubDate>
		<dc:creator>kosmas</dc:creator>
				<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[ActiveScaffold]]></category>
		<category><![CDATA[controller functional testing]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/2007/11/08/controller-testing-in-active-scaffold/</guid>
		<description><![CDATA[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&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong></p>
<p>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 <a href="http://www.oreilly.com/catalog/9780596527310/" target="_blank">Rails Cookbook</a>, or a fragment of code in an <a href="http://groups.google.com/group/activescaffold/browse_thread/thread/90678710553c6630/21b876d25aa8b804?lnk=gst&amp;q=controller+testing#21b876d25aa8b804" target="_blank">Active Scaffold application</a>, but they don&#8217;t have the full details.</p>
<p><strong>Solution</strong></p>
<p>Here is an attempt to give some more detailed step by step instructions on how to do it.</p>
<ol>
<li>The migration for the example customer model.</li>
<pre class="code">
class CreateCustomers &lt; ActiveRecord::Migration
  def self.up
    # Create customers table
    create_table  :customers do |t|
      t.column  :customer_code, :string, :null =&gt; false
      t.column  :created_at, :datetime
      t.column  :updated_at, :datetime
    end
  end
end</pre>
<li>The customer model, with the extra function to display the customer code</li>
<pre class="code">class Customer &lt; ActiveRecord::Base

  has_many    :numbers

  def to_label
    "#{customer_code}"
  end
end</pre>
<li>The customer controller app/controllers/customers_controller.rb, using the Active Scaffold</li>
<pre class="code">
class CustomersController &lt; ApplicationController

  active_scaffold :customer do |config|
    config.list.columns = [:customer_code, :numbers, :created_at, :updated_at]
    config.columns[:customer_code].inplace_edit = true
 end

end</pre>
<li>The fixtures YML file test/fixtures/customers.yml</li>
<pre class="code">
first_customer:
  id:               1
  customer_code:    123
  created_at:       2007-09-26 11:17:07
  updated_at:       2007-09-26 11:17:07

second_customer:
  id:               2
  customer_code:    456
  created_at:       2007-09-26 11:17:13
  updated_at:       2007-09-26 11:17:13</pre>
<li>And here are some functions to test some pages and a full CRUD test</li>
<pre class="code">
require File.dirname(__FILE__) + '/../test_helper'
require 'customers_controller'

class CustomerControllerTest &lt; Test::Unit::TestCase
  fixtures  :customers

  def setup
    @controller = CustomersController.new
    @request = ActionController::TestRequest.new
    @response = ActionController::TestResponse.new
  end

  def test_index
    get :index
    assert_response :success
    assert_template 'list'
  end

  def test_new
    get :new
    assert_response :success
    assert_template 'create_form'
  end

  def test_edit
    get :edit, :id =&gt; customers(:first_customer).id
    assert_response :success
    assert_template 'update_form'
  end

  def test_show
    get :show, :id =&gt; customers(:first_customer).id
    assert_response :success
    assert_template 'show'
  end

  def test_customer_controller_CRUD

    # CREATE
    # Get the number of records
    record_no = Customer.count
    # Create a new record
    post  :create, {"commit"=&gt;"Create", :record=&gt;{"customer_code"=&gt;"890"}}
    # Assert that the record is not nil
    assert_not_nil  assigns("record")
    # Look that the number of records has been increased by 1
    assert_equal  record_no+1, Customer.count

    # UPDATE
    # Get the number of records
    record_no = Customer.count
    # Update a record
    new_customer_code = "987"
    put :update, {"commit"=&gt;"Update",:id=&gt;customers(:first_customer).id,
                                      :record=&gt;{"customer_code"=&gt;new_customer_code}}
    # Assert that the record is not nil
    assert_not_nil  assigns("record")
    # Look that the number of records has stayed the same
    assert_equal  record_no, Customer.count
    # Check that the update took place
    customer = Customer.find(customers(:first_customer).id)
    assert_equal  new_customer_code, customer.customer_code

    # DELETE
    # Get the number of records
    record_no = Customer.count
    # Delete a record
    delete  :destroy, :id =&gt; customers(:first_customer).id
    # Look that the number of records has been decreased by 1
    assert_equal  record_no-1, Customer.count
  end

end</pre>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2007/11/08/controller-testing-in-active-scaffold/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>dhtmlcalendar in ActiveScaffold</title>
		<link>http://www.42.mach7x.com/2007/11/02/dhtmlcalendar-in-activescaffold/</link>
		<comments>http://www.42.mach7x.com/2007/11/02/dhtmlcalendar-in-activescaffold/#comments</comments>
		<pubDate>Fri, 02 Nov 2007 12:36:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[ActiveScaffold]]></category>
		<category><![CDATA[dhtmlcalendar]]></category>

		<guid isPermaLink="false">http://www.42.mach7x.com/?p=5</guid>
		<description><![CDATA[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] = &#8216;%d-%m-%Y&#8217; ii) If you only want to [...]]]></description>
			<content:encoded><![CDATA[<p>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:</p>
<p>i) if you want to affect the settings in all the application add the following to the top of your controllers/application.rb<br />
<span class="code"><br />
ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMAT[:default] = &#8216;%d-%m-%Y&#8217;</span><br />
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:</p>
<pre class="code">ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMAT[:default] = '%d-%m-%Y'</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.42.mach7x.com/2007/11/02/dhtmlcalendar-in-activescaffold/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

