用的是 ubuntu15.x.x rails 是 4.23 问题是 undefined method `chat' for #Chat:0x007fe686475850 Extracted source (around line #29):
def create
@chat = Chat.create(chat_params)
if @chat.save
redirect_to chats_path
else
#下面是控制器的
def create
@chat = Chat.create(chat_params)
if @chat.save
redirect_to chats_path
else
flash.now[:warning] = "error"
render 'new'
end
end
#这是视图
<div class:"col-md-4 col-md-offset-4">
<h1>new add comment panel</h1>
<hr>
<%= simple_form_for @chat do |f|%>
<div class="form-chat">
<%= f.input :title, input_html:{ class:"form-control"}%>
<%= f.input :desc, input_html:{ class:"form-control"}%>
</div>
<%= f.submit "submit", data:{disable_with: 'Submitting---'}, class:"btn btn-primary"%>
<%end%>
</div>
明明之前好好的,什么都没改,莫名其妙错了,求大家帮助呢!...