Sha256: 6557d28fcf40848d0b09964eb9599e89d16e5ee82d2439b1c242f71d8fa10e89

Contents?: true

Size: 1.79 KB

Versions: 1

Compression:

Stored size: 1.79 KB

Contents

Description:
    The first argument must be a Model. Next comes a list of name:form_element pairs that describe the model and it's database.
    We will generate a model, a migration, a controller and a route. Please do check the migration and the model because they will likely need tweaking.

Example:
    rails generate inline_forms Thing name:text_field description:text_area yesno:check_box gender:boolean_with_values

This will create:
      create  lib/app/models/thing.rb
      create  lib/app/controllers/things_controller.rb
       route  resources :things
      create  db/migrate/20110204074707_inline_forms_create_things.rb

      lib/app/models/thing.rb:
        class Thing < ActiveRecord::Base
          def _presentation
            #define your presentation here
          end
          def inline_forms_field_list
            [
                [ :name, 'name', :text_field ],
                [ :description, 'description', :text_area ],
                [ :yesno, 'yesno', :check_box ],
                [ :gender, 'gender', :boolean_with_values ],
            ]
         end
        end

        lib/app/controllers/things_controller.rb
            class ThingsController < InlineFormsController
            end

        config/routes.rb:
            ...
            resources :things
            ...

        db/migrate/20111015234500_inline_forms_create_things.rb
            class InlineFormsCreateThings < ActiveRecord::Migration
              def self.up
                create_table :things do |t|
                    t.string :name
                    t.text :description
                    t.boolean :yesno
                    t.boolean :gender
                    t.timestamps
                end
            end

            def self.down
              drop_table :things
              end
            end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
inline_forms-1.2.0 lib/generators/inline_forms/USAGE