IntelliJ IDEA 2017.3 Help

Creating Views from Actions

This feature is only supported in the Ultimate edition.

The following is only valid when Ruby Plugin is installed and enabled!

Though a view for a controller is added by default on controller creation, it is also possible to define individual views for each public method of a controller.

To create a view for a method

  1. Open a controller in the editor, and locate the desired method.
  2. Click the view icon in the left gutter of the editor:
    ruby railsCreateAction2
  3. If a view associated with the method exists, it is opened in the editor. If a view doesn't exist, IntelliJ IDEA informs that the corresponding view is not found, and suggests to create a new one:
    ruby addView

    Specify the name of the view file. By default, IntelliJ IDEA suggests .html.erb. However, you can specify .haml file as well. Click OK. The new view file opens in the editor.

  4. Edit view contents as required. Note that you can insert Ruby code in view, surrounded with the <% and %> characters. Refer to the section Injecting Ruby Code in View for details.
Last modified: 6 March 2018

See Also