Rails multipole sites using the same database / shared tables?
I am currently looking at using rails for a web app im working on..
It's a contact database for my church, with some fairly complex user authorization stuff (V Sensitive data)
I'm also looking at building a fairly complex (Content Deep) site for them using rails too..
What i'd really like to do is have it so the user can have the same login etc.. for 开发者_JAVA技巧the contact database, the blog, the download site etc..
i havent really used rails much but is it possible to have multiple apps running on the same database?
and if so is it possible to have your user model in one application have more fields than in another (reading from the same table)..
i.e.
User in the contact database would have fields like, name, age, can_see_x etc.. Where a User in the blog wouldnt have the can_see_x field..
could these models be reading from the same table?
Thanks
Daniel
Both of those are possible. You just have to make sure the data in the db config file is the same.
As far as making one user model have more fields than another, you can use the attr_accessible
tag to determine which fields are accessible in each respective model.
For example: One user model could look like this
attr_accessible :first_name, :last_name, :total_sales
While another would look like this:
attr_accessible :first_name, :last_name, :birthday
In the first, you'd be able to access user_object.total_sales
, but not user_object.birthday
. The reverse is also true.
精彩评论