我的评论控制器需要调整嵌套,但我遇到了一些错误。这是我一直在尝试的:
<% if @commentable == @user %>
<%= semantic_form_for [@commentable, @comment] do |f| %>
<% else %>
<%= semantic_form_for [@user, @commentable, @comment] do |f| %>
<% end %>
这给出了这个:
/Users/rbirnie/rails/GoodTeacher/app/views/comments/_form.html.erb:3: syntax error, unexpected keyword_else, expecting keyword_end'); else
知道为什么这不起作用吗?看起来很简单...
这是完整的视图:
<% if @commentable == @user %>
<%= semantic_form_for [@commentable, @comment] do |f| %>
<% else %>
<%= semantic_form_for [@user, @commentable, @comment] do |f| %>
<% end %>
<div class="control-group">
<%= f.label :subject %>
<div class="controls"><%= f.text_field :subject %></div>
</div>
<div class="control-group">
<%= f.label :body %>
<div class="controls"><%= f.text_area :body, rows: 8 %></div>
</div>
<div class="form-actions">
<%= f.submit "Submit", :class => "btn-success" %>
</div>
<% end %>