Ask A Question

Notifications

You’re not receiving notifications from this thread.

Recurring events with the ice_cube gem Discussion

On my app I use a Event and a EventTrans model so for each time a event occurs we can have a record with info and other stuff. So for the Calendar we display the First event with the recurrent on the fly and each time the event pass we save it as a record or if we need to move only on recurrent we create it as a event transaction.

My only problem is the time it takes to check if a recurrent is create as event_trans or not for calendar view.

Reply

For some reason the simple_calendar gem messed with a bunch of the CSS on my site (e.g. all my links now have a black background on hover, etc.). Any hints on how to avoid this?

Reply

simple_calendar doesn't include any CSS for the links, so it must come from somewhere else. It only has some optional CSS for styling the calendar, but not links.

Sounds like you may have created a scaffold and the scaffold.css file is styling your links.

Reply

Thanks for a good demo for IceCube! I've been looking for this functionality to use it in one of my pet projects, but ended up with implementing something like this using cron format to represent recurrent event rules, and parse-cron gem to parse it. But now I'll try to switch to IceCube. I like the hash format it uses. It look less cryptic than crontab. Thanks for a good tip :)

Reply
Jorg Dominguez Jorg Dominguez

Waiting for the next episode!!!
You are great!

Reply

Really enjoying this series. Curious to when the next episode will be for exceptions etc?

Reply

Hey Josh, looks like I forgot to put the video in the series. You can find the episode here: https://gorails.com/episode...

Reply

Hi, thanks for the tutorial I found it very helpful. I wondered if you had any thoughts on the best way to query recurring events that have been serialised using the recurring gem? The issue I'm running into is if an individual who has not created the original calendar events wanted to search several calendars (created by other users) for free slots at given times the serialiser method then seems to become more complex than if we'd created individual discrete events. For example if you wanted to share calendars between different users. Would be interested to know your thoughts on this. Thanks

Reply

Depends on what you're trying to accomplish (like everything right? lol). What kind of search are you trying to pull off?

Reply
Shawn Nigel Rebello Shawn Nigel Rebello

Thanks a lot for this !

Reply
Has anyone gotten recurring_select to work on rails 5.2?? I keep getting a wrong number of attributes error no matter what I try to pass it.
Reply
Seems like it only occurs on Rails 5.2.rc2.. I'm not sure why though.
Reply
Looks like there was a change in the value method of the FormBuilder Base class. I changed it to not pass de object around anymore on a fork, but this would make the gem not work with previous versions... anyways, I'll leave the link here in case anyone is in need of a quick fix. https://github.com/gafemoyano/recurring_select
Reply
Good work! Looks like this probably changed somewhat recently then. The gem sure hasn't been updated for quite a while so it's surprising other things haven't broken!
Reply

Hello Chris, thank you so much for putting this leson together.
I followed it step by step and everything worked fine, that is until something got mistrerously broken and now I cannot seem to know what it is or how to put it back together.

Coould you please take a look to the issue I posted on github and let me know your thoughts?

https://github.com/GetJobber/recurring_select/issues/123

Best

OO

Reply

Thanks Chris, very helpful as always :-)

As RecurringSelect.is_valid_rule?('null') is true, I had to change the recurring=(value) method.

Reply

We did you change? I am getting the error "undefined method `to_hash' for nil:NilClass" And I was wondering if that could be the issue.

Reply

@Jeff:

Make sure you don't have old event data stored in the event table as you move through the excercise. Also, as Chris Seelus pointed out, latest recurring select does parse string null and makes it a valid rule.

Maybe put a guard to call super(nil) like so?

def recurring=(value)
    if value != "null" && RecurringSelect.is_valid_rule?(value)
      super(RecurringSelect.dirty_hash_to_rule(value).to_hash)
    else
      super(nil)
    end
end
Reply

Cool. Thanks for the tips!

Reply

Hi Chris!

Thank you for the episode. It was very educational. 8-) Ross Kaffenberger (@rossta) has a neat gem called Montrose (https://rossta.net/montrose/) similar to/inspired by ice_cube which models recurrence quite nicely as well.

I am stuck in the ice_cube world though trying to solve the following problem: My event model needs to be searchable/order-able. Since I did not want to reinvent the wheel, I ended up with datatables implementation. I created a nice JSON endpoint which produces events. I was cruising along with implementation, until I got to the actual search part. The JSON endpoint returns data which is ordered/searched via chained AR calls, something like:

def fetch_events
  search_string = []
  %w[name description city country state zipcode].each do |term|
    search_string << "#{ term } ILIKE :search"
  end

  events = Event.active.order("#{sort_column} #{sort_direction}")
  events = event.page(page).per(per_page)
  events = events.where(search_string.join(' OR '), search: "%#{params[:search][:value]}%")
end

Soooo, it seems that if I want to include recurring events in the JSON endpoint, I should inject Event#calendar_events in the code above. One could, do that at the end, however, that wouldn't jive with sorting part. Not sure if one can try to do it early in the chain, becase, well, AR.

Would you, or anybody elase, have a clever idea how to handle that?

Thank you,

Pawel

Reply

I am using ice-cube gem for recurring.
Condition:
I have a form which allows user to select datetime for recurring.
Now I want to schedule and run a background job based on user frequncy.
Like if the frequncy is daily hten that job should run daily. How can I achieve this using ice-cube gem.

Reply

Any suggestions on how to handle searching the database for overlapping events when creating a new event?

With all the recurring info in the serialized column it seems there is no way to leave the heavy lifting to the database, and instead we need to iterate all events, find their recurring time slots, and compare. Is there any other solution?

Reply

Yeah, there's not a real easy way when the schedules are dynamically generated.

Reply

I've installed the gem exactly as the video says, however <%= form.select_recurring :recurring, nil, allow_blank: true %> throws an error "wrong number of arguments (given 1, expected 0)"

It's as if the gem hasn't installed and can't find the form helper.
Does anyone know where to go from here?

I'm using:
rails 6.0.1

And installing the gem like so:
gem 'recurring_select', github: "RundownApp/recurring_select"

I've also run bundle with no issues.

Reply

Out of curiosity, I created a new rails app exactly as Chris has here and I am getting the same error :(

Any help would be greatly appreciated :) Cheers guys

Reply

As was mentioned in the video, github: "RundownApp/recurring_select" was a fork for rails5. If you're having issues, try https://github.com/GetJobber/recurring_select which has been updated for rails 6

Reply

Hi Chris. This episode was exactly what I was looking for, thank you.
I've followed a few of your tutorials now and find them great.

I have been trying to figure out a way of marking individual instances of a recurring task as complete.
Has anyone tried/succeeded with this?

Reply

Thank you for sharing this video! I am having a really tough time with my application. When I go to create a recurring event, the javascript is not coming up to allow me to select from the dropdown menu...I have been searching online for hours trying to figure this out and nothing has worked :( any ideas what the problem could be?

Reply

Hi, Emma you need to first check that the script is running and that turbolinks is not blocking the recurring event. I use google chrome and the dev terminal to see if its running, there's different ways to check.

Reply

Thank you for your response Francisco! I disabled Turbolinks to see if it was blocking the recurring event, but still no luck. I'm wondering if the problem has something to do with the fact that I'm using rails 6 and this video was posted using rails 5 I believe...I am still fairly new to rails, so this is the most complex item I've implemented in my application thus far.

Reply

Hello there, I'm trying to use the recurrent_select gem in rails 7 but i'm getting an error
undefined method `field_name' for nil:NilClass

I'm getting this error in the form, when i try creating a new event
<%= form.select_recurring :recurring,nil, allow_blank: true%>
it seems it doesn't recognize "select_recurring", can someone help me pls?

Reply

I am getting same issue as jose - rails 7 does not work

Reply

Hi, I found a solution in github /GetJobber/recurring_select/pull/152
However the thing is that the js isn´t working for me, I don't know If I'm importing it correctly or how to do it in rails 7

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,464+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.