I, too, am toying with image uploads... and have got to the stage where I can now both save them to DB and resize them using RMagick..... I''m intrigued though by what seems the standard practice in Rails of first saving the image to the DB as a blob. Is this required? And what are the advantages of doing so? Or is it part of having an image "model"? And what about the recieved wisdom on where to store the images? Ideally, I''d like them somewhere in the /public/images..... heirarchy where they can be accessed from the front end. Is that the right place? But in that case, I''m having problems accessing them from my upload form (or rather, show.rhtml). If I do something like: <img src="<%= url_for(:action => "picture", :id => @picture.id) %>"/> then it searches for the image in (something like) /upload/picture/29 which is not at all where me "picture" is. Can anyone enlighten me? many thanks -- 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 -~----------~----~----~----~------~----~------~--~---
That sounds like file_column. I was playing with that yesterday. It looks in "picture/29" because the id for the image''s entry in the database is "29". The plugin saves each file in a separate folder because it doesn''t rename the files and wants to avoid overwriting a file with the same name. I didn''t like that much either. Now if I can just get Flex_image installed without fryig WEBrick... -- 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 -~----------~----~----~----~------~----~------~--~---
Thanks Sean,> That sounds like file_column.Yes, sounds like you''re right. And a quick search for file_column returns a wealth of info.>It looks in "picture/29" because the id for the image''s entry in the > database is "29". The plugin saves each file in a separate folder > because it doesn''t rename the files and wants to avoid overwriting a > file with the same name.Actually, that''s fine for me.> Now if I can just get Flex_image installed without fryig WEBrick...Good luck! You''re on Mac OSX right? Incidentally, I installed RMagick last week following this: http://rmagick.rubyforge.org/install-osx.html It worked fine. The only hiccup I had was on the actual RMagick installation - where I found I had to specify the PATH before it would work ( it had installed ImageMagick in a dir called /opt). I also had to edit my bashrc file. But once I''d done that, it worked fine. It did take a couple of hours though. -- 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 -~----------~----~----~----~------~----~------~--~---
Yeah! That''s exactly what I''m reading through right now. I just installed DarwinPorts and it doesn''t seem to be working. I think I need to restart the whole computer to get it going. I may have a question or two for you once I get to that bashrc file. cheers sean -- 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 -~----------~----~----~----~------~----~------~--~---
The main advantages of storing images in database for me is that: - images are treated the same way as any other data - no need to juggle with file system operations (especially deleting image files from filesystem) - very easy to move and backup data (just backup database, and not database _plus_ images directory) I personally use FlexImage, which in turn relies on RMagick, which in turn requires either GraphicsMagick or ImageMagick to be installed, which in turn.. :) But once you build the whole chain at least once, this is actually the easiest setup I have ever used. Also, kind of off-topic, but I''ve heard you''re better of as Mongrel as a web-server, especially during the development period. There were stories when Webrick didn''t reload changed files and stuff like that.. Myself, I use Mongrel on both development (plain mongrel) and production (mongrel cluster) systems. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> I may have a question or two for you once I get to that bashrc file.Sure. All it really does is set your path - to save you having to do something like this: export PATH=$PATH:/usr/local/bin every time you run a command. You can write it directly into a (hidden) file called just .bashrc in your home directory. To see if you''ve got that file already open a shell and type: ls -a If you''ve got TextMate (which most Rails folks seem to use) and you''ve set the TextMate command (Can''t remember the details of where to put this - somewhere in /usr - Google around for the exact details) you can just do: mate .bashrc in your shell and it will open the file for you to edit. This may be the problem with not having Darwin Ports. Maybe it can''t find the PATH. I seem to remember I ran into problems here sudo port -d selfupdate for exactly this reason. Try and find where it added the command "port" - then add that to your PATH. Hope that helps.... -- 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 -~----------~----~----~----~------~----~------~--~---
MacD wrote:> The main advantages of storing images in database for me is that: > - images are treated the same way as any other data > - no need to juggle with file system operations (especially deleting > image files from filesystem) > - very easy to move and backup data (just backup database, and not > database _plus_ images directory)All very valid reasons. Hadn''t thought of any of them before. Gives me something to think about.... > I personally use FlexImage, which in turn relies on RMagick, which in> Also, kind of off-topic, but I''ve heard you''re better of as Mongrel as > a web-server,I don''t know either, but you convince me to look into both. Thank you. D -- 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 -~----------~----~----~----~------~----~------~--~---
> This may be the problem with not having Darwin Ports. Maybe it can''t > find the PATH. I seem to remember I ran into problems here > > sudo port -d selfupdate > > for exactly this reason. Try and find where it added the command "port" > - then add that to your PATH.That''s exactly it. I restarted and nothing changed, so I fumed and snorted for a good twenty minutes before having one of those "Eureka" moments. Five minutes later, it was running perfectly. I have a question about storing images directly in the database. Maybe you can help me, MacD. I, too, thought this was a better idea, but never figured out how to get them *out*. How do you trick the user''s browser into rendering a file that doesn''t actually exist on the server? -- 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 -~----------~----~----~----~------~----~------~--~---
Probably MacD will be able to help you better.... but this is what I was doing. (Basically I was just following one of the recipes in Chad Fowler''s very worthwhile "Rails Recipes" book). I simply put the following code into the view: <% if @images.any? %> <div> <h2><%= pluralize(@images.size, "Image") %></h2> <p>[ <%= link_to("Destroy All",:action=>''clean'') %> ]</p> <% @images.each_with_index do |image,index| %> <%= thumbnail image %> <% if (index + 1) % 5 == 0 %><br/><% end %> <% end %> </div> <% end %> It worked fine - but for some reason only returned the top part of the image - and obfuscating the lower. The reason for which I haven''t yet got to the bottom of - maybe MacD or someone else will know -- 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 -~----------~----~----~----~------~----~------~--~---