Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Rails Check In & Out System

Hello All!

As I am new to Rails I was hoping someone could help me out with this.

I am trying to build a simple check in and out system.

Example:

User - id, username, email, password

Employee - id, employNum, firstName, lastName,

Equipment - id, alias, status

Vehicle - id, vehNum

I want a user to check out an equipment to an employee that is in a vehicle.

so outcome would basically be "Employee(1234) checked out Equipment(tablet) in Vehicle(123).

Now after that I can then show in a table what was checked out and what is not.

Let me know if this is simple.

I did it in php but its def. different in Rails. :)

Thanks in advance.

2 Answers

Hi Allen,

That's all doable; you need to define your models, which you've done some of, then create a model, view and controller for each. Personally (because I am massively lazy) I'd use scaffold to generate all those for me. Then define the relationships and modify the controllers to drive the workflow for you. Add some validation in the models too.

I'm happy to help get you started; maybe I can create the app and some models and chuck that at Github, you can pull that down and crack on with the rest of the app?

And, why have you decided to use Rails for this? Have you considered using Spring framework with Java? I've only briefly touched that, but it is way cleaner than RonR and I will be learning more of it when I get time. Ironically, I've got three RonR projects on at the moment, so I'm time-poor from a learning perspective.

Let me know which bits of RonR you're not happy with and I'll see what I can do to help.

Steve. :+1:

Thank you very much for your fast response.

I actually have all the default models/controllers/views setup. I think the only thing I really need help with is relationships.

Do I need to add any additional columns to my models? I need to have a form that pulls the list of Employees,Equipment,Vehicles(not already checked out) and when I select one of each and hit submit, it would then change the status of each one and have them linked to each other.

So if I have a table that will show me all stuff that is check out will be listed.

As far as the Java, I don't actually know Java. I don't have time to learn another languages. Plus I like Rails. :-)

I would def. like a github project if you have time but if this helps clear up stuff and you have just a quick solution to this then it would be pointless for the github project.

Thanks again!

Hi Allen,

OK - so you've got a piece of equipment that needs checking; you want to assign an employee to that? The fact that the equipment is part of a vehicle is pretty irrelevant to that, I think.

So, you want to create a Job model. That holds one Employee, Equipment and Vehicle. When an Equipment is assigned to a Job, it has its status amended to whatever means it's been looked at. Does Equipment have a frequency property such that it can be put back in the queue after, say, a year when it needs checking again? If so, you need a last_checked property and a method that sets the status after a certain period of time.

Does that sound about right?

Steve.

Steve,

Thanks again but I think I didn't explain correctly.

An employee(empl_id) will check out and in a vehicle(veh_id) and an equipment like a tablet(tab_id) to do jobs daily.

I need a to keep track of which employee checked out/in what vehicle and what equipment on that certain day/time.

so here would be an example:

Current Status Page (Tablet Showing information)

ID - Empl_ID - Veh_ID - Tab_ID - Date/Time - Status

1 - 8076 - 123 - 1823 - March 6, 2016 - Checked Out

2 - 8077 - 312 - 1824 - March 6, 2016 - Checked Out

3 - 8076 - 123 - 1823 - March 7, 2016 - Checked In

4 - 8077 - 312 - 1824 - March 7, 2016 - Checked In

This obviously will vary based upon what/who checked out.

Now, I have in each table a column that says status(ie. tablet_status, employee_status, etc.)

But I guess I need another table that will put this "History"(Current Status Page) in.

I don't really know how to do that and I am not sure about the form what would pull the dropdown for employees/vehicles/equipment and submit and change all the status and place that information also into the "History" table.

Let me know if this clears up stuff.

Thanks again for the help!