recurring_select icon indicating copy to clipboard operation
recurring_select copied to clipboard

allow_blank doesn't work.

Open brentonannan opened this issue 11 years ago • 3 comments

When I use the :allow_blank => true option, I end up with an 'allow_blank' option in the dropdown. If I then save the model, the rule gets serialized to the string 'true'.

brentonannan avatar May 03 '13 02:05 brentonannan

same here

pungoyal avatar May 07 '13 12:05 pungoyal

When I opensourced this, I didn't notice that the locations we use blank actually have a setter method on the model to handle this scenario.

class RecurringModel
  attribute_accessible :recurring_rule
  serialize :recurring_rule, Hash

  ....

  def recurring_rule=(new_rule)
    if RecurringSelect.is_valid_rule?(new_rule)
      write_attribute(:recurring_rule, RecurringSelect.dirty_hash_to_rule(new_rule).to_hash)
    else
      write_attribute(:recurring_rule, nil)
    end
  end
end

I'll need to write a :accepts_recurring module which can be mixed into ActiveRecord for making accepting these parameters easier.

forrest avatar May 07 '13 14:05 forrest

Sorry mate, missed the notification for your reply. If I can find some time, I'll try help resolve this. Cheers.

brentonannan avatar May 16 '13 01:05 brentonannan