In my application's admin interface, I am using ActiveScaffold for easy record editing:
class Admin::InspectionsController < ApplicationController
require_role :staff
protect_from_forgery :only => [:create, :update, :destroy]
active_scaffold :inspections do |config|
[:create, :delete].each {|a| config.actions.exclude a}
config.actions.exclude :nested
config.update.columns = [ :name, :activity_status, :inspector, :report, :note, :time_window, :inspection_type ]
end
end
In this case, :activity_status
and :inspector
are association columns, referring to associated objects. In my scaffold, I want the editor to be able to change which object the foreign key points to, but the above config shows this:
I only want the inspector itself to be updated, not its fields!
Changing the column to :inspector_id
only allows the ID itself to be edited directly.
What am I doing wrong?
Workaround I've used is to remove all columns from the subform action on the relevant controllers:
class Admin::UsersController < ApplicationController
active_scaffold :users do |config|
#...
config.subform.columns = []
#...
end
end
I don't know if there's a better, more elegant way though…
Use the form_ui
method for the column in the Inspections controller:
[:activity_status, :inspector].each do |c|
config.columns[c].form_ui = :select
end