27.02.2013 Views

Rails%203%20In%20Action

Rails%203%20In%20Action

Rails%203%20In%20Action

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Summary<br />

Great! With the ability to delete users implemented, you’ve completed the CRUD for<br />

Admin::UsersController and for the users resource entirely. Now make sure you<br />

haven’t broken anything by running rake cucumber:ok spec. You should see this<br />

output:<br />

33 scenarios (33 passed)<br />

286 steps (286 passed)<br />

# and<br />

14 examples, 0 failures, 7 pending<br />

Fantastic! Commit and push that:<br />

git add .<br />

git commit -m "Added feature for deleting users,<br />

including protection against self-deletion"<br />

With this final commit, you’ve got your admin section created, and it provides a great<br />

CRUD interface for users in this system so that admins can modify their details when<br />

necessary.<br />

7.9 Summary<br />

For this chapter, you dove into basic access control and added a field called admin to<br />

the users table. You used admin to allow and restrict access to a namespaced controller.<br />

Then you wrote the CRUD interface for the users resource underneath the admin<br />

namespace. This interface is used in the next chapter to expand on the authorization<br />

that you’ve implemented so far: restricting users, whether admin users or not, to certain<br />

actions on certain projects. You rounded out the chapter by not allowing users to<br />

delete themselves.<br />

The next chapter focuses on enhancing the basic permission system you’ve implemented<br />

so far, introducing a gem called cancan. With this permission system, you’ll<br />

have much more fine-grained control over what users of your application can and<br />

can’t do to projects and tickets.<br />

163

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!