vigetlabs / active_admin_associations

This extends ActiveAdmin to allow for better editing of associations.
MIT License
119 stars 55 forks source link

Auto Complete URL non existant #9

Closed maxstudener closed 11 years ago

maxstudener commented 11 years ago

The Autocomplete is ajax calling "/autocomplete/#{assoication}?q=#{search}"

But this routes doesnt exist, documentation doesn't say anything about this.

Do we need to add our own controller and return json?

brianjlandau commented 11 years ago

Did you configure Autocomplete? You need to make sure to specify config.aa_associations.autocomplete_models in config/application.rb.

maxstudener commented 11 years ago

module LUCom class Application < Rails::Application

Settings in config/environments/* take precedence over those specified here.

# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
config.aa_associations.autocomplete_models %(group product)

still no avail

brianjlandau commented 11 years ago

Can you change that to:

config.aa_associations.autocomplete_models = %w(group product)

See if that helps.

lpopa commented 11 years ago

It seems like i have a similar issue: undefined method `relate_admin_sale_section_path' for #<#Class:0x007fc464488070:0x007fc46441ac78>

sale_section model

class SaleSection < ActiveRecord::Base

has_and_belongs_to_many :products accepts_nested_attributes_for :products

end

sale_section model/controller active_admin

ActiveAdmin.register SaleSection do association_actions

form :partial => "admin/shared/form"

form_associations do association :products, [:name, :sku] end end

product model

class Product < ActiveRecord::Base has_and_belongs_to_many :sale_sections autocomplete :name, :format_label => proc {|p| label = "#{p.name} - #{p.sku}" label } end

I have this in config/application : config.aa_associations.autocomplete_models = %w(sale_section product)

maxstudener commented 11 years ago

You are correct it was the missing =

lpopa commented 11 years ago

I realized why i am getting this error. I have nested resources for sale and sale_sections. When i commented out the
"#belongs_to :sale, :finder => :find_by_permalink" in the AA resource definition block the edit form worked just fine.

Is there something i am missing in this case?

brianjlandau commented 11 years ago

@lpopa this would be a different issue. Also, not sure why belongs_to would effect this. Can you open up a separate issue for this, and I'll look into when I can. If you discover what the root issue is or find a fix, feel free to submit a pull request, I'd happily accept it.