Ruby on Rails Plugins - Rich Collins

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

1 comments

Comments 1 - 1 of 1 previous next Post a comment

  • + abhilashv abhilashv 3 years ago
    how to change the core Rails validation error messages using plugins?

    Give details
Post a comment
Embed Video
Edit your comment Cancel

9 Favorites

Ruby on Rails Plugins - Rich Collins - Presentation Transcript

  1. Rails Plugins Rich Collins r [email_address] 813-391-1080
  2. Plugins Presentation Overview
    • What are plugins?
    • Why use them?
    • When are they useful?
    • How are they used?
    • How are they created
    • This is an interactive presentation. Stop me frequently to ask questions and see real code!
  3. What are Rails Plugins?
    • A set of files containing ruby code that modifies your Rails application
      • Rails Code
        • Models, Helpers, Controllers … etc
      • Libraries
      • Templates for Generators
      • Tests!
  4. What are Plugins?
    • Plugins are not just libraries … They often:
      • Modify existing Rails classes
      • Require database schema modification
      • Include code generation scripts
  5. What are Plugins?
    • Plugins are not quite Rails Engines. They usually don’t include:
      • View templates
      • Entire controllers
      • Independent “sub-applications”
  6. Why use Plugins?
    • “ Rails is opinionated software” – DHH
      • No authentication
      • Enter acts_as_authenticated
    • “ Start with no” – Getting Real
    • “ Fuck You” – DHH – Canada on Rails
      • Good luck getting new features accepted into rails
  7. When to use Plugins
    • You want to abstract common cross-application patterns to re-usable components:
      • Tagging of data - acts_as_taggable
      • Versioning of data - acts_as_versioned
      • Voting on data - acts_as_voteable
  8. When to use Plugins
    • Common Plugin Patterns:
      • Models:
        • acts_as: voteable, taggable, versioned … etc
      • Views:
        • Markaby, Google Maps, CSS Graphs, Rails Widgets … etc
      • Other:
        • Controllers, Tests … etc
  9. How to use Plugins
    • Locating:
      • script/plugin list
    • Installing:
      • script/plugin install acts_as_voteable
    • Updating:
      • script/plugin update acts_as_voteable
    • Removing:
      • Script/plugin remove acts_as_voteable
  10. How to use Plugins
    • README, Rdoc:
      • /README
      • rake doc:plugins
  11. How to use Plugins
    • Run Tests!
      • rake test:plugins
      • Use test generators if present
        • script/generate acts_as_voteable_test post
        • rake test
  12. How to use Plugins
    • The common acts_as pattern:
    • class User
    • acts_as_voter
    • end
    • class Post
    • acts_as_voteable
    • end
  13. How to use Plugins
    • The acts_as_voter and acts_as_voteable calls add methods to the User and Post classes:
      • User#vote_up
      • User#vote_down
      • Post#up_votes
      • Post#down_votes
      • Post.find_top
  14. How to use Plugins
    • Plugins often require database schema modifications
      • votes table
    • Good plugins make these modifications easy
      • script/generate acts_as_voteable migration
      • rake migrate
  15. How to use Plugins
    • Plugin Guts – Initialization Files
      • install.rb – is executed when plugin is installed
        • Generate code, run tests … etc
      • init.rb – is executed each time the application is restarted
        • Mixin modules, initialize variables … etc
  16. How to use Plugins
    • Plugin Guts – Directories
      • /lib
        • Modules, models … etc
      • /generators
        • Generator code and templates
      • /test
        • Tests for plugin verification
      • /tasks
        • rake tasks (also see Rakefile)
  17. How to use Plugins
    • Live Coding Session :S
  18. Plugin Recap
    • What are plugins?
      • Ruby code & scripts that modify and extend the Rails framework
    • Why use them?
      • Your features are unlikely to be added to Rails.
      • DRY, Modularity & Abstraction
  19. Plugin Recap
    • How do I use them?
      • script/install
      • rake test:plugins
      • script/generate [plugin related code]
      • Mixin plugin functionality. (edit models - add acts_as calls)
  20. Contact Info
    • Rich Collins
    • [email_address]
    • http://richcollins.net/
    • http://guruza.com/

+ richcollinsrichcollins, 4 years ago

custom

5825 views, 9 favs, 0 embeds more stats

Presentation that I gave at the August Ruby Meetup more

More info about this document

© All Rights Reserved

Go to text version

  • Total Views 5825
    • 5825 on SlideShare
    • 0 from embeds
  • Comments 1
  • Favorites 9
  • Downloads 0
Most viewed embeds

more

All embeds

less

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

Cancel
File a copyright complaint
Having problems? Go to our helpdesk?

Categories