尝试在表单中包含条件逻辑。如果用户选择某种类型,则会显示与该类型相关联的信息。我怎样才能在表单中实现这一点?
<%= simple_form_for @post do |f| %>
<%= f.input :title %>
<%= f.input :image %>
<%= f.input :description %>
<%= f.input :link %>
<%= f.collection_select :typeof, Post::TYPEOFS, :to_s, :humanize %>
<% if @post.typeof.include?('audio') %>
<p>Audio Selected</p>
<% else %>
<p>Something else selected</p>
<% end %>
<%= f.input :typeof %>
<%= f.input :approve %>
<%= f.button :submit, "Submit", class: "button" %>
<% end %>