I have User model and users have they own customers. In rails4-autocomplete I want the user to have autocomplete(:name, :address, :zip, :phone ....) only from they own customers. So I need a condition somewhere in Customer controller where I have :
autocomplete :customer, :customer_name, :extra_data => [:phone, :address, :zip_code, :email]
I've tried in customer model :
default_scope where(:user_id => current_user.id)
but rails4-autocomplete doesn't work anymore.
I have customer.rb
belongs_to :job, optional: true
belongs_to :user, optional: true
And user.rb
has_many :customers
And _customers_fields.html.erb:
<%= f.autocomplete_field :customer_name, autocomplete_customer_customer_name_customers_path,
:update_elements => { :id => '#id_element',
:phone => '#phone-number',
:address => '#address_element',
:zip_code => '#zip_code_element',
:email => '#email_element'
}, class: "form-control", :required => true, placeholder: "Company Name", autocomplete: 'off' %>