how to write the code in model

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