Whle Ral a ll tak web ramework, by degn Raldoe not am to nlde every poble eatre Tere are many reaon that the Ral Core eam wold hooe not to nlde aeatre too ntable, too obre, or mply not needed n theore Ral dtrbton In at, there have been ntane whereeatre have been removed rom Ral and plaed nto a plgn!For example,
in_place_edit
and
auto_complete_for
were removedrom Ral n veron 0o help developer who are lookng to add, replae, ormody Ral' eatre et, Ral ha been blt wth a hghly extenble nratrtre Mot addton and modaton ome aplgn Whle many plgn extend one o the major lae nRal, lke
ActionView::Base
or
ActiveRecord::Base
, yo are reeto reate yor own lae or modle Moreover, plgn anhave ther own Rake ak and tet Eentally, plgn are el ontaned Ral pe lbrareOne o the bet way to e plgn the ree ode yond yorel ng rom projet to projet Robby Rell ha anexellent example h team at Planet Argon ed n ther applaton, Flah Meage Condtor Fndng that Ral' ah wanadeqate or ther applaton, they were rewrtng mh o trom applaton to applaton Te team reated a plgn thatadded helper to add meage, error, and note to ah anda new
render_flash_messages
method to render them n a vewBy ng Flah Meage Condtor n ther applaton, PlanetArgon ha an mproved ah, a ommon nterae, and n a very DRY ahonFor th artle, we wll ontrt a mple plgn that wlladd a qote method to or model Or goal very mplentonalty
a = User.newa.quote=> "If it bleeds, we can kill it."
We wll reate a Rake tak to generate a YAML le wth orqote, load that YAML le and e the data or or qoteWhle th a arly trval plgn, my am not to teah yohow to wrte a large, omplex plgn, bt gve yo the tart yoneed Let get tarted!Ral provde wth a generator or reatng plgn
script/generate plugin quote
T wll reate a bare plgn n yor
vendor/plugin
dretory wth the ollowng trtre:
init.rb
Loaded pon Ral tartng More ofen than not, twll reqre yor plgn le n the lb dretory
install.rb
Rn when yo ntall the plgn ng Ral'rpt/plgn ntall ommand
lib/
Te lb dretory atomatally added to Ral' loadpath Ually yor plgn ode wll rede here
MIT-LICENSE
Yor plgn hold nlde a lene, MI orotherwe
Rakefile
Te man Rake denton or yor plgn
README
Yo plgn' readme A hort ynop o yorplgn, t age, and any other note wold go here
tasks/
Any tom Rake tak an go here For or plgn,we wll reate one
test/
Yor plgn' tet hold go here When tet are rnon a plgn, Ral not loadedBeore we go any rther, we hold reate a plan or howexatly or qote plgn hold work Frt, we hold reate aRake tak whh reate or YAML le lled wth qote Aferor Rake tak ompleted, we wll reate an ntrb le that wllreqre the or qoterb le n the lb dretory and load orqoteyml le nto an array o qote We wll reate a newModle,
Quote::ClassMethods
to hoe or new method, and addthoe method to
ActiveRecord::Base
a to be avalable n model