在views/articles/index.html.erb中:
<%= search_form_for @q do |f| %>
<%= f.label :title %>
<%= f.search_field :title_or_body_cont_any %>
<%= f.submit %>
<% end %>
我尝试添加 class="btn btn-primary" 来提交:
<%= f.submit,class="btn btn-primary" %>
但我收到错误。如何将 Bootstrap 类加入到 form_for 字段?
全视图:
<div class="container">
<%= search_form_for @q do |f| %>
<%= f.search_field :title_or_body_cont_any %>
<%= f.submit %>
<% end %>
<br/>
<% @articles.each do |article|%>
<div class="border border-success p-2 border-opacity-25 rounded">
<p>
<%= link_to article.title, article_path(article), style: 'color:#d63e2d; font-size: 30px; ' %>
</p>
<p>
<%= markdown article.body%>
</p>
</div>
<br/>
<%end%>
</div>
完整错误跟踪______________________________________:
app/views/articles/index.html.erb:4: syntax error, unexpected ')', expecting '.' or &. or :: or '['
app/views/articles/index.html.erb:5: syntax error, unexpected `end', expecting ')'
app/views/articles/index.html.erb:23: syntax error, unexpected `end', expecting ')'
app/views/articles/index.html.erb:4: syntax error, unexpected ')', expecting '.' or &. or :: or '['
app/views/articles/index.html.erb:5: syntax error, unexpected `end', expecting ')'
app/views/articles/index.html.erb:23: syntax error, unexpected `end', expecting ')'
app/views/articles/index.html.erb:4: syntax error, unexpected ')', expecting '.' or &. or :: or '['
app/views/articles/index.html.erb:5: syntax error, unexpected `end', expecting ')'
app/views/articles/index.html.erb:23: syntax error, unexpected `end', expecting ')'
app/views/articles/index.html.erb:4: syntax error, unexpected ')', expecting '.' or &. or :: or '['
app/views/articles/index.html.erb:5: syntax error, unexpected `end', expecting ')'
app/views/articles/index.html.erb:23: syntax error, unexpected `end', expecting ')'
app/views/articles/index.html.erb:4: syntax error, unexpected ')', expecting '.' or &. or :: or '['
app/views/articles/index.html.erb:5: syntax error, unexpected `end', expecting ')'
app/views/articles/index.html.erb:23: syntax error, unexpected `end', expecting ')'
app/views/articles/index.html.erb:4: syntax error, unexpected ')', expecting '.' or &. or :: or '['
app/views/articles/index.html.erb:5: syntax error, unexpected `end', expecting ')'
app/views/articles/index.html.erb:23: syntax error, unexpected `end', expecting ')'