golna/class-cloud — Issue #11: attachments error
Author: golna
Created: 2011-12-05 19:16:10+00:00
State: open

Getting a 500 error followed by a 401 error when trying to view Stacie's attachment on staging. I'm guessing it's set up so only users who created the attachment can view or download it, which is good, but other users are still able to see it, which is bad. Having a server error followed by a forbidden error code is a little weird. Do you have time to look into this today Scott?

This brings up another point:

As the system is set up now, anyone can view any assignment or class created regardless of if it's theirs or not. We need to decide if we have time to implement the class creation functionality we talked about earlier -- either

- (1) turning class creation into a search for pre-existing classes to add to a user's classes, with an option to create a class if the one they're looking for doesn't exist, or

- (2) keeping things simple and having everything -- classes, assignments, attachments, be private and restricted to one user.

Option (1) is better but we're very strapped for time, so unless you've got some fancy stuff you can quickly copy paste and refactor from the game genome project I suggest we go with option (2) to at least have consistent behavior. Let me know which path you choose (keep in mind we're shooting for a demo on Wednesday).

Error log for attachments issue:

```
2011-12-05T19:04:26+00:00 app[web.1]: Started GET "/attachments/2" for 161.38.218.188 at 2011-12-05 19:04:26 +0000
2011-12-05T19:04:26+00:00 app[web.1]: Processing by AttachmentsController#show as HTML
2011-12-05T19:04:26+00:00 app[web.1]: Parameters: {"id"=>"2"}
2011-12-05T19:04:26+00:00 app[web.1]: Rendered attachments/show.html.erb within layouts/application (54.1ms)
2011-12-05T19:04:26+00:00 app[web.1]: Completed 500 Internal Server Error in 58ms
2011-12-05T19:04:26+00:00 app[web.1]:
2011-12-05T19:04:26+00:00 app[web.1]: ActionView::Template::Error (can't convert nil into String):
2011-12-05T19:04:26+00:00 app[web.1]: 7:
2011-12-05T19:04:26+00:00 app[web.1]: 8:

2011-12-05T19:04:26+00:00 app[web.1]: 9: <% if !@attachment.upload.url.blank? %>
2011-12-05T19:04:26+00:00 app[web.1]: 10:
<%= link_to 'Download "' + @attachment.upload_file_name + '"', @attachment.upload.url %>

2011-12-05T19:04:26+00:00 app[web.1]: 11: <% end %>
2011-12-05T19:04:26+00:00 app[web.1]: 12:

2011-12-05T19:04:26+00:00 app[web.1]: app/views/attachments/show.html.erb:10:in `+'
2011-12-05T19:04:26+00:00 app[web.1]: app/views/attachments/show.html.erb:10:in `_app_views_attachments_show_html_erb___2461440094642509325_40896440'
2011-12-05T19:04:26+00:00 app[web.1]:
2011-12-05T19:04:26+00:00 app[web.1]:
2011-12-05T19:04:26+00:00 app[web.1]: cache: [GET /attachments/2] miss
2011-12-05T19:04:26+00:00 app[web.1]:
2011-12-05T19:04:26+00:00 app[web.1]:
2011-12-05T19:04:26+00:00 app[web.1]: Started GET "/attachments/2" for 8.21.4.254 at 2011-12-05 19:04:26 +0000
2011-12-05T19:04:26+00:00 app[web.1]: Processing by AttachmentsController#show as */*
2011-12-05T19:04:26+00:00 app[web.1]: Parameters: {"id"=>"2"}
2011-12-05T19:04:26+00:00 app[web.1]: Redirected to http://class-cloud-staging.herokuapp.com/
2011-12-05T19:04:26+00:00 app[web.1]: Completed 401 Unauthorized in 1ms
```