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
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Lost Warrior 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 > endhmm 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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---