RubyMine 7.0.0 Web Help

When creating a controller, use the products approach described in the section Creating Rails Application Elements.

RubyMine 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 RubyMine coding assistance features.

To create a controller and define actions and options in it, follow these steps
  1. As described in the section Creating Rails Application Elements, do one of the following:
    • On the main menu, choose Tools | Run Rails Generator.
    • Press Ctrl+Alt+GCtrl+Alt+GCtrl+Alt+GCtrl+Alt+GCtrl+Alt+GCtrl+Alt+GCtrl+Alt+GCtrl+Alt+GAlt+GAlt Command GAlt GAlt Command GAlt G.
    • With the editor, or the Project tool windows having the focus, press Alt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertCtrl+N or Alt+InsertAlt+InsertAlt+InsertCtrl+N or Ctrl+EnterCommand N or Control EnterControl N or Control EnterCommand N or Control EnterControl N or Control Enter, or choose New on the context menu of the Project tool window. Then choose Run Rails Generator.
  2. In the pop-up window, type controller.
  3. In the Add New Controller dialog box, type the controller name and actions delimited with spaces.
    6.0+

    Next, click the right arrow arrow_small_blue_right to reveal the fields for entering directory and additional options:

    ruby_railsCreateAction

  4. In the Options section, specify the target directory and options, and then click OK:

    ruby_railsCreateAction1.png

    Alternatively, open the desired controller in the editor, type the def keyword, then the action name, and press EnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnter. RubyMine automatically adds the closing end keyword, and marks the new action with the view icon in the left gutter.

    6.0+

    ruby_railsCreateAction2.png

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 ruby_methodPrivate.png and ruby_methodPublic.png icons respectively.

See Also

Procedures:

Web Resources: