Class: Infold::SearchFormGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Infold::SearchFormGenerator
- Defined in:
- lib/generators/infold/search_form_generator.rb
Instance Method Summary collapse
Instance Method Details
#create_model_file ⇒ Object
20 21 22 |
# File 'lib/generators/infold/search_form_generator.rb', line 20 def create_model_file template "search_form.rb", Rails.root.join("app/forms/admin", "#{name.underscore.singularize}_search_form.rb"), force: true end |
#setup ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/generators/infold/search_form_generator.rb', line 11 def setup resource_name = name.camelize.singularize db_schema_file = Rails.root.join('db/schema.rb') db_schema = DbSchema.new(File.exist?(db_schema_file) ? File.read(db_schema_file) : nil) yaml = YAML.load_file(Rails.root.join("config/infold/#{resource_name.underscore}.yml")) resource = YamlReader.generate_resource(resource_name, yaml, db_schema) @writer = SearchFormWriter.new(resource) end |