12

I would like to create a structure with rails g scaffold Article, but I have already created the table Articles and model Articles.

Is there any way to do that?

user984621
  • 46,344
  • 73
  • 224
  • 412

2 Answers2

22

rails generate scaffold_controller Article

mikdiet
  • 9,859
  • 8
  • 59
  • 68
  • 5
    A short note: attribute names to be included in the generated views need adding otherwise the views will only contain the stub (at least for Rails 4). – smile2day Jul 31 '13 at 10:22
  • When run `scaffold_controller` generator script in Rails 4 found some bugs, if i don't make mistake. Generator `scaffold_controller` didn't create routes. It's normal? – Kirill Warp Aug 22 '13 at 12:53
2

Use rails generate scaffold_controller Article with parameters, example:

rails g scaffold_controller Article title:string body:text

Create views with attributes in tables

  • This is the better answer because this is the only one which also includes the data fields you'd like your views to incorporate. – Akash Agarwal Sep 07 '17 at 06:08