Turning a calendar into a form using Rails?

江枫思渺然 提交于 2019-12-06 11:04:38

Since you have the date available in the block of the day method, you should be able to pass it on to the partial like so:

<% calendar.day(:day_method => :workoutdate) do |date, workouts| %>
  <%= date.day %>
  <%= render 'form', :date => date %>
<% end %>

Then you can make use of it within the form partial and set the date of the date select via the local variable you have just passed in:

<%= f.date_select :workoutdate, :default => date %>

As a note: this method seems a bit funny, since you're rendering this form always for a particular day anyways. Why not send the date e.g. via a hidden input field? Is the user supposed to change the date? And if so, doesn't that break the UI logic?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!