Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Rails (>=3.1) generator syntax for creating a subclass model / scaffold?

What is the command line syntax for generating a subclass model or scaffold in Rails?

rails g model Mysubclass my_field:string ....

How do I specify the parent class?

like image 824
Clay Avatar asked Jan 09 '12 17:01

Clay


1 Answers

You can use "--parent=ParentClass".

Example:

1) Create a parent class "User".

rails g scaffold User login:string

2) Create a child class "Teacher".

rails g scaffold Teacher url:string --parent=User

But remember: you still need to create migrations(adding columns in datatables) and change views(adding fields in forms).

like image 117
Duany Dreyton Avatar answered Sep 23 '22 01:09

Duany Dreyton