I am confused of when to add 'self.'. Does self.title call a function named 'title' or 'title' is simply a instance variable?
class Movie < ActiveRecord::Base
# reminder: database columns are id, title, rating, release_date
# method 1:
def title_with_year_1
"#{self.title} - #{self.release_date.year}"
end
# method 2:
def title_with_year_2
"#{title} - #{release_date.year}"
end
# method 3:
def title_with_year_3
"#{@title} - #{@release_date.year}"
end
end
And if I add attr_accessor :title, release_date
to it ,would the method 3 work as intended?