Petran
Petran

Reputation: 8047

How to generate model fields on rails 4?

I have run

rails generate Model Profile name:string

It have worked and generated all the files. When I see the profile.rb file though it only has the class declaration not the fields.

class Profile < ActiveRecord::Base
end

Do I have to add all the fields manually ?

Upvotes: 1

Views: 339

Answers (1)

Sergio Tulentsev
Sergio Tulentsev

Reputation: 230286

No, you don't to add fields manually. ActiveRecord will discover them at runtime from the table structure. This is part of rails magic :)

Upvotes: 2

Related Questions