ruby-on-rails - 不确定要添加到我的路线以获取 icalendar gem 链接
问题描述
我的索引页面显示
<%= link_to 'Subscribe', icalendar_url(protocol: :webcal, format: :ics) %>
在我的控制器上,我添加了
respond_to do |format|
format.html
format.ics do
cal = Icalendar::Calendar.new
cal.x_wr_calname = 'Awesome Rails Calendar'
cal.event do |e|
e.scheduled_date = @clients.scheduled_date
e.summary = '@clients.work_needed'
e.description = '@clients.comments'
end
cal.publish
render plain: cal.to_ical
end
结尾
并没有在我的 client.rb 中添加任何内容
我该怎么办我得到错误
undefined method `icalendar_url' for #<#<Class:0x007fbb1a4b92b8>:0x007fbb32fc8560>
解决方案
我的错误是我试图解决路由中的问题,链接中的路由错误与路由无关
我有一个链接设置为
<%= link_to "CSV", calendar_path(format: "csv"), :class => 'glyphicon glyphicon-file' %>
中间的 calendar_path 不是我的控制器,我的控制器是 clients_path
一个简单的改变
<%= link_to "CSV", clients_path(format: "csv"), :class => 'glyphicon glyphicon-file' %>
有用 !
推荐阅读
- jquery - 使用 jQuery 向元素添加类
- xaml - Xamarin 在一行的每一端有两个标签
- python - Pygame 随机坐标生成
- wordpress - 移动版中未配置的间距元素
- javascript - 在 Google 表单中嵌入颜色选择器?
- python - R / Python置信区间
- javascript - Jmeter Chromedriver 错误:未知错误:从远程主机执行时,DevToolsActivePort 文件不存在
- php - 使用 Mysql 结果作为值
- laravel - 什么是 .phpunit.result.cache
- mysql - MySQL 通过中间表加入