Filtering params

Good night,

Could anyone tell me how can I split this hash?

@original_filename=“alf.jpg”, @content_type=“image/jpeg”,
@headers=“Content-Disposition: form-data; name=“photo[avatar]”;
filename=“alf.jpg”\r\nContent-Type: image/jpeg\r\n”>}

I need to create a new Photo objet with that data. I can’t use the
way ‘Photo.create(photo_params)’ because I need to add the
the photos table.

Below is the code that I’m using, but only the fields “title” and
are being saved in the table of each photo.

@photo = Photo.create do |p|
p.title = photo_params[:title]
p.user_id =
print p.avatar_file_name = photo_params{attr_accessor
p.avatar_content_type = photo_params[:content_type]
p.avatar_file_size = photo_params[:avatar_file_size]

Thanks & Regards


Ok solved.

@photo =
@photo.title = photo_params[:title]
@photo.user_id =


El jueves, 24 de abril de 2014 21:06:34 UTC+2, Alfredo B. escribió:

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