如何修复此语法错误?

Jus*_*zer 2 ruby debugging ruby-on-rails syntax-error ruby-on-rails-3

加载视频节目视图时出现此错误:

SyntaxError in Videos#show

Showing /rubyprograms/dreamstill/app/views/comments/new.html.erb where line #1 raised:

compile error
/rubyprograms/dreamstill/app/views/comments/new.html.erb:1: syntax error, unexpected tASSOC, expecting kEND
...deo.comments.new]), :remote => true do |f| @output_buffer.sa...
                          ^
/rubyprograms/dreamstill/app/views/comments/new.html.erb:6: syntax error, unexpected kENSURE, expecting $end
Run Code Online (Sandbox Code Playgroud)

它在我的comments/new.html.erb文件中指向此表单:

<%= simple_form_for([@video, @video.comments.new]), :remote => true do |f| %>
  <%= f.association :comment_title, :collection => @video.comment_titles, :label => "Comment Title:", :include_blank => false %>
  <%= f.input :body, :label => false, :placeholder => "Post a comment." %>
  <%= f.button :submit, :value => "Post" %>
<% end %>
Run Code Online (Sandbox Code Playgroud)

用这一行加载到我的视频节目视图中:

<%= render :file => 'comments/new' %>
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个错误?

Mik*_*wis 8

你要:

<%= simple_form_for([@video, @video.comments.new], :remote => true) do |f| %>
Run Code Online (Sandbox Code Playgroud)

基本上:remote => true应该是simple_form_for的参数.


Zab*_*bba 5

尝试:

<%= simple_form_for [@video, @video.comments.new], :remote => true do |f| %>
Run Code Online (Sandbox Code Playgroud)