# Problems with file\_column and rmagick

**URL:** <https://www.ruby-forum.com/t/problems-with-file-column-and-rmagick/124231>\
**Category:** Rails\
**Created:** [December 26, 2007, 7:58pm UTC](https://www.ruby-forum.com/t/problems-with-file-column-and-rmagick/124231 "2007-12-26T19:58:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stratboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/838e76/32.png) [@stratboy](https://www.ruby-forum.com/u/stratboy)\
**Post date:** [December 26, 2007, 7:58pm UTC](https://www.ruby-forum.com/t/problems-with-file-column-and-rmagick/124231/1 "2007-12-26T19:58:31Z")

</div>

i have installed file\_column plugin and rmagick.

i have a model:

class Core \< ActiveRecord::Base  
has\_one :forum\_topic  
has\_many :votes  
has\_many :forum\_messages ,:through =\> :forum\_topic  
attr\_accessible :site,:descriptionm,:image  
file\_column :image  
…

and in form i have:

 USERNAME\*: \<%= text\_field "user", "name", "size" =\> 25, "maxlength" =\> 25 %\> ICONA: (.jpg,.gif,.png) \<%= file\_column\_field "core", "image" %\>

and in action of form i have:

```
@user=User.create(params[:user])
if params[:regions]
  @regions=Region.find(params[:regions])
  @user.regions=@regions
end
if @user.save
  @user.image=params[:core][:image]
  @user.save

```

So it works. the file is uploaded correctly and the record is saved in  
db.

If i edit model so:

class Core \< ActiveRecord::Base  
has\_one :forum\_topic  
has\_many :votes  
has\_many :forum\_messages ,:through =\> :forum\_topic  
attr\_accessible :site,:descriptionm,:image  
file\_column :image, :magick =\> {  
:geometry =\> “400x400”,  
:versions =\>  
{  
:small =\> {:crop =\> “1:1”, :size =\>  
“62Ã—62!” },  
:thumb =\> {:crop =\> “1:1”, :size =\>  
“30Ã—30!” },  
:medium =\> { :size =\> “600Ã—600” }  
}

I receive this error:  
Trying to access file\_column, but primary key got lost.

The error is at the istruction:  
@user=User.create(params[:user])

Why? How i can do?

Thanks

---

<div class="post-metadata">

**Author:** ![stratboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/838e76/32.png) [@stratboy](https://www.ruby-forum.com/u/stratboy)\
**Post date:** [March 3, 2008, 7:42pm UTC](https://www.ruby-forum.com/t/problems-with-file-column-and-rmagick/124231/2 "2008-03-03T19:42:37Z")

</div>

The problem is that validation is make after the resize with magick  
is possible make it before resize?  
Thanks
