G
G
Gosha Arinich2011-09-16 18:54:51
MongoDB
Gosha Arinich, 2011-09-16 18:54:51

Rails application architecture?

Given: Rails 3.1, Devise, Mongoid
Need: somehow organize two types of users - Client and Developer, both should have different parameters in the profile. But everyone should be able to login through one form.
There are several ideas, for example - the Client and the Developer are different models, but each embed (embeds) User model.
Or the Client and the Developer are inherited from the User.
Question on StackOverflow

Answer the question

In order to leave comments, you need to log in

3 answer(s)
H
himik, 2011-09-16
@himik

Single table inheritance might work for you
StackOverflow question

K
Kasheftin, 2011-09-23
@Kasheftin

Imagine that the project grows and it will be necessary for the user to be both a customer and a performer (for example, a webmaster developer orders a design from a designer contractor). You will need a bike to synchronize the two models.
Take one user model, roles from cancan, here is a tutorial, there are plenty of attributes so that there are enough custom validators for all roles - what type of user can have which attributes. The form from devise will automatically turn out one.
Although one form can be drawn through partial, put the required object in : locales, if there are fields that are used in the form, everything will work out.

D
d4rkr00t, 2011-09-16
@d4rkr00t

There was an article on Habré about polymorphic models and Devise :) as an option to do so.
I made one model and a connection for additional. user fields depending on the type of user.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question