Rails 4 app with has_many through

I need to make an application in which there are two models: User and Company. In this case, users may be employees of the company, and then the user must be associated with Company model, and if the user is not an employee of the company, the connection with the Company model should not be.

I’m trying to make it through the association has_many through:

Models:

== Schema Information

Try to set autosave: true on your association

I would test this out in the rails console first, to ensure the model relationships are correct. Also you might want to use :accepts_nested_attributes_for :users for your Company model