S
S
Stopy2016-07-22 21:10:54
Ruby on Rails
Stopy, 2016-07-22 21:10:54

Ruby, what are you?

class Client < ApplicationRecord
  has_one :address
  has_many :orders
  has_and_belongs_to_many :roles
end

What are has_one and so on in this class? I'm trying Ruby for the first time and it's not entirely clear what they are, sort of like methods, but why do I use methods in a class and don't define them? Will they be inherited? And how to get access to them from an inherited class?
Sorry for stupid question :3

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene Burmakin, 2016-07-22
@Freika

In the above code, you are using 99% Rails, not Ruby.
apidock.com/rails/v4.2.1/ActiveRecord/Associations...
apidock.com/rails/v4.2.1/ActiveRecord/Associations...
apidock.com/rails/v4.2.1/ActiveRecord/Associations...
Question tagged as "the answer is easily found by a search engine"

A
Andrey Andreev, 2016-07-22
@b0nn1e

This is the magic of rails.
Smoke rusrails.ru or guides.rubyonrails.org from the very beginning.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question