concept ProjectsController in category ruby

appears as: ProjectsController, ProjectsController
Rails 4 in Action: Revised Edition of Rails 3 in Action

This is an excerpt from Manning's book Rails 4 in Action: Revised Edition of Rails 3 in Action.

1) Users can create new projects with valid attributes
   Failure/Error: click_link "New Project"
   AbstractController::ActionNotFound:
     The action 'new' could not be found for ProjectsController

This chapter guides you through restricting access to the CRUD operations of ProjectsController and TicketsController one by one, starting with reading and then moving on to creating, updating, and deleting. Any time a user wants to perform one of these actions, you’ll check if they have any roles that give them permission to do so (meaning whether or not they’re on the whitelist). During this process, you’ll become familiar with another gem called Pundit, which provides methods for your controllers and views that will help you check the current user’s ability to perform a specific action.

  • Translate roles into permissions (for example, :viewer of Project A means that the user can access the show action of the ProjectsController for Project A)
  • You can use that method in the show action of your ProjectsController, after loading the @project instance. Update the show action of the ProjectsController.

    Listing 8.8. The new show action of ProjectsController, Punditified
    def show authorize @project, :show? end
    Rails 3 in Action

    This is an excerpt from Manning's book Rails 3 in Action.

    Given I am on the homepage
      The action 'index' could not be found for ProjectsController ...
    When I follow "New Project"
      The action 'new' could not be found for ProjectsController

    Before you scope down this find, you must write a spec to test that the show action in the ProjectsController really does scope down this find, and if the project can’t be found, the controller should deny all knowledge of a project ever having existed.

    Flexible Rails: Flex 3 on Rails 2

    This is an excerpt from Manning's book Flexible Rails: Flex 3 on Rails 2.

    The script\generate scaffold command created more code in the controllers and views than in the models. In order to demystify it, we’ll look at the code that was created for the TasksController (the code for the ProjectsController and LocationsController is essentially the same). This code, shown in listing 5.15, is the basis for table 5.1; after you’ve read this code, that table will make more sense.

    Note that the solution isn’t “remove the id field from the form”: We’d still need to be wary of the user maliciously modifiying the form submission (for example, using Firebug). We need to fix this issue properly—and right now, as part of the security fixes. This vulnerability exists in the TasksController as well as in the ProjectsController and LocationsController (try it).