Rails错误:语法错误,意外',',expecting =>

时间:2016-12-17 20:31:06

标签: ruby ruby-on-rails-5

我的rails应用程序出现此错误:

$user->country->name;

我的模特中抱怨的是:

syntax error, unexpected ',', expecting =>

似乎是validates :body, presence: true, length: {minimum: 2, maximum: 1000}, :chat_room_id, :user_id :chat_room_id

之间的逗号

有什么想法吗?谢谢!

2 个答案:

答案 0 :(得分:3)

您无法编写验证条件,之后需要验证:

如果你想要这样的东西:

validates :body, presence: true, length: {minimum: 2, maximum: 1000}
validates :chat_room_id, :user_id, presence: true

或另一种选择:

validates :body, :chat_room_id, :user_id, presence: true
validates :body, length: {minimum: 2, maximum: 1000}

答案 1 :(得分:0)

我的参数列表: {:utf8,:authenticity_token,:worklog => {:typee,:do,:todo,:feel,:plan_done,:plan,:week_feel,:score,:good,:nogood},:commit}

添加thoes参数后,在数据库中获取空值