使用“weekly_builder”在我的日历中出现错误插件

发布于 2024-11-16 15:16:40 字数 1651 浏览 0 评论 0原文

我建立了一个每周日历“weekly_builder”( https://github.com/dmix/weekly_builder/ )我在 http://dmix.ca/2009/06/weeklybuilder-a-weekly-calendar-plugin-for-rails/ 。 当我进入日历路线时,我收到此错误:

undefined method `starts_at' for #<Status:0x866c100>
Extracted source (around line #4):

1: 
2: <% weekly_links(:date => @date) %>
3: <% weekly_calendar(@events, :date => @date, :include_24_hours => true) do |w| %>
4: <% w.week(:business_hours => params[:business_hours], :clickable_hours => true) do |event,truncate| %>
5: <%= event.date.strftime('%I:%M%p') %>
6: <%= link_to truncate(event.name,truncate), event_path(event) %>
7: <% end %>

这是我的日历控制器:

def weekcalendar
    @date = Time.parse("#{params[:start_date]} || #{Time.now.utc}")
    @start_date = Date.new(@date.year, @date.month, @date.day) 
    @events = Status.find(:all, :conditions => ['date between ? and ?', @start_date,  
    @start_date + 7]) 
end

这是我的日历视图:

<% weekly_links(:date => @date) %>
<% weekly_calendar(@events, :date => @date, :include_24_hours => true) do |w| %>
<% w.week(:business_hours => params[:business_hours], :clickable_hours => true) do |event,truncate| %>
<%= event.date.strftime('%I:%M%p') %>
<%= link_to truncate(event.name,truncate), event_path(event) %>
<% end %>
<% end %>

请让我知道出了什么问题。 非常感谢。

i builed a weekly calendar "weekly_builder" ( https://github.com/dmix/weekly_builder/ ) that i found in http://dmix.ca/2009/06/weeklybuilder-a-weekly-calendar-plugin-for-rails/ .
when i go into the calendar route i get this error:

undefined method `starts_at' for #<Status:0x866c100>
Extracted source (around line #4):

1: 
2: <% weekly_links(:date => @date) %>
3: <% weekly_calendar(@events, :date => @date, :include_24_hours => true) do |w| %>
4: <% w.week(:business_hours => params[:business_hours], :clickable_hours => true) do |event,truncate| %>
5: <%= event.date.strftime('%I:%M%p') %>
6: <%= link_to truncate(event.name,truncate), event_path(event) %>
7: <% end %>

this is my calendar controller:

def weekcalendar
    @date = Time.parse("#{params[:start_date]} || #{Time.now.utc}")
    @start_date = Date.new(@date.year, @date.month, @date.day) 
    @events = Status.find(:all, :conditions => ['date between ? and ?', @start_date,  
    @start_date + 7]) 
end

and this is my calendar view:

<% weekly_links(:date => @date) %>
<% weekly_calendar(@events, :date => @date, :include_24_hours => true) do |w| %>
<% w.week(:business_hours => params[:business_hours], :clickable_hours => true) do |event,truncate| %>
<%= event.date.strftime('%I:%M%p') %>
<%= link_to truncate(event.name,truncate), event_path(event) %>
<% end %>
<% end %>

please let me know what is wrong.
thank you very much.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

与往事干杯 2024-11-23 15:16:40

确保您为 Status 模型定义了 starts_at 属性。

根据您收到的错误,没有定义 starts_at 。将您使用的任何属性的名称更改为 starts_at,或者在 Status 模型中定义一个别名方法。

alias :starts_at :whatever_field_name

或者

def starts_at
  whatever_field_name
end

或者查看您使用的插件是否有一些配置参数来指定不同的字段。

Make sure you have a starts_at attribute defined for your Status model.

According to the error you are getting, there is not starts_at defined. Either change the name of whatever attribute you are using to starts_at, or in your Status model, define an alias method.

alias :starts_at :whatever_field_name

or

def starts_at
  whatever_field_name
end

Or see if there is some configuration parameter with the plugin you are using to specify a different field.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文