Sha256: 1bedda50f6a8987a033cae7e28c8403e99998206b094914e5a9a116dca0e06f2
Contents?: true
Size: 1.24 KB
Versions: 5
Compression:
Stored size: 1.24 KB
Contents
module Model class TagsGenerator < Rails::Generators::NamedBase source_root File.expand_path('../templates', __FILE__) argument :field, type: :string, default: [], banner: "model field" def copy_initializer_file @app_name = file_name @field = field inject_into_file "app/assets/javascripts/application.js", after: "//= require jquery_ujs" do <<-JS //= require bootstrap-tagsinput JS end inject_into_file "app/assets/javascripts/initializer.js", after: "atualiza_campos_crud(){" do <<-JS $("input[data-role=tagsinput], select[multiple][data-role=tagsinput]").tagsinput(); JS end inject_into_file "app/assets/stylesheets/application.css.scss", before: "*= require style" do <<-SCSS *= require bootstrap-tagsinput SCSS end inject_into_file "app/models/#{file_name}.rb", after: "ActiveRecord::Base" do <<-RUBY acts_as_taggable_on :#{@field.pluralize} def self.params_permitt [:#{@field.singularize}_list] end RUBY end gem 'acts-as-taggable-on', '~> 3.4' gem 'bootstrap-tagsinput-rails' Bundler.with_clean_env do run "bundle install" run "rake acts_as_taggable_on_engine:install:migrations" run "rake db:migrate" end end end end
Version data entries
5 entries across 5 versions & 1 rubygems