Search code examples
ruby-on-railssidekiq

using sidekiq to remove class from html


I have really never used background processing before with rails. I know that sidekiq is probably the most notable so I'm going with that. RUNDOWN: I have assignment that have a start_time. I want to make sure users cannot start the assignment until the start_time is an hour away form Time.current. The way I would like to do this is remove a disabled class from the html so the user can access the assignment. So if the user set the start_time of the assignment to 5:00 pm the class will be removed from the html at 4:00 PM. Does this make sense? and if so, Is using Sidekiq the proper way to go about this?


Solution

  • Background processes are used to perform long-running tasks in a way that doesn't tie up other users from using your site. For example: sending mail, doing something with an external API, calculating things. I don't think you'll need Sidekiq for what you're wanting to do.

    Instead, you already have start_time in the db, just use it! You can do something like this in your view:

    <div class="<%= 'hidden' if @assignment.start_time > 1.hour.from_now %>">