I am trying to implement this but I can't get it to work:
https://github.com/activescaffold/active_scaffold/wiki/
<https://github.com/activescaffold/active_scaffold/wiki/>Custom-Association-Options
<https://github.com/activescaffold/active_scaffold/wiki/Custom-Association-Options>
Here's my controller:
class Admin::Scaffold::BlocksTaxonsController < ApplicationController
layout "admin_scaffold"
protect_from_forgery except: [:create, :update]
active_scaffold :blocks_taxon do |config|
config.actions = [:create, :list, :update, :show, :delete, :field_search]
config.columns = [:taxon, :block, :position]
config.list.columns = [:block, :position, :go_live_at, :kind]
config.create.columns = [ :block_id, :go_live_at, :position, :kind]
config.columns[:block_id].form_ui = :select // THIS IS THE SELECT LIST I
AM TRYING TO MAKE DYNAMIC
config.columns[:kind].form_ui = :select
config.columns[:kind].options = { :options => {"heading" => "heading"}}
config.label = "Block Taxons"
config.list.sorting = { :position => :asc }
end
end
Here's my helper:
module Admin::Scaffold::BlocksTaxonsHelper
def options_for_association_conditions(association)
byebug
if association.name == :block_id
# byebug
if !Block.roots.all.nil?
Block.roots.all.collect{|b| [b.name, b.id]}
else
super
end
else
super
end
end
end
My debugging statement (byebug) isn't even called --- thus, the
options_for_association_conditions method isn't getting called.
Instead, I get this:
NoMethodError - undefined method `collect' for nil:NilClass:
active_scaffold (3.4.17)
lib/active_scaffold/helpers/form_column_helpers.rb:342:in
`active_scaffold_input_enum'
active_scaffold (3.4.17)
lib/active_scaffold/helpers/form_column_helpers.rb:357:in
`active_scaffold_input_select'
active_scaffold (3.4.17)
lib/active_scaffold/helpers/form_column_helpers.rb:23:in
`active_scaffold_render_input'
active_scaffold (3.4.17)
lib/active_scaffold/helpers/form_column_helpers.rb:10:in
`active_scaffold_input_for'
active_scaffold (3.4.17)
lib/active_scaffold/helpers/form_column_helpers.rb:175:in `form_attribute'
active_scaffold (3.4.17)
lib/active_scaffold/helpers/form_column_helpers.rb:162:in `render_column'
active_scaffold (3.4.17)
app/views/active_scaffold_overrides/_form.html.erb:27:in `block in
_df4c0d2b9a464dad64b929430d613032'
What have I missed? I need my select list to be dynamically pulled from the
database at runtime.
Thanks
Jason
----
Jason Fleetwood-Boldt
[email protected]
http://www.jasonfleetwoodboldt.com/writing
--
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails Gem" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/activescaffold.
For more options, visit https://groups.google.com/d/optout.