Active Scaffold for Rails: Many to Many
Yesterday I downloaded Active Scaffold and played around with it. I have to say its pretty nice and really easy to use.
- script/plugin install http://activescaffold.googlecode.com/svn/tags/active_scaffold
- create three tables items, baskets, and baskets_items (see SQL below)
- create a simple layout with two includes
< %= javascript_include_tag :defaults %>
< %= active_scaffold_includes %>
- create two models examples below SQL, Item and Basket and add has_and_belongs_to_many :items to Basket
- create two controllers one for Item and one for Basket and make sure each has the keyword active_scaffold
- navigate to items or baskets and enjoy!
SQL for tables
DROP TABLE IF EXISTS baskets;
CREATE TABLE baskets (
id INT(11) NOT NULL AUTO_INCREMENT,
basket_name VARCHAR(40) NOT NULL COMMENT 'name of the basket, should match event',
PRIMARY KEY (id)
)
ENGINE=INNODB;
DROP TABLE IF EXISTS items;
CREATE TABLE items (
id INT(11) NOT NULL AUTO_INCREMENT,
name VARCHAR(40) NOT NULL COMMENT 'name of the item',
qualities VARCHAR(40) NOT NULL COMMENT 'comma seperated list of qualities we may infer about the person consuming the item',
PRIMARY KEY (id)
)
ENGINE=INNODB;
DROP TABLE IF EXISTS baskets_items;
CREATE TABLE baskets_items (
basket_id INT(11) NOT NULL,
item_id INT(11) NOT NULL,
PRIMARY KEY (basket_id,item_id)
)
ENGINE=INNODB;
Many-to-Many models
class Basket < ActiveRecord::Base
has_and_belongs_to_many :items
end
class Item < ActiveRecord::Base
end
Controllers
class BasketsController < ApplicationController
layout "active_scaffold"
active_scaffold :basket
end
class ItemsController < ApplicationController
layout "active_scaffold"
active_scaffold :items
end
July 15th, 2010 at 10:37 am
< blockquote >< a href=”http://pillspot.org/”>Pillspot.org. Canadian Health&Care.Best quality drugs.No prescription online pharmacy.Special Internet Prices. No prescription pills. Buy pills online< /a >…
Buy:Cialis.Zithromax.Viagra Super Force.Maxaman.VPXL.Tramadol.Cialis Super Active+.Levitra.Soma.Viagra.Propecia.Cialis Professional.Viagra Professional.Cialis Soft Tabs.Viagra Soft Tabs.Viagra Super Active+.Super Active ED Pack….
July 20th, 2010 at 12:11 pm
< blockquote >< a href=”http://medicamentspot.com/”>MedicamentSpot.com. Canadian Health&Care.Best quality drugs.Special Internet Prices.No prescription online pharmacy. High quality pills. Buy pills online< /a >…
Buy:Ventolin.Aricept.Lasix.Zetia.Seroquel.Nymphomax.Lipitor.Lipothin.SleepWell.Amoxicillin.Benicar.Zocor.Female Pink Viagra.Cozaar.Advair.Wellbutrin SR.Female Cialis.Buspar.Prozac.Acomplia….
July 21st, 2010 at 9:32 pm
< blockquote >< a href=”http://medicamentspot.com/”>MedicamentSpot.com. Canadian Health&Care.Special Internet Prices.No prescription online pharmacy.Best quality drugs. High quality drugs. Order drugs online< /a >…
Buy:Mega Hoodia.Prednisolone.Arimidex.Lumigan.Zovirax.Valtrex.Petcam (Metacam) Oral Suspension.100% Pure Okinawan Coral Calcium.Zyban.Prevacid.Accutane.Actos.Synthroid.Nexium.Human Growth Hormone.Retin-A….
August 28th, 2010 at 11:47 pm
quote http://google.com : Love this keyword…
google…
August 29th, 2010 at 12:10 am
GT http://BESTPARTSPLUS.INFO/tag/GT : 110 Sony cdx/…
GT…
August 29th, 2010 at 12:14 am
18 Display Case airplanes water/ http://04FORDPARTS.US/tag/1 : 1…
1…
August 29th, 2010 at 12:24 am
f/2.8 http://03GMCPARTS.US/tag/sp af90mm f/2.8 di 1 : di…
sp…
August 29th, 2010 at 12:32 am
au Card XD/ http://ABABYCLOTHES.INFO/tag/r\x3dh : r\x3dh…
r\x3dh…
August 29th, 2010 at 3:18 am
dallas http://k4222njhsrr.05KIAPARTS.US/tag/Pop-up Canopy dallas ez/ : Pop-up…
Canopy…
August 29th, 2010 at 3:31 am
Flat http://nlge-d.03GMCPARTS.US/tag/Flat+Panel+lg+Sony/ : Panel…
Flat…
August 29th, 2010 at 3:53 am
pilot http://yhowkc7y.ACEHARDWAREE.INFO/tag/cabrio+pilot+a/ : pilot…
a…
August 29th, 2010 at 2:35 pm
Wide http://jairbrush48au.ANTIQUEFURNINISHING.INFO/tag/r2+super+Wide/ : super…
super…
August 29th, 2010 at 2:39 pm
under http://sunderuepqssr.02JEEPPARTS.US/tag/case+desk+under/ : case…
desk…
August 29th, 2010 at 5:47 pm
Service http://vsantag2mz.BABYCLOTHESNUT.INFO/tag/Distribution+Service+Press+Release/ : Distribution…
Distribution…
August 29th, 2010 at 5:50 pm
Shed http://zbullyphdrv.ACEHARDWAREE.INFO/tag/Smallwood+Shed+sheds+storage/ : sheds…
storage…
August 29th, 2010 at 7:00 pm
KitchenAid http://kstrontium3bj.01DODGEPARTS.US/tag/pink+Mixer+KitchenAid/ : KitchenAid…
pink…