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 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. -- Posted via http://www.ruby-forum.com/.
On 4/14/06, Steve Koppelman <hatlessnyc@yahoo.com> wrote:> 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 > > 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.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
Matthew Law
2006-Apr-14 20:32 UTC
[Rails] State models error (was state_models plugin and file_column?)
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"}
Kyle Maxwell
2006-Apr-15 01:50 UTC
[Rails] State models error (was state_models plugin and file_column?)
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
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-- Posted via http://www.ruby-forum.com/.
On 4/14/06, Steve Koppelman <hatlessnyc@yahoo.com> wrote:> 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 > > > -- > 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