Forum: Ruby on Rails state_models plugin and file_column?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
34f5b045aec62235c17458650ea75353?d=identicon&s=25 Steve Koppelman (hatless)
on 2006-04-14 16:06
I was looking at Kyle Mawell's extremely nifty-looking StateModels
plugin

http://www.kylemaxwell.com/articles/2006/02/06/fun...

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.
4bd34a2216dc8bdbf1f017f64e4d59e8?d=identicon&s=25 Kyle Maxwell (Guest)
on 2006-04-14 22:22
(Received via mailing list)
On 4/14/06, Steve Koppelman <hatlessnyc@yahoo.com> 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 Maxwell
Chief Technologist
E Factor Media // FN Interactive
kyle@efactormedia.com
1-866-263-3261
0ccfc4935cd968d289decc405604a2ca?d=identicon&s=25 Matthew Law (Guest)
on 2006-04-14 22:34
(Received via mailing list)
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#> | Framework
Trace <http://localhost:3000/signup/page_one#> | Full Trace
<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#>

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



    Response

*Headers*: {"cookie"=>[], "Cache-Control"=>"no-cache"}
4bd34a2216dc8bdbf1f017f64e4d59e8?d=identicon&s=25 Kyle Maxwell (Guest)
on 2006-04-15 03:52
(Received via mailing list)
On 4/14/06, Matthew Law <matt@matthewlaw.plus.com> 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
34f5b045aec62235c17458650ea75353?d=identicon&s=25 Steve Koppelman (hatless)
on 2006-04-15 04:51
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 Maxwell wrote:
> On 4/14/06, Steve Koppelman <hatlessnyc@yahoo.com> 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
4bd34a2216dc8bdbf1f017f64e4d59e8?d=identicon&s=25 Kyle Maxwell (Guest)
on 2006-04-17 19:09
(Received via mailing list)
On 4/14/06, Steve Koppelman <hatlessnyc@yahoo.com> wrote:
> Thanks.
> >   end
> > end
>
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> 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 Maxwell
Chief Technologist
E Factor Media // FN Interactive
kyle@efactormedia.com
1-866-263-3261
This topic is locked and can not be replied to.