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.

This chapter covers<br />

� Uploading files to the app<br />

� Locking down file access based on declared<br />

permissions<br />

� Uploading multiple files using JavaScript, jQuery,<br />

and CoffeeScript<br />

213<br />

File uploading<br />

In chapter 9, you learned how to restrict access to specific actions in your application,<br />

such as viewing projects and creating tickets, by defining a Permission model<br />

that keeps track of which users have access to which actions.<br />

Ticketee’s getting pretty useful now. This chapter focuses on file uploading, the<br />

next logical step in a ticket-tracking application. Sometimes, when people file a<br />

ticket on an application such as Ticketee, they want to attach a file to provide more<br />

information for that ticket, because words alone can only describe so much. For<br />

example, a ticket description saying, “This button should move up a bit,” could be<br />

better explained with a picture showing where the button is now and where it<br />

should be. Users may want to attach any kind of file: a picture, a crash log, a text<br />

file, you name it. Currently, Ticketee has no way to attach files to the ticket: people<br />

would have to upload them elsewhere and then include a link with their ticket<br />

description.

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

Saved successfully!

Ooh no, something went wrong!