Sha256: d4f17d8208711fb552cdef62d40a047a86da9914e6dc5309684185cb9bccbd4e
Contents?: true
Size: 1.32 KB
Versions: 8
Compression:
Stored size: 1.32 KB
Contents
require 'rails/generators' require 'rails/generators/migration' require 'rails/generators/active_record' class SelectionsScaffoldGenerator < Rails::Generators::Base include Rails::Generators::Migration source_root File.expand_path('../templates', __FILE__) def self.next_migration_number(path) ActiveRecord::Generators::Base.next_migration_number(path) end def generate_selections_scaffold { 'selection_spec.rb' => 'spec/models/', 'selections_controller_spec.rb' => 'spec/controllers/', 'selections_controller.rb' => 'app/controllers/', 'selections_helper.rb' => 'app/helpers/', 'selections.yml' => 'spec/fixtures/', '_form.html.haml' => 'app/views/selections/', 'edit.html.haml' => 'app/views/selections/', 'index.html.haml' => 'app/views/selections/', 'new.html.haml' => 'app/views/selections/' }.each_pair do |file, dir| copy_file file, dir + file end model_source = if ActiveRecord::VERSION::MAJOR >= 4 'selection.rb' else 'selection_rails3.rb' end copy_file model_source, 'app/models/selection.rb' migration_template 'create_selections.rb', 'db/migrate/create_selections.rb' route 'resources(:selections, only: :index) { resources :selections, except: :show }' end end
Version data entries
8 entries across 8 versions & 1 rubygems