When I do this:
我这样做的时候:
current_user.predictions.inspect
I get this:
我明白了:
#<Prediction id: 1, home_prediction: 1, away_prediction: 2, first_goalscorer: "Baaaa", double: nil, user_id: 1, match_id: 1, created_at: "2013-12-04 22:48:23", updated_at: "2013-12-04 22:48:23">
But when I do this:
但是当我这样做时:
current_user.predictions.match_id
I get this error:
我收到此错误:
undefined method `match_id'
How do I access the match_id of a user's prediction and ensure that they have not already made a prediction?
如何访问用户预测的match_id并确保他们尚未进行预测?
Thanks!
谢谢!
1 个解决方案
#1
0
Something seems off there
那里似乎有些东西
current_user.predictions is plural so it sounds like a collection
current_user.predictions是复数,所以它听起来像一个集合
so try:
所以尝试:
current_user.predictions.first.match_id
#1
0
Something seems off there
那里似乎有些东西
current_user.predictions is plural so it sounds like a collection
current_user.predictions是复数,所以它听起来像一个集合
so try:
所以尝试:
current_user.predictions.first.match_id