PiRSquared17 / activescaffold

Automatically exported from code.google.com/p/activescaffold
MIT License
0 stars 0 forks source link

ActiveRecord::Reflection::AssociationReflection.reverse shouldn't make up an column #704

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Given the following scenario:

class Company < ActiveRecord::Base
  belongs_to :contact
end

class Contact < ActiveRecord::Base

end

class Maintenance::CompaniesController < Maintenance::Base
  active_scaffold :companies do |config|
    config.columns[:contact].form_ui = :select
  end
end

class Maintenance::ContactsController < Maintenance::Base
  active_scaffold :contacts
end

When browsing the companies controller, it will automatically create links
to create a new contact if no contact exists.  To get the parent column it
uses this code:

  http://is.gd/3ABgu

The reverse_matches_for method appropriately returns empty - there is no
reverse matches.  But line 13 here invents one ("companies").  This
eventually causes a very cryptic error, saying "no such accessor
companies=", this because the constraints translator can't translate it
appropriately - no association to do such a thing.

I believe the correct behavior would be:

a) change line 13 so it no longer invents a parent column
b) don't offer the create_new link if no reverse assocation exists.

Original issue reported on code.google.com by timchar...@gmail.com on 23 Sep 2009 at 7:25

GoogleCodeExporter commented 9 years ago
the cryptic error is manifested when you actually click the "Create New" link.

Original comment by timchar...@gmail.com on 23 Sep 2009 at 7:27

GoogleCodeExporter commented 9 years ago
Fixed in e26b690

Original comment by sergio.c...@gmail.com on 27 Oct 2009 at 4:48