Rails Fullcalendar set certain events editable -
i'm using fullcalendar in rails. following code event model creates json fullcalendar events.
i want event editable: true if event.maxsynch = "n"
this code:
def as_json(options = {}) { :id => self.id, :title => "#{self.workorder.wonum} #{self.title} #{self.hours}", :description => self.description || "", :start => starts_at.rfc822, :end => ends_at.rfc822, :allday => self.all_day, :recurring => false, :editable => false if self.maxsynch == "n" :true, :url => rails.application.routes.url_helpers.event_path(id), :color => "blue", :backgroundcolor => "blue", :bordercolor => "black", :textcolor => "white" } end
the line :editable => false if self.maxsynch == "n" :true, wrong.
how can fix it?
thanks help!!
if understand question correctly, trying use called conditional or ternary operator. "if condition true a, otherwise, b."
you can read more here: http://en.wikipedia.org/wiki/%3f:#ruby
so line should read like
:editable => (self.maxsynch == "n" ? true : false),
but, if doing returning true or false, shouldn't have use conditional operator @ all. should have pass evaluated expression.
:editable => (self.maxsynch == "n"),
it return true, if statement true, otherwise return false. if need have opposite behavior, add ! beginning of statement , reverse logic.
Comments
Post a Comment