RubyMine 2017.1 Help

Creating Views from Actions

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:
    /help/img/idea/2017.1/ruby_railsCreateAction2.png
  3. If a view associated with the method exists, it is opened in the editor. If a view doesn't exist, RubyMine informs that the corresponding view is not found, and suggests to create a new one:
    /help/img/idea/2017.1/ruby_addView.png

    Specify the name of the view file. By default, RubyMine 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.

See Also

Last modified: 18 July 2017