# Gibberish and attachment\_fu

**URL:** <https://www.ruby-forum.com/t/gibberish-and-attachment-fu/129356>\
**Category:** Rails\
**Created:** [February 17, 2008, 1:49pm UTC](https://www.ruby-forum.com/t/gibberish-and-attachment-fu/129356 "2008-02-17T13:49:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![foxbunny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ed655f/32.png) [@foxbunny](https://www.ruby-forum.com/u/foxbunny)\
**Post date:** [February 17, 2008, 1:49pm UTC](https://www.ruby-forum.com/t/gibberish-and-attachment-fu/129356/1 "2008-02-17T13:49:56Z")

</div>

Hi,

I’m trying to code something that requires UI translation. I picked up  
Gibberish plugin, which (unfortunately) expands the String class in  
order to implement it’s magic. That seems to conflict with  
attachment\_fu. I’ve run the NetBeans debugger and stepped through the  
creation of my Image record and it seems that file name is set to nul  
at some point after gibberish extension code has ben run.

## The code for the New Image form looks like this:

\<% form\_for(image, :html =\> { :multipart =\> true } ) do |f| -%\>

\<%= "name"[:image\_name] %\>   
 \<%= f.text\_field :name %\>

\<%= "image file"[:image\_file] %\>   
 \<%= f.file\_field :uploaded\_data %\>

\<%= render :partial =\> ‘common/meta\_form’, :locals =\> { :item =\>  
image } %\>

\<%= f.submit button\_name %\>

## \<% end -%\>

## The create method in ImagesController is the default:

## def create @image = Image.new(params[:image]) respond\_to do |format| if @image.save flash[:notice] = ‘Image was successfully created.’ format.html { redirect\_to(@image) } format.xml { render :xml =\> @image, :status =\> :created, :location =\> @image } else format.html { render :action =\> “new” } format.xml { render :xml =\> @image.errors, :status =\> :unprocessable\_entity } end end end

## And the model contains attachment\_fu code:

has\_attachment :content\_type =\> :image,  
:storage =\> :file\_system,  
:path\_prefix =\> ‘public/assets/photos’,  
:thumbnails =\> { :preview =\> ‘320x320\>’, :thumb =\>  
‘100x100\>’ }

## validates\_as\_attachment

## Finally, the schema for the images table looks like this:

## create\_table “images”, :force =\> true do |t| t.string “filename” t.integer “size” t.integer “parent\_id” t.datetime “created\_at” t.datetime “updated\_at” t.string “content\_type” t.integer “height” t.integer “width” t.string “thumbnail” end

Unfortunatly, my skills in both Ruby and Rails are fairly  
underdeveloped so I can’t know for sure what is going on. Has anyone  
been using Gibberish plugin in conjunction with attachment\_fu? Can  
anyone tell me how to make this work?

Alternatively, is there any other lightweight UI translation solution  
that doesn’t involve modifying the String class?

Thanks in advance.

Branko

---

<div class="post-metadata">

**Author:** ![foxbunny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ed655f/32.png) [@foxbunny](https://www.ruby-forum.com/u/foxbunny)\
**Post date:** [February 17, 2008, 5:46pm UTC](https://www.ruby-forum.com/t/gibberish-and-attachment-fu/129356/2 "2008-02-17T17:46:07Z")

</div>

Hm, so it’s definitely not gibberish+attachment\_fu. I’ve just created  
a clean project with both plugins installed, and gibberish has not  
made attachment\_fu fail. I’ll try to dig deeper into my code and see  
what’s causing this problem…

Branko
