27.02.2013 Views

Rails%203%20In%20Action

Rails%203%20In%20Action

Rails%203%20In%20Action

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

x<br />

9<br />

10<br />

CONTENTS<br />

8.5 Restricting write access 185<br />

Rewriting a feature 185 ■ Blocking creation 187 ■ What is<br />

CanCan? 188 ■ Adding abilities 189<br />

8.6 Restricting update access 190<br />

No updating for you! 191 ■ Authorizing editing 192<br />

8.7 Restricting delete access 193<br />

Enforcing destroy protection 193 ■ Hiding links based on<br />

permission 194<br />

8.8 Assigning permissions 198<br />

Viewing projects 198 ■ And the rest 206<br />

8.9 Seed data 209<br />

8.10 Summary 212<br />

File uploading 213<br />

9.1 Attaching a file 214<br />

A feature featuring files 214 ■ Enter stage right, Paperclip 216<br />

Using Paperclip 217<br />

9.2 Attaching many files 220<br />

Two more files 221 ■ Using nested attributes 224<br />

9.3 Serving files through a controller 226<br />

Protecting files 227 ■ Showing your assets 228 ■ Public<br />

assets 230 ■ Privatizing assets 230<br />

9.4 Using JavaScript 231<br />

JavaScript testing 232 ■ Introducing jQuery 233 ■ Adding<br />

more files with JavaScript 234 ■ Responding to an asynchronous<br />

request 235 ■ Sending parameters for an asynchronous<br />

request 237<br />

9.5 Summary 241<br />

Tracking state 243<br />

10.1 Leaving a comment 244<br />

Where’s the ticket? 245 ■ The comment form 247<br />

The comment model 247 ■ The comments controller 249<br />

10.2 Changing a ticket’s state 252<br />

Creating the State model 253 ■ Selecting states 255<br />

Callbacks 257 ■ Seeding states 259 ■ Fixing creating<br />

comments 261

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

Saved successfully!

Ooh no, something went wrong!