カレンダーの日付にリンクを付けたい

実現したいこと

ここに実現したいことを箇条書きで書いてください。

前提

カレンダーの日付にリンクを付けたいですがうまくいきません。chat gptなどを使って調べましたが駄目でした。
_month_calendar.html.erbの<body>内で日付がリンクになる記述をすればいいのかなと考えていましたが、うまくいきませんでした。

発生している問題・エラーメッセージ

<% capture_haml(day, sorted_events.fetch(day, []), &passed_block) do %>
<%= link_to day.day, seminars_path(day.id) %>
<% end %>
とすると、syntaxエラーが起きる

エラーメッセージ ActionView::SyntaxErrorInTemplate in SeminarsController#index

該当のソースコード

(simple_calendarフォルダ、_month_calendar.html.erb内のコード)

<div class="simple-calendar"> <div class="calendar-heading"> <%= link_to t('simple_calendar.previous', default: 'Previous'), calendar.url_for_previous_view %> <span class="calendar-title"><%= start_date.year %>年 <%= t('date.month_names')[start_date.month] %></span> <%= link_to t('simple_calendar.next', default: 'Next'), calendar.url_for_next_view %> </div> <table class="table table-striped"> <thead> <tr> <% date_range.slice(0, 7).each do |day| %> <th><%= t('date.abbr_day_names')[day.wday] %></th> <% end %> </tr> </thead> <tbody> <% date_range.each_slice(7) do |week| %> <tr> <% week.each do |day| %> <%= content_tag :td, class: calendar.td_classes_for(day) do %> <% if defined?(Haml) && respond_to?(:block_is_haml?) && block_is_haml?(passed_block) %> <% capture_haml(day, sorted_events.fetch(day, []), &passed_block) %> <% else %> <% passed_block.call day, sorted_events.fetch(day, []) %> <% end %> <% end %> <% end %> </tr> <% end %> </tbody> </table> </div>

試したこと

内のコードを以下のように記述した。
<% capture_haml(day, sorted_events.fetch(day, []), &passed_block) do %> <%= link_to day.day, seminars_path(day.id) %> <% end %>

補足情報(FW/ツールのバージョンなど)

ここにより詳細な情報を記載してください。

コメントを投稿

0 コメント