Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch Create: undefined method 'options_for_association' #3

Closed
guycall opened this issue Nov 23, 2015 · 3 comments
Closed

Batch Create: undefined method 'options_for_association' #3

guycall opened this issue Nov 23, 2015 · 3 comments

Comments

@guycall
Copy link

guycall commented Nov 23, 2015

I am upgrading an old Rails 3 app that used the vho versions of activescaffold and activescaffold_batch to Rails 4 and the https://github.com/activescaffold/ versions.

Currently my app is:

  • rails 4.0.13
  • ruby 2.0
  • active_scaffold 3.4.30
  • active_scaffold_batch 3.3.2

I have Unit model that has_many :trainings and Training model that belongs_to :unit. In my trainings controller:

config.actions.add :batch_create
config.batch_create.default_batch_by_column = :unit

When I click the create batch link I get the error:

ActionView::Template::Error (undefined method `options_for_association' for #<     <Class:0x00000006c1b668>:0x00000004e405f8>):
     5:   </dt>
     6:   <dd>
     7:     <% if column == batch_create_by_column.to_sym %>
     8:       <%= active_scaffold_batch_create_by_column column, scope, :object => record %>    
     9:     <% else %>
    10:       <%= active_scaffold_input_for column, scope, options %>
    11:       <% if column.update_columns -%>
  active_scaffold_batch (3.3.2) lib/active_scaffold/helpers/batch_create_column_helpers.rb:22:in `active_scaffold_batch_create_singular_association'
  active_scaffold_batch (3.3.2) lib/active_scaffold/helpers/batch_create_column_helpers.rb:13:in `active_scaffold_batch_create_by_column'
  active_scaffold_batch (3.3.2) app/views/active_scaffold_overrides/_batch_create_form_attribute.html.erb:8:in `__var_lib_gems_______gems_active_scaffold_batch_______app_views_active_scaffold_overrides__batch_create_form_attribute_html_erb__1283941216574438672_54293840'
  actionpack (4.0.13) lib/action_view/template.rb:143:in `block in render'
  activesupport (4.0.13) lib/active_support/notifications.rb:161:in `instrument'

Looking through history, that method disappeared here: activescaffold/active_scaffold@8cc6406#diff-4c47891cc03986ef007c128a77d82b09

@scambra
Copy link
Member

scambra commented Nov 23, 2015

I forgot to update active_scaffold_batch when I removed that deprecated method.

@scambra
Copy link
Member

scambra commented Nov 23, 2015

fixed on 25c0b82

@scambra scambra closed this as completed Nov 23, 2015
@guycall
Copy link
Author

guycall commented Nov 23, 2015

Thanks. That has solved the error. I do now get a different problem when actually trying to create the batch:

ActiveRecord::RecordNotFound (Couldn't find all Units with IDs (Travel Unit Part 1, Travel Unit Part 2) (found 0 results, but was looking for 2)):
  activerecord (4.0.13) lib/active_record/relation/finder_methods.rb:199:in `raise_record_not_found_exception!'
  activerecord (4.0.13) lib/active_record/relation/finder_methods.rb:308:in `find_some'
  activerecord (4.0.13) lib/active_record/relation/finder_methods.rb:272:in `find_with_ids'
  activerecord (4.0.13) lib/active_record/relation/finder_methods.rb:36:in `find'
  activerecord-deprecated_finders (1.0.4) lib/active_record/deprecated_finders/relation.rb:122:in `find'
  activerecord (4.0.13) lib/active_record/querying.rb:3:in `find'
  active_scaffold (3.4.30) lib/active_scaffold/attribute_params.rb:202:in `column_plural_assocatio

I've not yet investigated it. So I'll look into the issue now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants