Upload Picture to Rails App
How to upload picture in rails app ?
If you want to upload picture in your rails app, you should make
- Open your
Gemfilein rails app then add
1
| |
in terminal write bundle for install gem.
Which models do you want to upload picture ? For example, you have
booksmodel, because of this, I write all command according tobookmodel.After install
paperclipgem, open yourterminalagain then write
1
| |
then
1
| |
- Open
models/book.rbadd
1 2 3 4 5 6 7 | |
- Open
books/show.html.hamladd
1
| |
- Open
books/_form.html.hamladd
1 2 | |
- Open
controllers/books_controller.rb, then checkcreatemethod if you use
1 2 3 | |
instead of above, you should write
1 2 3 | |
Lastly, you should control to add :photo in your book_params method.
1 2 3 4 | |
If you want to learn with details, you can visit this site
That’ s all.