Your question is very vague?  You have a column that is a thumbnail image.
You said first you are trying to display the thumbnail image in the list
view, but then you say you are overriding the graphic_form_column method.
The graphic_form_column method is used to override the graphic column when
shown in a form.  If you are trying to override this column in the list view
you need to override the method graphic_column(record).  so if you want to
show an image for the column you would do something like this

def graphic_column(record)
  # code to show the image here
end

Now rails allows you to show an image very easily.  you said that
record.graphic is the name of the image file, I'm assuming that it also has
the extension correct?  So if the column has the actual file name and
extension you can use

image_tag "file_name"

So now in your helper you can do

def graphic_column(record)
  image_tag record.graphic
end

but there is one *gotcha* here and that is that you said your files are
located in the icon directory.  The image_tag method looks for files in the
images directory by default so you need to do

def graphic_column(record)
  image_tag "icons/#{record.graphic}"
end



On Thu, May 7, 2009 at 7:43 AM, JannaB <[email protected]> wrote:

>
> I have about 500 small ( <1kb) .png files I put into /images/icons. In
> my Origins table, I have a column called 'graphic' which contains the
> filename (sans path) to one of these 500 small png's (e.g.
> "fire.PNG").
>
> I'm trying to do two separate things here, but I am getting really
> twisted up on the syntax. First, In the List view, I'd like to display
> the thumbnail image. I understand that I need to amend the helper to
> that Model, and I do so as follows:
>
> module OriginHelper
>  def graphic_form_column (record, input_name)
>    s = %Q{"images/icons/#{record.graphic}"}
>    # I dont know about the syntax of this (so I rem it out, to view
> the string itself):
>    # img src = s
>    # below, to make sure the string s is correct:
>    render :text => s
>    end
> end
>
> As you can see, the img src line is causing an issue (I cannot seem to
> find out here or in the Wiki how to get the feild to be recognised as
> coming from a graphic image on the server) Furthermore, I think
> amending the Helper only alters the output in the Show or Edit views
> (which is the second issue I want to work on, and that is to have a
> combobox in the edit view that shows all 500 graphics, with the
> selected on showing, and allow the user to change that on the fly).
> For now, I cannot even get the selected image to display in the List
> view as I cannot find the proper syntax for this. Can someone show me
> what the syntax should be for this, or how to find it in the docs?
> Thank you, Janna
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to