Jquery FullCalendar- Change event color according to even_type in ruby app

倖福魔咒の 提交于 2019-12-07 01:41:29

Are you going to use these colors somewhere else outside of your model?

Most likely, you need not to make it globally available, so just add a constant to the model:

scope :before, ...
scope :after, ...

EVENT_COLORS = { "School" => "#ff0000", "Holidays" => "#00ff00", ... }
EVENT_COLORS.default = "#0000ff" #optional step, set default color for events

...
:url => Rails.application.routes.url_helpers.event_path(id),
:color => EVENT_COLORS[self.event_type]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!