开发者

How to upload images in Rails?

I am looking for a tutorial/how-to for uploading and storing images in rails. I searched google, but all I found was "...use imagemagick" or stuff like that. But I did not find any step by step tutorial (including installing imagemagick or a different image开发者_Go百科-plugin).

Can you give me a step by step tutorial (including installing the required plugins)? I am using Netbeans.

All I want is uploading images, resize images (save a picture in 3 different sizes), store images and display them.

Please help me! I need a tutorial for dummies :)


There is a Railscast for using paperclip. Maybe this is for you...?

http://railscasts.com/episodes/134-paperclip


You use paperclip plugin. It is one of the most used plugin in rails.

Before that you have to install imageMagick.

Model look like this

class ImageClass < ActiveRecord::Base
# Paperclip
has_attached_file :photo,
  :styles => {
    :thumb=> "100x100#",
    :large =>   "400x400>" }
end

you can set different sizes of images

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜