Julian
Julian

Reputation: 145

Rails 4 - Creating a settings page

I currently have users set up with Devise. I want to add a settings page that belongs to a user for business settings , and I have been reading that it is better to keep the User model as clean as possible. How can I create a page that has a form with "company Name", "Company Phone", etc.

Upvotes: 0

Views: 212

Answers (1)

calas
calas

Reputation: 1603

I would create an Account, Customer or Company model that relates to the user(s) model(s).

If a Company is supossed to have several users then maybe users belongs_to a Company and the company would have_many users. In this case only Company admins would be able to update Company information.

If a Company will have only one user then the Company would belongs_to :user and the user would have_one :company and accepts_nested_attributes_for :company. From your question I think this is the one you will need.

With accepts_nested_attributes_for you can then update company details in your forms using field_for

When using devise I usually go with a '/profile' resource page where you can put your settings forms.

Upvotes: 1

Related Questions