lib - generators - gemname install_generator.rb - templates (template files)
require 'rails/generators' module ModuleName module Generators class InstallGenerator < Rails::Generators::NamedBase include Rails::Generators::Migration source_root File.expand_path("../templates", __FILE__) generators... def self.next_migration_number(path) @migration_number = current_migration_number(path) + 1 ActiveRecord::Migration.next_migration_number(@migration_number) end end end end
def generators generate("controller" , "nameOfController") copy_file "fileWantYouCopy.rb" , "app/models/destiniAndNameToCopiedFile.rb" migration_template("modelOfMigrate.rb" , "db/migrate/modelOfMigrateDestini.rb") end
You need add this include to use migration_template
include Rails::Generators::Migration
You need to implement next_migration_number
def self.next_migration_number(path) @migration_number = current_migration_number(path) + 1 ActiveRecord::Migration.next_migration_number(@migration_number) end
-
Gem previsao-clima-tempo
Blocks Writing methods that can accept blocks is simple. There’s no special syntax needed, you can simply write the method as you would any other. To call any block passed to the method, use the...
What is it? {% highlight ruby %} gem ‘turbolinks’ {% endhighlight %} “This is a gem that works similar to pjax, but instead of worrying about what element on the page to replace, and tailoring ...
Communication with Clima Tempo accessing information about the weather of Brazil. Installation Add this line to your application’s Gemfile: {% highlight ruby %} gem ‘previsao-clima-tempo...