我對Rails很新,所以請耐心等待。用戶可以有很多導師,導師所屬的用戶從其他表訪問屬性
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:confirmable, :omniauthable
validates :firstname, :lastname, presence: true
has_many :mentors
class Mentor < ApplicationRecord
belongs_to :user
has_many :photos
我需要的導師顯示頁面中使用的用戶名。有人能告訴我該怎麼辦?正如我之前所說的,我對Rails很陌生。所以如果有人能告訴我我需要做的分步改變,那會非常有幫助。
https://apidock.com/rails/Module/delegate –