Hi,

I'm using attachment_fu with great success, but have run into a
requirement that I'd like to solve elegantly --  but I've outstripped my
ruby skills.
I have a class that returns a hash of thumbnail definitions, like so:
    class Thumb
       def  self.get_thumbs(style)
          return { :small => "100x50",  :large  => "200x100" }  if style
== 'landscape'
          return { :small => "50x100",  :large  => "100x200" }  if style
== 'portrait'
       end
    end

My attachment model is defined like this:

    class Photo < ActiveRecord::Base
         has_attachment :content_type => :image,
             :thumbnails => Thumb.get_thumbs(??????)
       [...more stuff ...]
    end

My photos controller has the following line:

     @photo = Photo.new(params[:photo])

My question:

I'd like dynamically determine what value to set to Thumbnail.get_thumbs
based on values set in the  Photo.new constructor.  Is this possible?
I've fooled around with attr_accessors,  lambdas, etc, but, I can't seem
to do what I want.   Is it possible to make such a run-time decision as
I'm trying to make?

Which is to say, if params[:photo][:style] = 'portrait', i'd like to cut
the thumbnails accordingly?


Does anyone have an elegant solution for this?
-- 
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@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to