Adam Roth
2005-Nov-04 05:17 UTC
Re: [ANN] file_column_0.3 plugin with rmagick support - HABTM example?
Hello, Thanks for developing file_column. I have a question regarding uploading images and habtm relationships. For example: Table: users Table: pictures Table: pictures_users Users can have N pictures. When a user uploads a picture from /user/new, I want the record to be inserted into the ''pictures'' table, and the mapping between user and picture to be inserted into the ''pictures_users'' table. I have a custom solution for this, but I''d like to use file_column to simplify the process. Could anyone provide a simple solution/concept for this? Thanks, Adam _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Kyle Maxwell
2005-Nov-04 08:24 UTC
Re: [ANN] file_column_0.3 plugin with rmagick support - HABTM example?
Seems pretty simple to me... user = User.find :first user.pictures << Picture.create(:field_name => params[:field_name]) On 11/3/05, Adam Roth <adamjroth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, > > Thanks for developing file_column. I have a question regarding uploading > images and habtm relationships. For example: > > Table: users > Table: pictures > Table: pictures_users > > Users can have N pictures. When a user uploads a picture from /user/new, I > want the record to be inserted into the ''pictures'' table, and the mapping > between user and picture to be inserted into the ''pictures_users'' table. I > have a custom solution for this, but I''d like to use file_column to simplify > the process. > > Could anyone provide a simple solution/concept for this? > > Thanks, > Adam > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Adam Roth
2005-Nov-04 15:04 UTC
Re: [ANN] file_column_0.3 plugin with rmagick support - HABTM example?
Kyle, Thanks -- that works. But is it still possible to use the file_column helpers when dealing with multiple files through a habtm relationship? ie: <%= file_column_field "images", "file[]" %><br> <%= file_column_field "images", "file[]" %><br> (That doesn''t work -- results in the input name being images[file[]] instead of images[ file ][] which is what is required. I just typed these out long-hand instead. The same applies for displaying the image (this doesn''t work either, but you get the diea of what I''m going for): 2 images:<br> <%= image_tag url_for_file_column( @user.images[0], "file" ) %><br> <%= image_tag url_for_file_column( @user.images[1], "file" ) %><br> Thanks in advance. Adam On 11/4/05, Kyle Maxwell <kyle-FOSOgQihYpQjo0HpFSRKWA@public.gmane.org> wrote:> > Seems pretty simple to me... > > user = User.find :first > user.pictures << Picture.create(:field_name => params[:field_name]) > > On 11/3/05, Adam Roth <adamjroth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hello, > > > > Thanks for developing file_column. I have a question regarding uploading > > images and habtm relationships. For example: > > > > Table: users > > Table: pictures > > Table: pictures_users > > > > Users can have N pictures. When a user uploads a picture from /user/new, > I > > want the record to be inserted into the ''pictures'' table, and the > mapping > > between user and picture to be inserted into the ''pictures_users'' table. > I > > have a custom solution for this, but I''d like to use file_column to > simplify > > the process. > > > > Could anyone provide a simple solution/concept for this? > > > > Thanks, > > Adam > > > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Tim
2005-Nov-04 16:44 UTC
Re: [ANN] file_column_0.3 plugin with rmagick support - HABTM example?
what about something like: <% for @image in @user.images %> <%= image_tag url_for_file_column( image, "file" ) %><br> <% end %> Tim Adam Roth wrote:> Kyle, > > Thanks -- that works. But is it still possible to use the file_column > helpers when dealing with multiple files through a habtm relationship? ie: > > <%= file_column_field "images", "file[]" %><br> > <%= file_column_field "images", "file[]" %><br> > > (That doesn''t work -- results in the input name being images[file[]] > instead of images[ file ][] which is what is required. I just typed > these out long-hand instead. > > The same applies for displaying the image (this doesn''t work either, > but you get the diea of what I''m going for): > > 2 images:<br> > <%= image_tag url_for_file_column( @user.images[0], "file" ) %><br> > <%= image_tag url_for_file_column( @user.images[1], "file" ) %><br> > > Thanks in advance. > Adam > > > > On 11/4/05, *Kyle Maxwell* <kyle-FOSOgQihYpQjo0HpFSRKWA@public.gmane.org > <mailto:kyle-FOSOgQihYpQjo0HpFSRKWA@public.gmane.org>> wrote: > > Seems pretty simple to me... > > user = User.find :first > user.pictures << Picture.create(:field_name => params[:field_name]) > > On 11/3/05, Adam Roth <adamjroth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > <mailto:adamjroth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> wrote: > > Hello, > > > > Thanks for developing file_column. I have a question regarding > uploading > > images and habtm relationships. For example: > > > > Table: users > > Table: pictures > > Table: pictures_users > > > > Users can have N pictures. When a user uploads a picture from > /user/new, I > > want the record to be inserted into the ''pictures'' table, and > the mapping > > between user and picture to be inserted into the > ''pictures_users'' table. I > > have a custom solution for this, but I''d like to use file_column > to simplify > > the process. > > > > Could anyone provide a simple solution/concept for this? > > > > Thanks, > > Adam > > > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > http://lists.rubyonrails.org/mailman/listinfo/rails > > >------------------------------------------------------------------------ > >_______________________________________________ >Rails mailing list >Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >http://lists.rubyonrails.org/mailman/listinfo/rails > >
Tim
2005-Nov-04 16:46 UTC
Re: [ANN] file_column_0.3 plugin with rmagick support - HABTM example?
Oops, typo :-) <% for @image in @user.images %> <%= image_tag url_for_file_column( "image", "file" ) %><br> <% end %> Tim Tim wrote:> what about something like: > > <% for @image in @user.images %> > <%= image_tag url_for_file_column( image, "file" ) %><br> > <% end %> > > Tim > > Adam Roth wrote: > >> Kyle, >> >> Thanks -- that works. But is it still possible to use the file_column >> helpers when dealing with multiple files through a habtm >> relationship? ie: >> >> <%= file_column_field "images", "file[]" %><br> >> <%= file_column_field "images", "file[]" %><br> >> >> (That doesn''t work -- results in the input name being images[file[]] >> instead of images[ file ][] which is what is required. I just typed >> these out long-hand instead. >> >> The same applies for displaying the image (this doesn''t work either, >> but you get the diea of what I''m going for): >> >> 2 images:<br> >> <%= image_tag url_for_file_column( @user.images[0], "file" ) %><br> >> <%= image_tag url_for_file_column( @user.images[1], "file" ) %><br> >> >> Thanks in advance. >> Adam >> >> >> >> On 11/4/05, *Kyle Maxwell* <kyle-FOSOgQihYpQjo0HpFSRKWA@public.gmane.org >> <mailto:kyle-FOSOgQihYpQjo0HpFSRKWA@public.gmane.org>> wrote: >> >> Seems pretty simple to me... >> >> user = User.find :first >> user.pictures << Picture.create(:field_name => params[:field_name]) >> >> On 11/3/05, Adam Roth <adamjroth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org >> <mailto:adamjroth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> wrote: >> > Hello, >> > >> > Thanks for developing file_column. I have a question regarding >> uploading >> > images and habtm relationships. For example: >> > >> > Table: users >> > Table: pictures >> > Table: pictures_users >> > >> > Users can have N pictures. When a user uploads a picture from >> /user/new, I >> > want the record to be inserted into the ''pictures'' table, and >> the mapping >> > between user and picture to be inserted into the >> ''pictures_users'' table. I >> > have a custom solution for this, but I''d like to use file_column >> to simplify >> > the process. >> > >> > Could anyone provide a simple solution/concept for this? >> > >> > Thanks, >> > Adam >> > >> > >> > _______________________________________________ >> > Rails mailing list >> > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> >> > http://lists.rubyonrails.org/mailman/listinfo/rails >> > >> > >> > >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails