Calendar in Rails 4

Asked

Viewed 381 times

0

I would like to create a calendar in Rails 4. I followed some tutorials on the internet, however, I was not successful. I managed to make the calendar in "per month" format through the table_builder, but I need much more of the weekly view (with the hours on the left and the days on top). I couldn’t think of a way to create this.

I tried to use some Gems, like Event-Calendar or simple Calendar, but I could not make it work properly with Rails 4.

I also went after some Javascript and/or HTML codes, but I don’t know if it is the ideal way, because then the 'filter' would be done on the client side (client-side) and then would bring all the records of events at once, overloading the client (I believe I).

If anyone can help me with this question, I’m on hold.

  • Try this: https://github.com/bokmann/fullcalendar-rails This Gem already generates the html and JS that are required!

1 answer

1


You can create an action in the controller that uses a date parameter (current day, for example) and filter the query for the given week, for example:

def eventos_da_semana
  semana = params[:data_da_semana_desejada].at_beginning_of_week
  @eventos = Event.where("data_inicial > ? AND data_inicial < ?", semana, semana.next_week)
end

In the view, just iterate through events by day and by hour (use Copes or methods in the model or in the client itself)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.