Turbocharge Ruby on Rails with ActiveScaffold
Author: ceefour | Filed under: Cool, GUI, Plugins, Rails, Ruby, Tips, Tools, Web 2.0If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!
ActiveScaffold is a plugin for Ruby on Rails (also known as Rails) that provides dynamic model-based view generation. Instead of having to create pages by hand that display your models, ActiveScaffold will introspect your ActiveRecord models and dynamically generate a CRUD (create, read, update, delete) user interface for managing those objects.
Installing ActiveScaffold
As ActiveScaffold is a Rails plugin, you can install it from a remote Web or Subversion server. The command below will check out the ActiveScaffold plugin from the ActiveScaffold Subversion server.
Install the latest version of the plugin:
script/plugin install http://activescaffold.googlecode.com/svn/tags/active_scaffoldAdd this to your layout:
<%= javascript_include_tag :defaults %> <%= active_scaffold_includes %>Add this to your controller:
active_scaffold :<your_model_name>
for example:
class UsersController < ApplicationController active_scaffold :user end
That’s it! Your first ActiveScaffold is up and running.
The Model
Most modern Web application frameworks are based on the MVC (model, view, controller) pattern, and Rails is no different. The model represents the data stored in the database with each table having a corresponding
ActiveRecordmodel class in Ruby.class User < ActiveRecord::Base belongs_torganization end class Organization < ActiveRecord::Base has_many :projects has_many :users end class Project < ActiveRecord::Base belongs_to
rganization has_many :projects_users has_many :administrators, :through => :projects_users, :source => :user, :conditions => "projects_users.role_type = 3" has_many :managers, :through => :projects_users, :source => :user, :conditions => "projects_users.role_type = 2" has_many :workers, :through => :projects_users, :source => :user, :conditions => "projects_users.role_type = 1" end class ProjectsUser < ActiveRecord::Base belongs_to :project belongs_to :user end
Visit ActiveScaffold home page to find out more!
P.S.: Happy New Year from AdaRuby.com crew (Hendy & Eka)!
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.