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.

242 CHAPTER 9 File uploading<br />

After multiple-file uploading, you learned how to restrict which files are served<br />

through your application by serving them through a controller. By using a controller,<br />

you can use CanCan’s can? helper to determine if the currently signed-in user has<br />

access to the requested asset’s project. If so, then you give the user the requested asset<br />

using the send_file controller method. If not, you deny all knowledge of the asset<br />

ever having existed.<br />

Finally, you used a JavaScript library called jQuery, in combination with a simpler<br />

way of writing JavaScript called CoffeeScript, to provide users with an Add Another<br />

File link. jQuery does more than simple asynchronous requests, though, and if you’re<br />

interested, the documentation 14 is definitely worth exploring.<br />

In the next chapter, we look at giving tickets a concept of state, which enables users<br />

to see which tickets need to be worked on and which are closed. Tickets will also have<br />

a default state so they can be easily identified when they’re created.<br />

14 http://jquery.com.

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

Saved successfully!

Ooh no, something went wrong!