2011-09-19 60 views
0

我正在使用帶軌道2.3.8的event_calendar插件。我有名稱,場地和教練列的事件表。我想要根據教練和場地進行顏色比賽。我可以通過培訓師給它着色。但是現在我想將參數傳遞給活動日曆助手,考慮它是否是培訓師或場地。我應該如何傳遞這個參數?任何人使用這個插件? plz幫助我....如何將參數傳遞給事件日曆助手?

回答

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) %> 
helper方法

應用程序/傭工/ 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 
+0

我可以傳遞參數給供應商\插件\ event_calendar \ LIB \ event_calendar \日曆助手如上?我試圖通過它。但是有錯誤。 – Rosh

+0

@Rosh:是的,您可以使用上述方法將參數傳遞給您的插件的幫助器方法。在我的例子中,你可以像下面的'options [:display_properties]'一樣在插件的幫助器中獲取參數。一個重要的,也就是每當你改變你的插件重新啓動我們的服務器。 – Salil

相關問題