Sha256: f890a8f67c7fc80abc942d93fcf7be04a420714e0f33c981732d968daec7a0e4
Contents?: true
Size: 895 Bytes
Versions: 3
Compression:
Stored size: 895 Bytes
Contents
module Dash class ResourceGenerator < Rails::Generators::NamedBase source_root File.expand_path('../templates', __FILE__) def add_scope insert_into_file "app/models/#{singular_name}.rb", after: /class #{singular_name.camelize}(.*)/ do "\n\n scope :filter, lambda { |filter| where('', filter: \"%\#{filter.to_s.downcase}%\") }" end end def create_templates @param_singular = ":#{singular_name}" @param_plural = ":#{plural_name}" @instance_singular = "@#{singular_name}" @instance_plural = "@#{plural_name}" @index_path = "dash_#{index_helper}_path" template 'resource_controller.rb', "app/controllers/dash/#{table_name}_controller.rb" template 'form.html.erb', "app/views/dash/#{table_name}/form.html.erb" template 'index.html.erb', "app/views/dash/#{table_name}/index.html.erb" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rails_dash-0.1.2 | lib/generators/dash/resource_generator.rb |
rails_dash-0.1.1 | lib/generators/dash/resource_generator.rb |
rails_dash-0.1.0 | lib/generators/dash/resource_generator.rb |