This is an intermediate to advanced change. I'd recommend taking a look at good first issues first if you're not too comfortable with Rails yet.
Problem statement
Our events do not specify a location at the moment. That's obviously a big problem for an event management app.
Solution
We should implement locations as a separate model. That will allow us to share the same location record among different events. For example, let's say the event RailsConf is happening at Oregon Convention Center. When we create that event, we will also create a location record for the Oregon Convention Center.
Then, a month later, Comic-Con schedules an event at the Oregon Convention Center. This time, we should use the existing location record.
This is powerful because it gives us the ability to find all events happening at a given location. We wouldn't have that power if we implemented location as just a string column in the events table.
Implementation details
- Location should have its own model backed by a database table.
- Location should
belong_to events and an event should have_one location.
- See video 14 - Creating a Registration Model (add link) for a refresher on setting up these relationships.
- The location should have a name column, but I will leave it up to you on how you'd like to implement the address storage. I'd recommend doing some research and explaining the reasoning behind your recommendation.
I'd be happy to review your implementation when I have time. Please open a pull request following these steps:
- Follow this guide to setup your forked repo
- Checkout a development branch
- Implement your changes
- Open a pull request and tag me for review
This is an intermediate to advanced change. I'd recommend taking a look at good first issues first if you're not too comfortable with Rails yet.
Problem statement
Our events do not specify a location at the moment. That's obviously a big problem for an event management app.
Solution
We should implement locations as a separate model. That will allow us to share the same location record among different events. For example, let's say the event RailsConf is happening at Oregon Convention Center. When we create that event, we will also create a location record for the Oregon Convention Center.
Then, a month later, Comic-Con schedules an event at the Oregon Convention Center. This time, we should use the existing location record.
This is powerful because it gives us the ability to find all events happening at a given location. We wouldn't have that power if we implemented location as just a string column in the events table.
Implementation details
belong_toevents and an event shouldhave_onelocation.I'd be happy to review your implementation when I have time. Please open a pull request following these steps: