ASSOCIATIONS I

Models I

Great! Looking at the request/response cycle, we need four parts to build the travel app: models, controllers, routes, and views.

Let’s begin by creating the models.


1.

Generate a model named Tag.

2.

Generate another model named Destination.

3.

In app/models/tag.rb add a has_many method, like this:

class Tag < ActiveRecord::Base has_many :destinations end
4.

In app/models/destination.rb, add a belongs_to method:



belongs_to :tag

Comments

Popular posts from this blog

Rails 7 Features :: Comparison with Rails 6 and Rails 5