# State\_models plugin and file\_column?

**URL:** <https://www.ruby-forum.com/t/state-models-plugin-and-file-column/57825>\
**Category:** Rails\
**Created:** [April 14, 2006, 4:06pm UTC](https://www.ruby-forum.com/t/state-models-plugin-and-file-column/57825 "2006-04-14T16:06:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hatless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/848f3c/32.png) [@hatless](https://www.ruby-forum.com/u/hatless)\
**Post date:** [April 14, 2006, 4:06pm UTC](https://www.ruby-forum.com/t/state-models-plugin-and-file-column/57825/1 "2006-04-14T16:06:34Z")

</div>

I was looking at Kyle Mawell’s extremely nifty-looking StateModels  
plugin

[http://www.kylemaxwell.com/articles/2006/02/06/fun-with-single-table-inheritance](http://www.kylemaxwell.com/articles/2006/02/06/fun-with-single-table-inheritance)

and before I go down the road with it, I was wondering if anyone has  
used it with file\_column.

The way file\_column deals with an uploaded file – by storing it to the  
filesystem in a path that employs the model name and id – sounds like  
it might break against this.

Thanks.

---

<div class="post-metadata">

**Author:** ![hatless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/848f3c/32.png) [@hatless](https://www.ruby-forum.com/u/hatless)\
**Post date:** [April 14, 2006, 10:22pm UTC](https://www.ruby-forum.com/t/state-models-plugin-and-file-column/57825/2 "2006-04-14T22:22:00Z")

</div>

On 4/14/06, Steve K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> it might break against this.  
> You can hardcode the path in the base class.

class MyModel \< ActiveRecord::Base  
file\_column :my\_field, :store\_dir =\> :some\_method  
def some\_method  
“my\_model/my\_field”  
end  
end

–  
Kyle M.  
Chief Technologist  
E Factor Media // FN Interactive  
removed\_email\_address@domain.invalid  
1-866-263-3261

---

<div class="post-metadata">

**Author:** ![hatless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/848f3c/32.png) [@hatless](https://www.ruby-forum.com/u/hatless)\
**Post date:** [April 14, 2006, 10:34pm UTC](https://www.ruby-forum.com/t/state-models-plugin-and-file-column/57825/3 "2006-04-14T22:34:22Z")

</div>

Hi Kyle,

I too am interested in doing this for my application, so I created a new  
rails app, loaded the database schema, added the changes to  
conf/environment.rb and generally followed your instructions to the  
letter. When I post a page (or do anything other than render HTML, for  
that matter) I get the error below. What have I done wrong? ☹

I am using Rails 1.1.2 with Ruby 1.8.4, if that helps…

TIA,

Matt

NameError in SignupController#page\_one

uninitialized constant PageOne

|RAILS\_ROOT: script/…/config/…|

Application Trace [http://localhost:3000/signup/page\_one#](http://localhost:3000/signup/page_one#) | Framework  
Trace [http://localhost:3000/signup/page\_one#](http://localhost:3000/signup/page_one#) | Full Trace  
[http://localhost:3000/signup/page\_one#](http://localhost:3000/signup/page_one#)

|/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active\_support/dependencies.rb:123:in `const_missing' #{RAILS_ROOT}/app/controllers/signup_controller.rb:5:in `page\_one’|

|/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active\_support/dependencies.rb:123:in `const_missing' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:910:in `perform\_action\_without\_filters’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action\_controller/filters.rb:368:in  
`perform_action_without_benchmark' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in `perform\_action\_without\_rescue’  
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in `perform\_action\_without\_rescue’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action\_controller/rescue.rb:82:in  
`perform_action' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:381:in `process\_without\_filters’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action\_controller/filters.rb:377:in  
`process_without_session_management_support' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/session_management.rb:117:in `process’  
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/dispatcher.rb:38:in  
`dispatch' /usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:115:in `handle\_dispatch’  
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick\_server.rb:81:in  
`service' /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service’  
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' /usr/lib/ruby/1.8/webrick/server.rb:173:in `start\_thread’  
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' /usr/lib/ruby/1.8/webrick/server.rb:95:in `start’  
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start' /usr/lib/ruby/1.8/webrick/server.rb:23:in `start’  
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start' /usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:67:in `dispatch’  
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/servers/webrick.rb:59  
/usr/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:21:in `require' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require’  
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/server.rb:30  
/usr/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:21:in `require' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require’  
script/server:3|

|/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active\_support/dependencies.rb:123:in `const_missing' #{RAILS_ROOT}/app/controllers/signup_controller.rb:5:in `page\_one’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action\_controller/base.rb:910:in  
`perform_action_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:368:in `perform\_action\_without\_benchmark’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action\_controller/benchmarking.rb:69:in  
`perform_action_without_rescue' /usr/lib/ruby/1.8/benchmark.rb:293:in `measure’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action\_controller/benchmarking.rb:69:in  
`perform_action_without_rescue' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/rescue.rb:82:in `perform\_action’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action\_controller/base.rb:381:in  
`process_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:377:in `process\_without\_session\_management\_support’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action\_controller/session\_management.rb:117:in  
`process' /usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/dispatcher.rb:38:in `dispatch’  
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick\_server.rb:115:in  
`handle_dispatch' /usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:81:in `service’  
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run’  
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' /usr/lib/ruby/1.8/webrick/server.rb:162:in `start\_thread’  
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start' /usr/lib/ruby/1.8/webrick/server.rb:92:in `start’  
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start' /usr/lib/ruby/1.8/webrick/server.rb:82:in `start’  
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick\_server.rb:67:in  
`dispatch' /usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/servers/webrick.rb:59 /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require’  
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active\_support/dependencies.rb:147:in  
`require' /usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/server.rb:30 /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require’  
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active\_support/dependencies.rb:147:in  
`require’  
script/server:3|

|This error occured while loading the following files:  
user\_continuation/page\_one.rb|

```
Request

```

_Parameters_: {“commit”=\>“Save changes”, “signup”=\>{“login”=\>“Zed Test”,  
“password”=\>“password”}}

Show session dump [http://localhost:3000/signup/page\_one#](http://localhost:3000/signup/page_one#)

* * *

flash: !map:ActionController::Flash::FlashHash {}

```
Response

```

_Headers_: {“cookie”=\>[], “Cache-Control”=\>“no-cache”}

---

<div class="post-metadata">

**Author:** ![hatless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/848f3c/32.png) [@hatless](https://www.ruby-forum.com/u/hatless)\
**Post date:** [April 15, 2006, 4:51am UTC](https://www.ruby-forum.com/t/state-models-plugin-and-file-column/57825/4 "2006-04-15T04:51:02Z")

</div>

I was curious about whether you knew if a file\_column field filled on  
page one of a multipage form would still be there and save properly when  
page 3 was submitted.

I don’t think this below is quite what I meant unless this is a fix you  
already found you needed to make yourself, but I guess it won’t hurt  
for me to set up a test app and see if StateModels and FileColumn play  
well together myself. Either you have indeed got it working or you’re  
pretty confident it will. These are Good Signs. 🙂

Thanks.

Kyle M. wrote:

> On 4/14/06, Steve K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > it might break against this.  
> > You can hardcode the path in the base class.
> 
> class MyModel \< ActiveRecord::Base  
> file\_column :my\_field, :store\_dir =\> :some\_method  
> def some\_method  
> “my\_model/my\_field”  
> end  
> end

---

<div class="post-metadata">

**Author:** ![hatless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/848f3c/32.png) [@hatless](https://www.ruby-forum.com/u/hatless)\
**Post date:** [April 15, 2006, 3:52am UTC](https://www.ruby-forum.com/t/state-models-plugin-and-file-column/57825/5 "2006-04-15T03:52:34Z")

</div>

On 4/14/06, Matthew L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi Kyle,
> 
> I too am interested in doing this for my application, so I created a new  
> rails app, loaded the database schema, added the changes to  
> conf/environment.rb and generally followed your instructions to the  
> letter. When I post a page (or do anything other than render HTML, for  
> that matter) I get the error below. What have I done wrong? ☹
> 
> I am using Rails 1.1.2 with Ruby 1.8.4, if that helps…

Someone told me that Rails 1.1 wants the models to be in different  
files, I believe. If you require\_dependency “model\_file\_name” (no  
.rb) in your config/environment file, you _should_ be fine. Tell me  
if that doesn’t work and I’ll look into it in detail.

-Kyle

---

<div class="post-metadata">

**Author:** ![hatless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/848f3c/32.png) [@hatless](https://www.ruby-forum.com/u/hatless)\
**Post date:** [April 17, 2006, 7:09pm UTC](https://www.ruby-forum.com/t/state-models-plugin-and-file-column/57825/6 "2006-04-17T19:09:32Z")

</div>

On 4/14/06, Steve K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks.
> 
> > end  
> > end
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

File\_column will still be able to find the previously saved file, but  
updating it will do funny things, unless you follow the hard-coding  
suggestion in the previous email.

–  
Kyle M.  
Chief Technologist  
E Factor Media // FN Interactive  
removed\_email\_address@domain.invalid  
1-866-263-3261
