Hi

The line setting @column is in actions/subform.rb, in do_edit_associated:

@column = active_scaffold_config.columns[params[:child_association]]

What's the value of child_association param in the request? Is that column 
included in conf.columns?

Regards

El lunes, 3 de abril de 2023 9:24:52 (CEST) Dennis Bulgatz escribió:
> Hi Sergio,
> 
> Doh.. I eventually figured out that the conf.actions needs to include
> subform!  Hopefully this will help someone in the future.
> 
> class OdcsController < ApplicationController
> 
>   before_action :check_resource_permissions
> 
>   active_scaffold :"odc" do |conf|
>     conf.label = '8.  MISCELANEOUS PURCHASES AND OTHER DIRECT COSTS (ODCS)'
>     conf.subform.columns =[:line_item_number, :description, :qty,
> :justification ] conf.columns = [:line_item_number, :description, :qty,
> :justification, :sub_tdn ] conf.actions = [:delete, :list, :show, :search,
> :export, :subform] conf.export.default_file_format = 'xlsx' # or 'csv'
>   end
> 
> But I am getting a new error when I try to add Another child record, for
> example with “Create Another Odc”
> 
> 
> [cid:[email protected]]
> 
> 
> 
> ActionView::Template::Error (undefined method `name' for nil:NilClass):
> 
>     1: <%
> 
>     2: subform_id = sub_form_list_id(:association => @column.name, :id =>
> @parent_record.id || generated_id(@parent_record) || 99999999999)
> 
>     3: associated_form = render :partial => "form_association_record",
> :object => @record, :locals => {:scope => @scope, :parent_record =>
> @parent_record, :column => @column, :locked => @record.new_record? &&
> @column.association.singular?}
> 
>     4: options = {:singular => false}
> 
>     5: if @column.association.singular?
> 
> 
> 
> active_scaffold (ccfc9d71d522)
> app/views/active_scaffold_overrides/edit_associated.js.erb:2
> 
> actionview (6.1.7.3) lib/action_view/base.rb:247:in `public_send'
> 
> actionview (6.1.7.3) lib/action_view/base.rb:247:in `_run'
> 
> Not sure if this is an AS bug?  Or a problem somewhere in my code?
> 
> Thanks
> 
> Dennis
> 
> From: Dennis Bulgatz <[email protected]>
> Date: Saturday, April 1, 2023 at 11:08 PM
> To: Sergio Cambra <[email protected]>, ActiveScaffold : Ruby on Rails Gem
> <[email protected]> Subject: Re: Created a show helper, lost
> the association create
> Hi Sergio,
> 
> Thanks again.  I did as you suggested and created an override for
> column_renders_as.  For some reason, I get “Subform is not enabled” when I
> force subform.
> 
> What would a controller config look like to enable/disable the subform? 
> What is the method checking for the subform being enabled?
> 
>   def column_renders_as(column)
>     puts "YES, we are here! #{column.name.inspect}"
>     if column.name == :travels
>       logger.debug "@@@@@@@@@"
>       logger.debug "column.association.nil? : #{column.association.nil?}"
>       logger.debug "column.form_ui : #{column.form_ui}"
>       logger.debug
> "!active_scaffold_config_for(column.association.klass).actions.include?(:su
> bform) :
> #{!active_scaffold_config_for(column.association.klass).actions.include?(:s
> ubform)}" logger.debug "@@@@@@@@@"
>       return :subform
>     end
> 
>     if column.is_a? ActiveScaffold::DataStructures::ActionColumns
>       return :subsection
>     elsif column.active_record_class.locking_column.to_s == column.name.to_s
> or column.form_ui == :hidden return :hidden
>     elsif column.association.nil? or column.form_ui or
> !active_scaffold_config_for(column.association.klass).actions.include?(:sub
> form) return :field
>     else
>       return :subform
>     end
>   end
> 
> 
>  Rendered
> /Users/dbulgatz/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/bundler/gems/acti
> ve_scaffold-ccfc9d71d522/app/views/active_scaffold_overrides/_form_messages.
> html.erb (Duration: 0.4ms | Allocations: 147)
> 
> YES, we are here! :travels
> 
> @@@@@@@@@
> 
> column.association.nil? : false
> 
> column.form_ui :
> 
> !active_scaffold_config_for(column.association.klass).actions.include?(:subf
> orm) : true
> 
> @@@@@@@@@
> 
>   Rendered
> /Users/dbulgatz/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/bundler/gems/acti
> ve_scaffold-ccfc9d71d522/app/views/active_scaffold_overrides/_form.html.erb
> (Duration: 32.8ms | Allocations: 9586)
> 
>   Rendered
> /Users/dbulgatz/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/bundler/gems/acti
> ve_scaffold-ccfc9d71d522/app/views/active_scaffold_overrides/_base_form.html
> .erb (Duration: 37.9ms | Allocations: 14980)
> 
>   Rendered
> /Users/dbulgatz/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/bundler/gems/acti
> ve_scaffold-ccfc9d71d522/app/views/active_scaffold_overrides/_update_form.ht
> ml.erb (Duration: 38.3ms | Allocations: 15249)
> 
> Completed 500 Internal Server Error in 84ms (ActiveRecord: 12.1ms |
> Allocations: 41633)
> 
> 
> 
> 
> 
> 
> 
> ActionView::Template::Error (Subform is not enabled. Please enable it or
> remove any references in your configuration (e.g. config.subform.columns =
> [...]).):
> 
>     19:     <%= render :partial => 'form', :locals => { :columns => column,
> :subsection_id => subsection_id, :form_action => form_action, :scope =>
> scope } %>
> 
>     20:   </li>
> 
>     21:   <% end %>
> 
>     22:   <% elsif renders_as == :subform and authorized -%>
> 
>     23:   <%= content_tag :li, active_scaffold_subform_attributes(column,
> column_css_class) do %>
> 
>     24:     <%= render_column(column, @record, renders_as, scope) %>
> 
>     25:   <% end %>
> 
> 
> 
> active_scaffold (ccfc9d71d522) lib/active_scaffold/config/core.rb:250:in
> `[]'
> 
> Here is my controller:
> 
> class SubTdnsController < ApplicationController
>   active_scaffold :"sub_tdn" do |conf|
>     conf.columns = [:title, :ordinal, :work_lead,
> 
>                     :pop_begin, :pop_end,
>                     :introduction, :description_of_work,
>                     ::software_classification,
>                     :environment_impact, :data_sensitivity,
>                     ::special_requirements,
>                     :travels, :odcs, :gfis, :deliverables,
>                     ::data_rights_notice ]
> 
>     conf.create.columns = [
> 
>       :travels, :odcs, :gfis, :deliverables,
>       :title, :ordinal, :work_lead,
>       :pop_begin, :pop_end,
>       :introduction, :description_of_work, :software_classification,
>       :environment_impact, :data_sensitivity, :special_requirements,
>     :
>     :data_rights_notice ]
> 
>     conf.update.columns = [
> 
>       :travels, :odcs, :gfis, :deliverables,
>       :title, :ordinal, :work_lead,
>       :pop_begin, :pop_end,
>       :introduction, :description_of_work, :software_classification,
>       :environment_impact, :data_sensitivity, :special_requirements,
>     :
>     :data_rights_notice ]
> 
>     conf.list.columns = :sub_tdn_number, :title
>     conf.columns[:introduction].label =  "1. Introduction"
>     conf.columns[:description_of_work].label =  "2. Description of Work"
>     conf.columns[:software_classification].label =  "3. Software
> Classification" conf.columns[:environment_impact].label =  "4. Environment
> Impact" conf.columns[:data_sensitivity].label =  "5. Data Sensitivity"
> conf.columns[:special_requirements].label =  "6. Special Requirements"
> conf.columns[:travels].label =       "7. Travel Requirements"
>     conf.columns[:odcs].label =          "8. Other Direct Costs"
>     conf.columns[:gfis].label =          "9. Government Furnished Items"
>     conf.columns[:deliverables].label=   "10. Deliverables/Milestones"
>     conf.columns[:data_rights_notice].label=   "11. Data Rights Notice"
> 
>     conf.columns[:introduction].form_ui = :text_editor
>     conf.columns[:description_of_work].form_ui = :text_editor
>     conf.columns[:software_classification].form_ui = :text_editor
>     conf.columns[:environment_impact].form_ui = :text_editor
>     conf.columns[:data_sensitivity].form_ui = :text_editor
>     conf.columns[:special_requirements].form_ui = :text_editor
>     conf.columns[:data_rights_notice].form_ui = :text_editor
> 
>     conf.action_links.add 'get_pdf', :type => :member, controller:
> :sub_tdns, action: :show, page: true, :parameters => {format: :pdf}
> 
>     #conf.show.link.page = true
>   end
> 
> From: Sergio Cambra <[email protected]>
> Date: Friday, March 31, 2023 at 9:06 AM
> To: ActiveScaffold : Ruby on Rails Gem <[email protected]>
> Cc: Dennis Bulgatz <[email protected]>
> Subject: Re: Created a show helper, lost the association create
> Hi Dennis
> 
> There is a helper method, column_renders_as, which should return :subform
> for column travels. It would return :field if subform action has been
> excluded from travels controller, form_ui has been set for the column, or a
> helper _form_column has been defined for the column. Defining
> sub_tdn_travels_show_column shouldn't affect.
> 
> Was sub_tdn_travels_show_column being called in create/update form? Or was
> it displaying a list of checkboxes instead of subform?
> 
> What method is called with the super line? Super would call another method
> with the same name, and ActiveScaffold doesn't define
> sub_tdn_travels_form_column, so you must have defined that method somewhere
> else.
> 
> Regards
> 
> El jueves, 30 de marzo de 2023 0:32:39 (CEST) Dennis Bulgatz escribió:
> > Hi Sergio,
> > 
> > i have a resource that a column with a has_many association.
> > 
> > For the "show" action I have a column helper that renders the children as
> > a
> > table.
> > 
> >   def sub_tdn_travels_*show_column*(record, input_name)
> >   
> >     display_standard_table(
> >     
> >       [
> >       
> >         { :name => 'line_item_number', :display_name => 'Item' },
> >         { :name => 'purpose', :display_name => 'Purpose' },
> >         { :name => 'number_of_travelers', :display_name => 'Traveler(s)'
> >         },
> >         { :name => 'number_of_nights', :display_name => 'Night(s)' },
> >         { :name => 'number_of_days', :display_name => 'Days(s)'},
> >         { :name => 'from_date', :display_name => 'From'},
> >         { :name => 'to_date', :display_name => 'To'},
> >         { :name => 'destination', :display_name => 'Destination'}
> >     
> >     ], record.travels)
> >   
> >   end
> > 
> > This has stopped the create/update actions on the parent from showing the
> > AS form/partial that can create new child records.
> > 
> > Not sure what is going on, but can i restore partial with a call in the
> > 
> > helper method:
> >   def sub_tdn_travels_*form_column*(record, input_name)
> >   
> >       super(record,input_name) #THIS IS NOT RIGHT, but the idea is to use
> > 
> > default partial
> > 
> >   end
> > 
> > Thanks!
> > 
> > Dennis




-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/activescaffold/12199465.O9o76ZdvQC%40pc-sergio.

Reply via email to