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

Lost W. wrote:

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

hmm
perhaps just this…

controller:

def upload
image = Image.new(params[:image])
if image.save

else

end
end

model:

def uploaded_data=(file)
self.filename = file.original_filename
self.content_type = file.content_type
self.size = file.size
end

MAtthewrudy

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs