concept view in category rails

appears as: views, view, views, view, The views
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.

This app directory has three main subdirectories: models, controllers, and views:

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.

Listing 8.34. An example of using Pundit’s policy helper in views
<% if policy(@project).update? %> <p>This displays if the user has the "update" permission on the @project.</p> <% else %> <p>This displays if the user doesn't have the "update" permission on the @project. No soup for you!</p> <% end %>

More on view specs can be found in the Rails documentation: www.relishapp.com/rspec/rspec-rails/v/3-2/docs/view-specs/view-spec.

Rails 3 in Action

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

In applications that don’t use MVC, the directory structure and how the different parts connect to each other is commonly left up to the original developer. Generally, this is a bad idea because different people have different opinions on where things should go. In Rails, a specific directory structure makes all developers conform to the same layout, putting all the major parts of the application inside an app directory. This app directory has three main subdirectories: models, controllers, and views.

During this process, you’ll see another gem called CanCan, which provides some methods for your controllers and views that help you check the current user’s permission to perform a specific action.

Because you’re overriding Devise’s controller, Rails won’t use Devise’s views. You must copy the views from Devise into your application and move them into the app/views/registrations directory. Lucky for you, Devise has a generator that places Devise’s views in your application: devise:views. You can run the generator with this command:

rails g devise:views

This command places Devise’s views into the app/views/devise directory of your application. This directory shares the same name as the directory internal to Devise where these views came from, and if a view exists in your application first, then Rails doesn’t look for it in the engines attached to the application. With these files copied over, move the app/views/devise/registrations directory out to app/views/registrations so you have some views to use for your new RegistrationsController.