I am looking to develop a personnel evaluation web form.
This stuff below is repeated 5 times with different job
responsibilities and outcomes ina kind table format. What is the most
efficient way to model this? Make a generic table and create a NEW
for each one in the controller save action?
Don't worry too much about forms and so on yet, think about the
fundamental objects in your requirement (users and assessments maybe).
Then think about the relationships, possibly:
user has_many assessments
assessment belongs_to user
Then work out what data and rules go in each model, and finally how to
display and enter the data.
The above is probably not what you want, but those are the sort of
things you have to think about.
I was looking more at how the tables were set up. I have a review table that hold the main form data; but the 5 pieces that repeat, I could make a table for each one but I was thinking there might be a more efficent way to do it and also make it more flexible so down the road if more sections get added I would not have to go add another table for that data. I put the header info(job role/requirements) into the DB so I could change it through the form instead of having to go into the code to modify it. Right now there are 5 of those sections in the form so I just do a FIND on them and loop through how many times they are there and display a partial X times and use the data in the db for the header info to make it relatively dynamic.
I was looking more at how the tables were set up. I have a review table
that hold the main form data; but the 5 pieces that repeat, I could make a
table for each one but I was thinking there might be a more efficent way to
do it and also make it more flexible so down the road if more sections get
added I would not have to go add another table for that data. I put the
header info(job role/requirements) into the DB so I could change it through
the form instead of having to go into the code to modify it. Right now
there are 5 of those sections in the form so I just do a FIND on them and
loop through how many times they are there and display a partial X times and
use the data in the db for the header info to make it relatively dynamic.
Sorry, you have completely lost me, please describe your table setup
more clearly. Give the name of each table and what the columns are
(not necessarily all the columns but enough for me to understand)
What do you mean 'the 5 pieces that repeat'? Again please describe
the data more clearly, not just in words but with field names and
descriptions.
Ok, I was referring to my first post, this data:
Key Job Responsibility #1 job1
Desired Outcome(s) outcome 1
Employee Assessment
Self Assessment Rating:
Self Assessment Comments:
Supervisor Assessment
Supervisor Rating:
Supervisor Comments:
repeats itself 5 times in the form. I was thinking instead of making 5 tables to hold the data ther mught be a more efficient way and flexible way to hold the data. I do not have any tables yet really I was waiting to see if a better way to do it than to statically make 5 tables if there was a different way to do this section of the form.
The Key job resp, and outcomes TEXT are static, that is in the db. Example,
job responsibility, understand the network(in the db).
outcomes, know all systems(in the db).
Therefore I have 5 rows in a table that hold that data. I loop through and display the data section above in a table format with the the text from the db populating the responsibility and outcomes section and then a drop down box for the rating and a text area for comments.
Right now I have no tables to insert for the data.
repeats itself 5 times in the form. I was thinking instead of making 5
tables to hold the data ther mught be a more efficient way and flexible way
to hold the data. I do not have any tables yet really I was waiting to see
if a better way to do it than to statically make 5 tables if there was a
different way to do this section of the form.
Why do you contemplate 5 tables? Why not just have 5 rows in one
table? I think we are back to what I was saying originally, think
about the data you are trying to model. What do you call one set of
the data above? Maybe a Responsibility? So have a responsibilities
table. Then what is it that has these responsibilities? An Employee?
So have an employees table. Then
Employee has_many :responsibilities # it will be 5 actually
Responsibility belongs_to :employee
If you have an employee in @employee then his responsibilities are
@employee.responsibilities.