【发布时间】:2017-09-20 01:04:10
【问题描述】:
我想像往常一样在我的视图上使用这个控制器变量 但是
def new
@lease_type = LeaseType.new
@vehicle_types = VehicleType.all
user_id = current_user.id
@parking = Parking.where(owner: user_id).last
@lease_times = LeaseTime.all
end
所以我读到...并说我必须拥有这样的东西。但我认为最好使用我从控制器发送的内容,而不是从视图中访问模型。
但是
所以!???为什么不能访问使用呢?感谢您的帮助
更新:
创建方法
[![enter code here][8]][8]
【问题讨论】:
-
你能在 LeaseTypesController 上展示你的 create 方法吗?
-
那是创造,不是新的......
-
??!我们有 2 种方法,这 1 种新方法是您拥有表单的地方,并在您保存时创建... u.u 我知道我可以在保存时在控制器上获取一些此类属性,例如停车 ID,但需要其他集合...
标签: ruby-on-rails variables dictionary collections controller