Category:CNCThis subproject is one of many research subprojects utilizing the resources provided by a Center grant funded by NIH/NCRR. The subproject and investigator (PI) may have received primary funding from another NIH source, and thus could be represented in other CRISP entries. The institution listed is for the Center, which is not necessarily the institution for the investigator. In ongoing studies, we are studying human volunteer sensitivity to the root extract of black cohosh (BC) and black cohosh alone (BC+AC). The study involves a pharmacokinetic study.Q:
How to restrict access of some users to a table or access a specific attribute?
I would like to make sure that only certain users can access some tables in the database.
For example, say I have two tables, contact and messages:
contact
=====
id (pk)
name
messages
=====
id (pk)
message_id (fk)
user_id (fk)
date
user_name (fk)
What I would like to achieve is that only the user with a name equal to USER_NAME can access the table messages, and that the user with a name equal to USER_NAME can access the contact table.
How would I achieve this?
A:
This can be achieved using the has_many and belongs_to relations between User and Contact.
The User can be defined as such:
class User
has_many :contacts
has_many :messages, :through => :contacts
end
The Contact will need a column for the user_id that references the user table:
class Contact
belongs_to :user
has_many :messages, :dependent => :destroy
validates :user_id, presence: true
validates :user, :presence => true
end
The Message model will have the user_id attribute as a foreign key, and the user_id value will belong to the user with a name of USER_NAME.
The present invention relates to the field of hydromachines, specifically, to a flowmeter with a piston pump for a controlled operation.
The invention relates to a hydromachine, be359ba680
Related links:
Comments