首页 > 解决方案 > 带有 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

标签: ruby-on-railssimple-formlink-to

解决方案


推荐阅读