dnestoff
10/3/2016 - 1:52 AM

Rails: Scaffolding and Generation

In command line in a rails project you can generate a model and migration with an entire set of controller, views, with:

rails generate scaffold post title:string body:text published:boolean

------------- RESULTS OF COMMAND LINE CALL--------------------------------------------

Running via Spring preloader in process 86118

  invoke  active_record
  create    db/migrate/20161003014936_create_posts.rb
  create    app/models/post.rb
  invoke    test_unit
  create      test/models/post_test.rb
  create      test/fixtures/posts.yml
  invoke  resource_route
   route    resources :posts
  invoke  scaffold_controller
  create    app/controllers/posts_controller.rb
  invoke    erb
  create      app/views/posts
  create      app/views/posts/index.html.erb
  create      app/views/posts/edit.html.erb
  create      app/views/posts/show.html.erb
  create      app/views/posts/new.html.erb
  create      app/views/posts/_form.html.erb
  invoke    test_unit
  create      test/controllers/posts_controller_test.rb
  invoke    helper
  create      app/helpers/posts_helper.rb
  invoke      test_unit
  invoke    jbuilder
  create      app/views/posts/index.json.jbuilder
  create      app/views/posts/show.json.jbuilder
  create      app/views/posts/_post.json.jbuilder
  invoke  assets
  invoke    coffee
  create      app/assets/javascripts/posts.coffee
  invoke    scss
  create      app/assets/stylesheets/posts.scss
  invoke  scss
  create    app/assets/stylesheets/scaffolds.scss

bin/rails generate controller Articles bin/rails generate model Posts