djkazunoko / nijikai-go

テック系イベントの二次会参加者募集ツール
0 stars 0 forks source link

GroupのCRUDをscaffoldで生成する #57

Closed djkazunoko closed 7 months ago

djkazunoko commented 7 months ago

機能の説明

2次会グループの作成・表示・更新・削除

何故この機能が必要なのか

作成・表示・更新・削除を別issueに分けて進める予定だったが、一旦scaffoldでCRUDを生成して、そこから修正していった方が早いと判断したため。

完了条件

djkazunoko commented 7 months ago
bin/rails generate scaffold --help ``` $ bin/rails generate scaffold --help Usage: bin/rails generate scaffold NAME [field[:type][:index] field[:type][:index]] [options] Options: [--skip-namespace] # Skip namespace (affects only isolated engines) # Default: false [--skip-collision-check] # Skip collision check # Default: false [--force-plural], [--no-force-plural], [--skip-force-plural] # Do not singularize the model name, even if it appears plural # Default: false -o, --orm=NAME # ORM to be invoked # Default: active_record [--model-name=MODEL_NAME] # ModelName to be used [--resource-route], [--no-resource-route], [--skip-resource-route] # Indicates when to generate resource route # Default: true [--api], [--no-api], [--skip-api] # Generate API-only controller and tests, with no view templates # Default: false -c, --scaffold-controller=NAME # Scaffold controller to be invoked # Default: scaffold_controller ActiveRecord options: [--migration], [--no-migration], [--skip-migration] # Indicates when to generate migration # Default: true [--timestamps], [--no-timestamps], [--skip-timestamps] # Indicates when to generate timestamps # Default: true [--parent=PARENT] # The parent class for the generated model # Default: ApplicationRecord [--indexes], [--no-indexes], [--skip-indexes] # Add indexes for references and belongs_to columns # Default: true [--primary-key-type=PRIMARY_KEY_TYPE] # The type for primary key --db, [--database=DATABASE] # The database for your model's migration. By default, the current environment's primary database is used. -t, [--test-framework=NAME] # Test framework to be invoked # Default: rspec Rspec options: [--fixture], [--no-fixture], [--skip-fixture] # Indicates when to generate fixture [--fixture-replacement=NAME] # Fixture replacement to be invoked # Default: factory_bot [--singleton], [--no-singleton], [--skip-singleton] # Supply to create a singleton controller [--controller-specs], [--no-controller-specs], [--skip-controller-specs] # Generate controller specs # Default: false [--request-specs], [--no-request-specs], [--skip-request-specs] # Generate request specs # Default: true [--view-specs], [--no-view-specs], [--skip-view-specs] # Generate view specs # Default: true [--helper-specs], [--no-helper-specs], [--skip-helper-specs] # Generate helper specs # Default: true [--routing-specs], [--no-routing-specs], [--skip-routing-specs] # Generate routing specs # Default: true ScaffoldController options: [--helper], [--no-helper], [--skip-helper] # Indicates when to generate helper # Default: true [--skip-routes] # Don't add routes to config/routes.rb. -e, [--template-engine=NAME] # Template engine to be invoked # Default: slim [--jbuilder], [--no-jbuilder], [--skip-jbuilder] # Indicates when to generate jbuilder # Default: true Slim options: [--form-builder=NAME] # Form builder to be invoked Runtime options: -f, [--force] # Overwrite files that already exist -p, [--pretend], [--no-pretend], [--skip-pretend] # Run but do not make any changes -q, [--quiet], [--no-quiet], [--skip-quiet] # Suppress status output -s, [--skip], [--no-skip], [--skip-skip] # Skip files that already exist Description: Scaffolds an entire resource, from model and migration to controller and views, along with a full test suite. The resource is ready to use as a starting point for your RESTful, resource-oriented application. Pass the name of the model (in singular form), either CamelCased or under_scored, as the first argument, and an optional list of attribute pairs. Attributes are field arguments specifying the model's attributes. You can optionally pass the type and an index to each field. For instance: 'title body:text tracking_id:integer:uniq' will generate a title field of string type, a body with text type and a tracking_id as an integer with an unique index. "index" could also be given instead of "uniq" if one desires a non unique index. As a special case, specifying 'password:digest' will generate a password_digest field of string type, and configure your generated model, controller, views, and test suite for use with Active Model has_secure_password (assuming they are using Rails defaults). Timestamps are added by default, so you don't have to specify them by hand as 'created_at:datetime updated_at:datetime'. You don't have to think up every attribute up front, but it helps to sketch out a few so you can start working with the resource immediately. For example, 'scaffold post title body:text published:boolean' gives you a model with those three attributes, a controller that handles the create/show/update/destroy, forms to create and edit your posts, and an index that lists them all, as well as a resources :posts declaration in config/routes.rb. If you want to remove all the generated files, run 'bin/rails destroy scaffold ModelName'. Examples: `bin/rails generate scaffold post` `bin/rails generate scaffold post title:string body:text published:boolean` `bin/rails generate scaffold purchase amount:decimal tracking_id:integer:uniq` `bin/rails generate scaffold user email:uniq password:digest` ```
djkazunoko commented 7 months ago
bin/rails generate -h ``` $ bin/rails generate -h Usage: bin/rails generate GENERATOR [args] [options] General options: -h, [--help] # Print generator's options and usage -p, [--pretend] # Run but do not make any changes -f, [--force] # Overwrite files that already exist -s, [--skip] # Skip files that already exist -q, [--quiet] # Suppress status output Please choose a generator below. Rails: application_record benchmark channel controller generator helper integration_test jbuilder job mailbox mailer migration model resource scaffold scaffold_controller system_test task ActiveRecord: active_record:application_record active_record:multi_db Erb: erb:controller erb:mailer erb:scaffold FactoryBot: factory_bot:model Rspec: rspec:channel rspec:controller rspec:feature rspec:generator rspec:helper rspec:install rspec:integration rspec:job rspec:mailbox rspec:mailer rspec:model rspec:request rspec:scaffold rspec:system rspec:view Stimulus: stimulus Tailwindcss: tailwindcss:controller tailwindcss:mailer tailwindcss:scaffold TestUnit: test_unit:channel test_unit:controller test_unit:generator test_unit:helper test_unit:install test_unit:integration test_unit:job test_unit:mailbox test_unit:mailer test_unit:model test_unit:plugin test_unit:scaffold test_unit:system ```
djkazunoko commented 7 months ago
bin/rails g scaffold_controller -h ``` $ bin/rails g scaffold_controller -h Usage: bin/rails generate scaffold_controller NAME [field:type field:type] [options] Options: [--skip-namespace] # Skip namespace (affects only isolated engines) # Default: false [--skip-collision-check] # Skip collision check # Default: false [--force-plural], [--no-force-plural], [--skip-force-plural] # Do not singularize the model name, even if it appears plural # Default: false [--model-name=MODEL_NAME] # ModelName to be used [--helper], [--no-helper], [--skip-helper] # Indicates when to generate helper # Default: true -o, --orm=NAME # ORM to generate the controller for # Default: active_record [--api], [--no-api], [--skip-api] # Generate API controller # Default: false [--skip-routes] # Don't add routes to config/routes.rb. -e, [--template-engine=NAME] # Template engine to be invoked # Default: slim --resource-route # Indicates when to generate resource route # Default: true -t, [--test-framework=NAME] # Test framework to be invoked # Default: rspec [--jbuilder], [--no-jbuilder], [--skip-jbuilder] # Indicates when to generate jbuilder # Default: true Slim options: [--form-builder=NAME] # Form builder to be invoked Rspec options: [--singleton], [--no-singleton], [--skip-singleton] # Supply to create a singleton controller [--controller-specs], [--no-controller-specs], [--skip-controller-specs] # Generate controller specs # Default: false [--request-specs], [--no-request-specs], [--skip-request-specs] # Generate request specs # Default: true [--view-specs], [--no-view-specs], [--skip-view-specs] # Generate view specs # Default: true [--helper-specs], [--no-helper-specs], [--skip-helper-specs] # Generate helper specs # Default: true [--routing-specs], [--no-routing-specs], [--skip-routing-specs] # Generate routing specs # Default: true Jbuilder options: [--timestamps], [--no-timestamps], [--skip-timestamps] # Indicates when to generate timestamps # Default: true Runtime options: -f, [--force] # Overwrite files that already exist -p, [--pretend], [--no-pretend], [--skip-pretend] # Run but do not make any changes -q, [--quiet], [--no-quiet], [--skip-quiet] # Suppress status output -s, [--skip], [--no-skip], [--skip-skip] # Skip files that already exist Description: Generates a scaffolded controller, its seven RESTful actions and related views. Pass the model name, either CamelCased or under_scored. The controller name is retrieved as a pluralized version of the model name. To create a controller within a module, specify the model name as a path like 'parent_module/controller_name'. This generates a controller class in app/controllers and invokes helper, template engine and test framework generators. Example: `bin/rails generate scaffold_controller CreditCard` Credit card controller with URLs like /credit_cards. Controller: app/controllers/credit_cards_controller.rb Test: test/controllers/credit_cards_controller_test.rb Views: app/views/credit_cards/index.html.erb [...] Helper: app/helpers/credit_cards_helper.rb ```
djkazunoko commented 7 months ago

58 がマージされたため、closeします。