0

I am having a lot of trouble setting this gem up. I just added the gem yesterday--first, is it truly compatible with Rails 4? (because that's what I am using)

If so I'm not sure what I am doing wrong. I have UserOrganizations and Organizations models. UserOrganizations stores the relationships between users and orgs--so it belongs to orgs.

I want people to search by the organization's :name to add it as a relationship to their user account. In the user_organizations_controller.rb:

  autocomplete :organization, :name, full: true

routes.rb:

  resources :user_organizations do
    get :autocomplete_organization_name, on: :collection
  end

Then, continuing on with the tutorial provided here, I add the following in UserOrganization's _form.html.erb:

<%= f.autocomplete_field :organization_name,
  autocomplete_organization_name_user_organizations_path %>

This then returns:

undefined method `organization_name' for #<UserOrganization:0x6846f48>

In the view, do I actually need to put in :organization? :name? If not, I am not sure what I need to be doing differently, I followed the tutorial pretty closely and it put in :brand_name despite that not being an actual attribute name. I have the gems jquery-rails and jquery-ui-rails installed, and autocomplete-rails.js is listed with the other script files. Thanks for any help. This is, of course, after restarting the server repeatedly.

1 Answer 1

1

Answer: Nevermind, I've decided to use the select2 gem instead. It's way easier and does exactly what I want. Not sure if I didn't understand the tutorial directions or it is compatibility issues with Rails 4, but I've found this instead.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.