List Info

Thread: Re: simple RoR problem with file_column / rmagick




Re: simple RoR problem with file_column / rmagick
user name
2008-01-21 05:53:24
Thank you very much for the suggestions but it's not quite
what I'm
looking for.
I think what I'm having trouble with is more basic.

What I want to be able to is access the file size (and
other
attributes) outside, from an rhtml file.
I have done this successfully by adding this line to the
rhtml file:
    <%= Magick::ImageList.new(photo.image).filesize
%>

Although this works, it incurs a massive time penalty,
somewhere
around 1 second per image.

I think the best method would be to get the size and store
it when the
image is saved, which is why I thought of putting this
beneath line 5:
     size = image.filesize

however that does nothing so far as I can tell.

I had another thought - defining this function at the start
of the
class:
     def store_size(image)
          size = image.filesize
     end

and adding this beneath line 5:
     store_size(image)

however this gives the error 'undefined method
`write_description' for
Photo:Class'

So how do I call a function on the object rather than the
class from
the block starting at line 5?


Thanks again!
--~--~---------~--~----~------------~-------~--~----~
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-talkgooglegroups.com
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: simple RoR problem with file_column / rmagick
country flaguser name
Germany
2008-01-21 06:08:34
add a feild 'size' to your table and this will work

class some_class

 before_save :store_size

 def store_size
  size = image.filesize
 end

 ....
end
-- 
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-talkgooglegroups.com
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )