The Power of Rails 2.3 Engines & Templates

50 %
50 %
Information about The Power of Rails 2.3 Engines & Templates
Technology

Published on March 11, 2009

Author: tsechingho

Source: slideshare.net

The Power of Rails 2.3 Engines & Templates Tse-Ching Ho 2009/03/10

Rails app used to be rails engines_demo cd engines_demo script/generate scaffold product serial_number:string price:float discount:float quantity:integer name:string remark:string rake db:migrate sudo gem install png script/plugin install git://github.com/toretore/barby.git script/server

Use Template rails <app> -m ~/template.rb rails <app> -m http://gist.github.com/12345.txt rake rails:template LOCATION=~/template.rb

Commands for Template plugin(name, options) capify! gem(name, options = {}) freeze! rake(command, options = {}) initializer(filename, data = nil, &block) generate(what, *args) lib(filename, data = nil, &block) route(routing_code) rakefile(filename, data = nil, &block) run(command, log_action = true) vendor(filename, data = nil, &block) git(command = {}) file(filename, data = nil, log_action = true, &block) inside(dir = '', &block) load_template(template) ask(question) environment(data = nil, &block) yes?(question) gsub_file(relative_destination, regexp, no?(question) *args, &block) rails-2.3.0/lib/rails_generator/generators/applications/app/ template_runner.rb

Lessons for Template hooks related commands of one gem or plugin groups hooked commands into functional sets files one set in one template writes scaffold generation template for project combines templates for each project

Start the Engine script/generate plugin <your-plugin> cd vendor/plugins/<your-plugin> mkdir app config db move codes to your plugin

Issues in Rails 2.3 Gem App routes.rb not loaded when both engine and inflections present Allow ActionMailer to use view_paths from plugins Improve view performance in development and reinstate template reloading in production rake rails:freeze:edge Rake tasks for run engine migrations

Demo

Authlogic_Bundle http://github.com/ tsechingho/ authlogic_bundle Engines + template i18n + authlogic + open_id_authentication + declarative_authorization

barcode creator : barby http://github.com/toretore/barby created from template make into engines

Q&A

References http://guides.rubyonrails.org/2_3_release_notes.html http://m.onkey.org/2008/12/4/rails-templates http://railscasts.com/episodes/148-app-templates-in-rails-2-3 http://railscasts.com/episodes/149-rails-engines http://github.com/pixels-and-bits/strappy/ http://github.com/tsechingho/authlogic_bundle/ http://github.com/jeremymcanally/rails-templates/tree/master http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets? q=engines

Add a comment

Related presentations