我有一个属于用户的激活模型。我试图显示用户在视图中提交的激活信息,但我不知道如何执行此操作。例如,从两个Rails模型检索数据
class Activation < ApplicationRecord
belongs_to :user
default_scope -> { order(created_at: :desc) }
validates :user_id, presence: true
validates :dealer_store, presence: true, length: { maximum: 50 }
validates :customer_name, presence: true, length: { maximum: 50 }
validates :customer_phone_number, presence: false, length: { maximum: 10 }
class User < ApplicationRecord
has_many :activations
validates :name, presence: true, length: { maximum: 50 }
我能够从与用户ID激活的用户获取数据,像这样
<%= activation.user.dealer_store %>
我将如何获得用户的激活CUSTOMER_PHONE_NUMBER?我似乎失去了一些东西
因为用户有许多激活你需要首先确定你想要的激活号码你可能在这里找到它https://bitbucket.org/QuriouslyStrong/sample_app
'activation.user.dealer_store' - 这是不行的。 –