我有USERSwhich haveLISTINGS和 a SHOP。
我刚刚创建了Shop Controller并且在我def show action把事情搞砸了。
当用户创建商店时,它会将 a 传递user_id给商店,因此每个商店都属于一个用户。
class AddUserIdToShops < ActiveRecord::Migration
def change
add_column :shops, :user_id, :integer
add_index :shops, :user_id
end
end
但是在显示页面上我不能调用@user.name 例如因为rails 不知道我的意思是什么用户。
如何正确设置我的显示操作以便我可以调用 @user ?
谢谢