Hi
I'm quite new to Rails and to ActiveScaffold. I'm working on a tight
deadline to build a database web app to manage a computer repair shop
where I work, so some help would be greatly appreciated. I'm using
Goldberg (
http://goldberg.240gl.org/ ) to manage users, layout and
content, and want to use ActiveScaffold for dynamic in-page management
of the actual data. After an initially positive and productive start
I've hit a brick wall with this frustrating problem. I've looked for
similar experiences on this group, and found many posts with similar
errors, but none quite the same. Most of those seem to involve complex
inter-table relationships, whereas my models are quite simple (for the
time being). The crazy thing is that I have one resource that
continues to work correctly even though the broken ones are configured
almost identically!
Thanks in advance for your help.
Joe
The error I get is as follows:
NameError in MachinesController#index
uninitialized constant ActiveRecord::Base::User
Full Trace
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:492:in `const_missing_before_generators'
/Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/rails_generator/lookup.rb:
15:in `const_missing'
/Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/
base.rb:1909:in `compute_type'
/Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/
reflection.rb:129:in `send'
/Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/
reflection.rb:129:in `klass'
vendor/plugins/active_scaffold/lib/actions/nested.rb:41:in
`links_for_associations'
vendor/plugins/active_scaffold/lib/data_structures/action_columns.rb:
68:in `each'
vendor/plugins/active_scaffold/lib/data_structures/action_columns.rb:
55:in `each'
vendor/plugins/active_scaffold/lib/actions/nested.rb:32:in
`links_for_associations'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
callbacks.rb:173:in `send'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
callbacks.rb:173:in `evaluate_method'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
callbacks.rb:161:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
filters.rb:430:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
filters.rb:592:in `run_before_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
filters.rb:578:in `call_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
filters.rb:573:in `perform_action_without_benchmark'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/benchmark.rb:293:in `measure'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
rescue.rb:201:in `perform_action_without_caching'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
caching/sql_cache.rb:13:in `perform_action'
/Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/
connection_adapters/abstract/query_cache.rb:33:in `cache'
/Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/
query_cache.rb:8:in `cache'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
caching/sql_cache.rb:12:in `perform_action'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:529:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:529:in `process_without_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
filters.rb:569:in `process_without_session_management_support'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
session_management.rb:130:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:389:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatcher.rb:149:in `handle_request'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatcher.rb:107:in `dispatch'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatcher.rb:104:in `synchronize'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatcher.rb:104:in `dispatch'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatcher.rb:120:in `dispatch_cgi'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatcher.rb:35:in `dispatch'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in
`process'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in
`synchronize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in
`process'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in
`process_client'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in
`process_client'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in
`initialize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in
`initialize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:
282:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:
281:in `each'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:
281:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in
`run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:
212:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:502:in `load'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:502:in `load'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:354:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:502:in `load'
/Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/commands/servers/
mongrel.rb:64
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:27:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:509:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:354:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:509:in `require'
/Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/commands/server.rb:39
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:27:in `require'
script/server:3
Request
Parameters:
None
Show session dump
---
:csrf_id: 9337a604d3f1086533ab4a3a6307eb34
:last_time: 2008-08-10 21:56:29.174980 +03:00
as:customers:
:list: {}
as:machines:
:list: {}
flash: !map:ActionController::Flash::FlashHash {}
:goldberg:
:path: /machines
:menu_item: setup/controllers
:user_id: 2
:menu_history:
/customers/list: Customers
/admin: admin
/goldberg/site_controllers/new_called/machines: setup/controllers
/goldberg/site_controllers/new_called/cases: setup/controllers
/menu/Customers: admin
/goldberg/auth/login:
/denied: Customers
/goldberg/site_controllers/new_called/parts: setup/controllers
/goldberg/site_controllers/show/15: setup/controllers
/goldberg/site_controllers/new_called/notes: setup/controllers
/goldberg/site_controllers/destroy/15: setup/controllers
/goldberg/site_controllers/new: setup/controllers
/goldberg/site_controllers/list: setup/controllers
/goldberg/site_controllers/new_called/service_cases: setup/
controllers
/menu/admin:
/menu/setup/controllers: setup
/goldberg/site_controllers/create: setup/controllers
/machines: Customers
/site_admin: setup
/menu/setup: admin
Response
Headers:
{"cookie"=>[],
"Cache-Control"=>"no-cache"}
************************************************************************************
This works correctly:
contollers/customers_controller.rb:
class CustomersController < ApplicationController
# layout "customers"
layout "application"
active_scaffold :customers
active_scaffold :customers do |config|
config.label = "Customers"
config.columns =
[:name, :contact_person, :email, :phone_number, :address_1]
list.columns.exclude :country
list.sorting = {:name => 'ASC'}
columns[:phone_number].label = "Phone #"
columns[:phone_number].description = "(Format: +###-##-#######)"
end
end
models/customer.rb
class Customer < ActiveRecord::Base
[:name, :email, :phone_number].each do |field|
validates_presence_of field
end
end
But for some reason this doesn't:
controllers/machines_controller.rb:
class MachinesController < ApplicationController
# layout "machines"
layout "application"
active_scaffold :machines
active_scaffold :customers do |config|
config.label = "Apple Device"
list.sorting = {:updated_at => 'ASC'}
end
end
models/machine.rb:
class Machine < ActiveRecord::Base
validates_presence_of :serial_number, :on => :create, :message =>
"can't be blank"
validates_uniqueness_of :serial_number, :on => :create, :message =>
"this serial number is already registered on the database!"
end