I'm building an app that provides functionality for both consumers and businesses. In creating my models, I'm thinking of having user (consumer) and business...where each business would also have user(s), but users wouldn't necessarily belong to a business. To reduce redundancy I'd collect name, email, etc in User and specific business info (address, phone) in Business.
class Business < ActiveRecord::Base
belongs_to :user
end
class User < ActiveRecord::Base
has_one :business #only if business user, not consumer
end
Is this the correct way to configure the desired relationship?
Then when it comes time for business registration, is it possible (and how) to have nested forms where my business object is first, then user...so I'm collecting information in that order? All examples/info I've found shows the setup with user info captured first, then any sub-models.
In my following example, would this be correct:
<%= form_for(@business) do |f| %>
#grab business info
<%= f.fields_for :user do |ff| %>
#grab user info
Thanks for your time and assistance.