Yeah,
I’m trying to solve it:
Models: User and Picture
User has_many Pictures
Pictures belongs_to User
<% form_for(@user, :html => { :multipart => true }) do |f| %>
<%= f.text_field :anything %>
<%= f.file_field :uploaded_data %>
<% end %>
At Picture.rb:
has_attachment :content_type => :image,
:storage => :file_system,
:max_size => 2.megabytes,
:resize_to => “640x480”,
:path_prefix => ‘public/images/’
validates_as_attachment
I tried to do something like:
@user = User.new
params[:user].each do |p|
unless p == ':uploaded_data' # it's really an idea!
@user = User.update_attributtes(:name, p)
else
@user = User.picture_id.update_attributte(:name, p)
end
end
This sounds me very bad because it isn’t DRY.
How can i save the ‘:anything’ object in User model and ‘:uploaded_data’
object to User.picture_id or Picture passing the user_id ?
Thanks for your attention!
–
Regards,
Luiz Vitor Martinez C.
cel.: (11) 8187-8662
blog: rubz.org
engineer student at maua.br
“Posso nunca chegar a ser o melhor engenheiro do mundo, mas tenha
certeza de
que eu vou lutar com todas as minhas forças para ser o melhor engenheiro
que
eu puder ser”