Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

Can I assign dates to display a link?

General • Asked by Nicolás Bobb

Hello, I'm doing an application where I have to show a link. The administrative must be able to assign the date where it is displayed and hidden. Sorry for my English.
I think it's done with the gem delayed job, right?


As far as I understand situation, you don't need background jobs here. To display something on a web page within certain date interval, you just need to add this condition to your view:

<% if (start_date..end_date).cover? %>
  <%= link_to 'Your link', '#' %>
<% end %>

Identical condition check could be implemented within a helper or presenter to keep view cleaner.

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 29,763+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.