Browse the Ruby on Rails Community.

You are here: Forums Ask a Rails expert how to write in model...

Replytotopic

how to write in model

Posted in Forums : Ask a Rails expert

 
Warrior

Authority 12
Posting Rating 3
Sign in to rate this post

hi i am a beginner for rails how to write this in a model and access in a controller
def upload
@image=Image.new
@image.filename=params:image.original_filename
@image.content_type=params:image.content_type
@image.siz=params:image.size
@image.user_id=params:image
@image.save
end

 
Me

Authority 62
Posting Rating 100
Sign in to rate this post

Use a plugin like attachment_fu or Paperclip.

I prefer attachment_fu if a model has an undetermined number of attachments (e.g. a photo album has many photos) and Paperclip if I know that there’s only a certain number of attachments (e.g. a user has one avatar).

 
100_5106-785540

Authority 25
Posting Rating 0
Sign in to rate this post

I wrote a small step by step tutorial on setting up attachment_fu with image science:
http://blog.springenwerk.com/2008/05/setting-up-attachmentfu-for-rails-with.html

The post also has a link to a free chapter from the advanced rails recipes book which will answer your attachment_fu questions for sure.

- Johannes

Replytotopic

Other Recent Topics

Ask a Rails expert : Couldn't find Product without an ID

Ask a Rails expert : HTML to XML ---> get title & description

Ask a Rails expert : Accessing controller actions from scripted page?

Ask a Rails expert : seledted option for select_tag

Ask a Rails expert : Merging fields from two tables into one, including duplicates

Ask a Rails expert : saving has_many :through

Ask a Rails expert : Use Rails to develop sites for both Designer and Programmer

Ask a Rails expert : Rails+RS232

Ask a Rails expert : Is this a good way to add Admin section

Ask a Rails expert : RSS feed maker in rails 2.1

Formatting Help
  • *bold*       _italics_      
    bq. (quotes)
  • "DSC":http://www.dsc.net
  • * or # (lists)
or cancel