I've been living in USA for 1 year. I think transportation system in Pittsurgh is pretty good. However, Yesterday, I had very bad experience with the bus system. In the morning, the bus didn't stop at the bus stop because the driver thought I would like to go another way. How did he know where I want to go?!?!?!?! Then, in the afternoon, a bus came about 10 minutes early! and I missed it. I checked the schedule and I have to wait 15 minutes more, ok I can wait, but it came 10 minutes late......UNRELIAB LE!
I really want to eat thai noodle but I can't find the restaurant that make a good one. So I made it myself :D.
This week, I trained users how to use the application I've developed. I can feel that they like it. However, they want me to add more functions and want to change report format.
I've talked to my supervisor, she told me that this application will reduce time that managers have to spend on this task. Also, the old system, they can work on it only one person at a time. That means other managers have to wait until a manager who is using it finish the task.
Nest week, I will train content creators to make webpages with CSS because the old web pages they have don't use CSS and when they want to change their web theme they have to change every single page. So, I suggest that they should use CSS and my supervisor agree with me. :D
I'm glad to see that the application I developed can save manager's time and make things better.
I'm working on my new project and it has many-to-many association. Also, I want to store additional fields in the relation. So, I used has_many :through in my models.
Example:
GIVEN: I have 2 models which are driver and bus. Driver can drive more than one bus and has start time and stop time for each bus. Also, bus can be drived by many drivers. ( Driver will drive particular bus only one period)
I will generate one more model called " Shift " which has bus_id, driver_id, start_time and stop_time.
Model:
class Shift < ActiveRecord::Base belongs_to :bus belongs_to :driver end class Driver < ActiveRecord::Base has_many :shifts has_many :buses, :through => :shifts end class Bus < ActiveRecord::Base has_many :shifts has_many :drivers, :through => :shifts end
Then, how to access start and stop time?
We treat Shiftas one model, so we can use s = Shift.find_by_bus_id_and_driver_id(busID,driverID)
to get the shift and s.start_time or s.stop_time to access the additional fields.