Creating Your First Rails Plug-in

If you already have Rails installed, you’re ready to craft your first plug-in. Let’s call this plug-in pdf_renderer:

​ 
$ ​rails plugin new pdf_renderer​

When we run this command we see the following output:

​ 
create
​ 
create README.rdoc
​ 
create Rakefile
​ 
create pdf_renderer.gemspec
​ 
create MIT-LICENSE
​ 
create .gitignore
​ 
create Gemfile
​ 
create lib/pdf_renderer.rb
​ 
create lib/tasks/pdf_renderer_tasks.rake
​ 
create lib/pdf_renderer/version.rb
​ 
create test/test_helper.rb
​ 
create test/pdf_renderer_test.rb
​ 
append Rakefile
​ 
vendor_app test/dummy
​ 
run bundle install

This command creates the basic plug-in structure, containing a pdf_renderer.gemspec ...

Get Crafting Rails 4 Applications, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.