I have a one to many association between jobs and companies and it works fine. In the job form view I have text_field for the company name with an autocomplete feature. The autocomplete works fine but the find_or_create_by don't create a new company if I put a company name that doesn't exist in the autocomplete list.
def company_name
company.try(:name)
end
def company_name=(name)
@company = Company.find_or_create_by(name: name)
end