Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions source/projects/blogger.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -1885,7 +1885,7 @@ First we'll add the ability to upload the file when editing the article, then we
In the very first line, we need to specify that this form needs to accept "multipart" data. This is an instruction to the browser about how to submit the form. Change your top line so it looks like this:

```erb
<%= form_for(@article, html: {multipart: true}) do |f| %>
<%= form_for @article, :html => {:multipart => true} do |f| %>
```

Then further down the form, right before the paragraph with the save button, let's add a label and field for the file uploading:
Expand All @@ -1899,7 +1899,7 @@ Then further down the form, right before the paragraph with the save button, let

### Trying it Out

If your server isn't running, start it up (`rails server` in your terminal). Then go to `http://localhost:3000/articles/` and click EDIT for your first article. The file field should show up towards the bottom. Click the `Choose a File` and select a small image file (a suitable sample image can be found at http://hungryacademy.com/images/beast.png). Click SAVE and you'll return to the article index. Click the title of the article you just modified. What do you see? Did the image attach to the article?
If your server isn't running, start it up (`rails server` in your terminal). Then go to `http://localhost:3000/articles/` and click EDIT for your first article. The file field should show up towards the bottom. Click the `Choose a File` and select a small image file. Click SAVE and you'll return to the article index. Click the title of the article you just modified. What do you see? Did the image attach to the article?

When I first did this, I wasn't sure it worked. Here's how I checked:

Expand Down