Hello people, I''m using squeegy fleximage for my site right now and having some difficulty to achieve some things. Updates photos are saved in created at date generated fom like : '' /images/2008/05/14/22.png '' . However this route is not accessible through the browser and I don''t know how to add it in my routes.rb knowing that the dates will change everyday. However there''s a way to avoid these kind of generated paths and use only a flat form by using a rake task ( http://github.com/Squeegy/fleximage/tree/master - Bottom page ) . rake fleximage:convert:to_flat FLEXIMAGE_CLASS=Photo And actually, I''m having the following error from console : ** Invoke fleximage:convert:to_flat (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute fleximage:convert:to_flat rake aborted! You have a nil object when you didn''t expect it! The error occurred while evaluating nil.year Anyone knows how to solve this ? Regards, Joel --~--~---------~--~----~------------~-------~--~----~ 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 am using fleximage, and having no problem with it. I think you must be using it incorrectly. Those date paths are how it *stores* the master image. You should not be rendering from those. You *render* using their special templates called from special formats in your controller. The rake tasks are for one time jobs during development. Try reading their instructions and examples more carefully and see if you can figure it out. --Will joel wrote:> Hello people, > > I''m using squeegy fleximage for my site right now and having some > difficulty to achieve some things. Updates photos are saved in created > at date generated fom like : '' /images/2008/05/14/22.png '' . However > this route is not accessible through the browser and I don''t know how > to add it in my routes.rb knowing that the dates will change everyday. > However there''s a way to avoid these kind of generated paths and use > only a flat form by using a rake task ( http://github.com/Squeegy/fleximage/tree/master > - Bottom page ) . > > rake fleximage:convert:to_flat FLEXIMAGE_CLASS=Photo > > And actually, I''m having the following error from console : > > ** Invoke fleximage:convert:to_flat (first_time) > ** Invoke environment (first_time) > ** Execute environment > ** Execute fleximage:convert:to_flat > rake aborted! > You have a nil object when you didn''t expect it! > The error occurred while evaluating nil.year > > Anyone knows how to solve this ? > > Regards, > > Joel > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Indeed I was using it wrongly ! But the real problem is as described below, in fact it concerns the rendering of the image. My controller action code looks like this : def showimg @promo = Promotion.find(params[:id]) respond_to do |format| # format.png { image_tag @promo.file_path(@promo) } format.html { render :inline => "@promo.operate {|p| p.resize ''30x30''}", :type => :flexi } # format.xml { render :xml => @promo } end end I''m using the following code in my view ; <div> <%render_component(:controller=>''promotions'',:action=>''showimg'',:id=>promotion.id) %> </div> And this view actually doesn''t correspond to the correponding view of the above controller action code.The url corresponding to the above controller action however displays very well my image, but I''m having very much difficulty to display it in this view. Instead of having my image, i''m having some binary data, quite a messy thing. I''m asking myself whether this doesn''t have to do with the respond_to format. I tried using the render instead of render_component but didn''t work. Does this tell you something ? Joel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 16 May 2008, at 14:21, joel wrote:> > respond_to do |format| > # format.png { image_tag > @promo.file_path(@promo) } > > And this view actually doesn''t correspond to the correponding view of > the above controller action code.The url corresponding to the above > controller action however displays very well my image, but I''m having > very much difficulty to display it in this view. > Instead of having my image, i''m having some binary data, quite a messy > thing. I''m asking myself whether this doesn''t have to do with the > respond_to format.It does and it doesn''t. You don''t need to render an image_tag, you need to render the binary data itself with the correct headers defined, so that your browser recognizes it as being a png image. Something like this probably works: respond_to do |format| format.png { send_data(@promo.file_path(@promo), :type=>"image/ png", :disposition =>"inline") } end Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Understand, but I tried the send_data method with no result. What I don''t understand is why the url corresponding to controller action works and not the rendering of the image. In both cases the specified type is flexi, so why it works in the 1st case and not the second ? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
My first question is: which view? This whole thing you''ve got seems really complicated. As far as I understand flexi really wants to use a .flexi file to do its rendering. So you should have a showimg.png.flexi file in your view directory. Your controller action can be really simple. Something like this (this one of mine): def thumbnail @photo = Photo.find(params[:id]) respond_to do |format| format.jpg end end Then you just let rails magic handle the rendering. One thing that took me a little while to figure out was that the rendering of the image is actually a separate http call. That is, the image itself has its own trip through the routes/controller/view mechanism. So when the *image* is being rendered, it is *all* that is being rendered, and it is the flexi file that does the view part. One more thing, I found my life got easier when I started using separate names for different types of images. To show the information about a photo, I use: # GET /photos/1 # GET /photos/1.xml def show @photo = Photo.find(params[:id]) respond_to do |format| format.html if # show.html.erb format.xml { render :xml => @photo } end end But to show the actual photo I use the action above. To make this work I also add a few routes: map.resources :photos map.thumbnail ''/photos/normal/:id.:format'', :controller => "photos", :action => "normal" map.thumbnail ''/photos/thumb/:id.:format'', :controller => "photos", :action => "thumbnail" map.fullsize ''/photos/fullsize/:id.:format'', :controller => "photos", :action => "fullsize" Hope all of this helps. --Will joel wrote:> Indeed I was using it wrongly ! But the real problem is as described > below, in fact it concerns the rendering of the image. > > My controller action code looks like this : > > def showimg > @promo = Promotion.find(params[:id]) > respond_to do |format| > # format.png { image_tag > @promo.file_path(@promo) } > format.html { render :inline => > "@promo.operate {|p| p.resize > ''30x30''}", :type => :flexi } > # format.xml { render :xml => @promo } > end > end > > I''m using the following code in my view ; > > <div> > <%> render_component(:controller=>''promotions'',:action=>''showimg'',:id=>promotion.id) > %> > </div> > > And this view actually doesn''t correspond to the correponding view of > the above controller action code.The url corresponding to the above > controller action however displays very well my image, but I''m having > very much difficulty to display it in this view. > Instead of having my image, i''m having some binary data, quite a messy > thing. I''m asking myself whether this doesn''t have to do with the > respond_to format. > > I tried using the render instead of render_component but didn''t work. > > Does this tell you something ? > > Joel > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi, thank you very much for all these explanations that I found out to be very useful. However I think the problem is really due to calling the action method from another view. Actually I have the following code in my view when trying to render the image. <% for promotion in @promotion %> <div''> <%render_component :controller=>''promotions'', :action=>''showimg'',:id=>promotion.id %> </div> <% end %> The following works very well : http://0.0.0.0:3000/promotions/showimg/23 Controller action code looks like this : (very simple and basic) def showimg @promo = Promotion.find(params[:id]) respond_to do |format| #format.html format.png end end But then I need to call this action from another view and render the actual image; but I have binary data instead of a beautiful picture. Joel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Joel, Instead of using render_component, just use image_tag and let rails do the work. I think your trying too hard. Heres one from my site: <%= image_tag(thumbnail_path(photo, :jpg), :height => "100", :alt => photo.alt, :title => photo.title) %> -- Will joel wrote:> Hi, > > thank you very much for all these explanations that I found out to be > very useful. However I think the problem is really due to calling the > action method from another view. Actually I have the following code in > my view when trying to render the image. > > > <% for promotion in @promotion %> > <div''> > <%> render_component :controller=>''promotions'', :action=>''showimg'',:id=>promotion.id > %> > </div> > <% end %> > > The following works very well : > http://0.0.0.0:3000/promotions/showimg/23 > > Controller action code looks like this : (very simple and basic) > > def showimg > @promo = Promotion.find(params[:id]) > respond_to do |format| > #format.html > format.png > end > end > > But then I need to call this action from another view and render the > actual image; but I have binary data instead of a beautiful picture. > > > Joel > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Yep, indeed I was trying too hard ! Got the problem solved now, thank you very much ;-) Indeed it was quite a simple task. However I have another issue concerning fleximage. Is it possible to "attach" two different images to a single record and rendering the both of them. For my case, I need to be able to store one image for my promotion item and a second that would be a logo of the item''s brand. Help for your precious help. Best Regards, Joel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Joel, This actually has nothing to do with fleximage. How are you "attaching" the first image? Just do that twice. Probably what you want is a one to many relationship. Some kind of has_many model. Just link in the images you need and then just generate an image tag for each. -- Will joel wrote:> Yep, indeed I was trying too hard ! > > Got the problem solved now, thank you very much ;-) Indeed it was > quite a simple task. > > However I have another issue concerning fleximage. Is it possible to > "attach" two different images to a single record and rendering the > both of them. For my case, I need to be able to store one image for my > promotion item and a second that would be a logo of the item''s brand. > > Help for your precious help. > > Best Regards, > > > Joel > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---