新手问题 如何调用 belongs_to 的 model 方法???急谢谢

ckl · March 25, 2014 · Last by zj0713001 replied at March 25, 2014 · 1834 hits

User model has_many :works def find puts “hello world” end

Work model belongs_to :user

Work model 的对象 test 如何调用 User model 中的方法???

我在代码中试了 test.user.find 不可以

@miclle 不好意思 方法举例错误!方法改为 bar

@miclle 谢谢了 我找到了!

test.user.class.find

You need to Sign in before reply, if you don't have an account, please Sign up first.