Creating Controllers and Actions
When creating a controller, use the IntelliJ IDEA approach described in the section Creating Rails Application Elements.
IntelliJ IDEA suggests two ways of defining actions in controllers. First, you can define actions on creating a controller. Alternatively, it is also possible to edit the source code, enjoying the powerful IntelliJ IDEA coding assistance features.
To create a controller and define actions and options in it, follow these steps
- As described in the section Creating Rails Application Elements, do one of the following:
- On the main menu, choose .
- With the editor, or the Project tool windows having the focus, press Alt+Insert, or choose on the context menu of the Project tool window. Then choose .
- In the pop-up window, type
- In the Add New Controller dialog box, type the controller name and actions delimited with spaces.
Next, click the right arrow to reveal the fields for entering directory and additional options:
- In the Options section, specify the target directory and options, and then click OK:
Alternatively, open the desired controller in the editor, type the def keyword, then the action name, and press Enter. IntelliJ IDEA automatically adds the closing end keyword, and marks the new action with the view icon in the left gutter.
Using private and public modifiers results in hiding or showing view icons in the gutter, and, respectively disabling or enabling creation of views. In the Project tool window, such methods are marked as and icons respectively.