Forum: Ruby on Rails output fleximage image from DB?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Taylor S. (Guest)
on 2009-01-19 17:08
I'm a bit stuck trying to output a DB-stored file in a view with
FlexImage 2.  DB storing is supported but there is no documentation on
how to get it out of the DB.  Could someone point me to a resource
explaining how to render a DB stored FlexImage in a view?
Rob L. (Guest)
on 2009-01-19 17:18
(Received via mailing list)
Here's the documentation for a start, I've been using FlexImage for a
while now

Since the latest code is for RESTful style controllers/views, etc. You'd
do something like this in your view that you're placing your image in.

@image = Image.find(:first)

<%= image_tag formatted_image_path(@image, :jpg) %>

This would generate something like this...

<img src="/images/1.jpg" />

which would map to the ImagesController, something like...

class ImagesController < ApplicationController

def show
  @image = Image.find(params[:id])


this would then render the flexi template which might then look like

@image.operate do |i|
  i.resize '200'

I hope this helps or at least the documentation link does.

Taylor S. (Guest)
on 2009-01-19 17:44
Thanks for responding.  I think my problem comes from rendering a
collection through partials.  It is not calling the 'show' method and
therefore not triggering the routing call to .jpg.  But my best effort
still doesn't work:

<%= image_tag(url_for(:controller => 'questions', :action => 'show', :id
=> question, :format => 'jpg') %>


<img src="/questions/show/1.jpg" />

but just has a broken image link. Its not getting the data.

  def show
    @question = Question.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @question }
      format.jpg #for fleximage


map.resources :questions
Taylor S. (Guest)
on 2009-01-19 17:47
Going to the image directly by /questions/show/1.jpg yields the
following error:

NoMethodError in QuestionsController#show

undefined method `call' for Fleximage::View:Class
Taylor S. (Guest)
on 2009-01-19 21:25
Taylor S. wrote:
> Going to the image directly by /questions/show/1.jpg yields the
> following error:
> NoMethodError in QuestionsController#show
> undefined method `call' for Fleximage::View:Class

This continues to be my sticking point.  The server throws these errors
silently.  More info on the error:

NoMethodError (undefined method `call' for Fleximage::View:Class):


This is on Rails 2.2.2.  When installing I also had to change this line
in plugins/fleximage/init.rb

ActionView::Base.register_template_handler :flexi, Fleximage::View

ActionView::Template.register_template_handler :flexi, Fleximage::View

So I wonder if there are other issues at work.   Anyone on Edge rails
running fleximage ok?  I can get the images to work when I use
embedded_image_tag but have had issues with image corruption really
blowing up my app. (have to drop the row from DB)  Man, you spend more
time troubleshooting and shoehorning plugins than you do just writing
the functions from scratch!
Taylor S. (Guest)
on 2009-01-19 22:07
Issue resolved.  Somehow I had downloaded an old version of the plugin
from GitHub.  The Dec 12th build solves everything.  I love Mondays.
This topic is locked and can not be replied to.