ruby-on-rails - 带有 select_tag 的 Rails link_to
问题描述
我正在尝试从活动页面链接到带有嵌套票务表格的预订表格。我想添加一个 select_tag,以便用户可以在单击“预订票”并加载表单之前选择他们想要的票数,但我找不到将 select_tag 放入 link_to 块的方法。任何帮助将非常感激。我已经设置了控制器。
def create
@event = Event.find(params[:event_id])
@booking = @event.bookings.new(booking_params)
@number_of_tickets = params[:nog].to_i
@booking.user_id = current_user.id
@number_of_tickets.times { @booking.tickets.build }
并在我看来尝试过
<%= select_tag(:nog, options_for_select(1..10, selected: params[:nog]), { prompt: 'Number of Tickets' }) %>
<% end %>```
I just get a stringyfy keys error.
the model is set up correctly and all works when I select how many tickets in the controller and the form manually but I need the user to be able to choose how many tickets they want.
TIA
解决方案
推荐阅读
- pyinstaller - 是否有等效于使用 PyObjC 的“os.listdir()”方法?
- google-chrome - 如何从弹出窗口访问当前选项卡的 LocalStorage 和 Cookie
- android - Bitbucket Container 'Build' 超出内存限制 - 使用 android build 时
- kotlin - 如何测试返回 com.google.type.Money 的 gRPC 端点
- android - 我无法读取我的 FirebaseDatabase。它显示警告为:W/System: Ignoring header X-Firebase-Locale because its value is null
- python - 将具有不同形状的numpy数组列表转换为灰度值
- javascript - 我的三元代码不起作用 Javascript
- python - 如何将 python 列表中的每个元素与另一个列表中的元素相乘?
- php - 使用 PHP 填写 PDF 表单
- python - 如何使用包含来自两个列表的多个值的键创建一个字典?