我正在使用带有rails 2.3.8的event_calendar插件。我有活动表,名称,地点和培训师专栏。我想根据培训师和场地为活动着色。我可以通过培训师给它上色。但现在我想将参数传递给事件日历助手,考虑它是教练还是场地。我应该如何传递这个参数?有人使用这个插件吗?请帮助我......
答案 0 :(得分:1)
如果你看一下README.rdoc,你就会得到
<%= event_calendar %>
==Default Options
The default options for the calendar are:
defaults = {
:year => Time.zone.now.year,
:month => Time.zone.now.month,
:abbrev => true,
:first_day_of_week => 0, # See note below when setting this
:show_today => true,
:month_name_text => Time.zone.now.strftime("%B %Y"),
:previous_month_text => nil,
:next_month_text => nil,
:event_strips => [],
# it would be nice to have these in the CSS file
# but they are needed to perform height calculations
:width => nil,
:height => 500,
:day_names_height => 18,
:day_nums_height => 18,
:event_height => 18,
:event_margin => 1,
:event_padding_top => 1,
:use_all_day => false,
:use_javascript => true,
:link_to_day_action => false
}
我在日历中使用了以下两个参数,并在
中覆盖了插件助手方法<%= event_calendar(user.format, outbound) %>
应用程序/助手/ calendar_helper.rb
def event_calendar_opts(display_format, outbound)
{
:year => @year,
:month => @month,
:abbrev => nil,
:event_strips => @event_strips,
:display_properties => (display_format==4)? 4 : 3,
:outbound => outbound,
:month_name_text => I18n.localize(@shown_month, :format => "%B %Y"),
:previous_month_text => month_link(@shown_month.last_month),
:next_month_text => next_month_link(@shown_month.next_month) }
end
def event_calendar(display_format, outbound)
# args is an argument hash containing :event, :day, and :options
index = 0
calendar event_calendar_opts(display_format, outbound) do |args|
html << some_html
html
end
end