The Generate Controller Script Summarized

Before moving on, let’s consolidate the fundamental details of running the Rails generate controller script and learn a few extra tricks you can use when creating views. Each time a new controller is generated, it creates a Ruby code file in the app/controllers directory, with a name matching the name you entered but all in lowercase, with any noninitial capitals that you specified being preceded by an underscore and _controller appended. So, if you entered SayHello, the controller file will be called say_hello_controller.rb. The controller will contain a class definition such as SayHelloController. You may subsequently add to this class some “view methods” such as index and bye. Alternatively, you may ...

Get The Book of Ruby now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.