Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next occurence with recurring_select #336

Closed
vincentcordel opened this issue May 14, 2016 · 1 comment
Closed

Next occurence with recurring_select #336

vincentcordel opened this issue May 14, 2016 · 1 comment

Comments

@vincentcordel
Copy link

vincentcordel commented May 14, 2016

Hi there,

I'm storing a user schedule in the User model (field: study_frequency).

I don't know how to display the next occurence.

I tried (naively):
current_user.study_frequency.next_occurence(Time.now)

I also tried creating a IceCube object first:
schedule = IceCube::Schedule.new(now = Time.now) do |s|
s.add_recurrence_rule(current_user.study_frequency)
end
@user_schedule = schedule.next_occurrence(Time.now)

None of them worked. I'm sure I'm missing something obvious but can't figure out what.

Any advice?

Thanks!

Vincent

@avit
Copy link
Collaborator

avit commented Mar 21, 2017

Closing this since it's such a late reply... I hope you found your answer somehow!

It's hard to answer without knowing what type of value is study_frequency. I expect you want to create a rule something like this:

schedule = IceCube::Schedule.new do |s|
  s.add_recurrence_rule(IceCube::Rule.daily(current_user.study_frequency)
end
@user_schedule = schedule.next_occurrence

@avit avit closed this as completed Mar 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants