Calendar in Rails 4

0

I would like to create a calendar in Rails 4. I followed some tutorials on the internet, however, I did not succeed. I was able to do the table_builder calendar in "per month" format, but I need a lot more of the weekly view (with hours on the left and days on top). I could not think of a way to create this.

I tried to use some gems, such as event-calendar or simple calendar, but I could not get it to work correctly with rails 4.

I also went behind some JavaScript and / or HTML code, but I do not know if it is the ideal form, because there the 'filter' would be done on the client side and would bring all the events at one time, overloading the client (I believe).

If anyone can help me with this question, I'll be waiting.

    
asked by anonymous 24.06.2014 / 14:17

1 answer

1

You can create an action in the controller that uses a date parameter (current day, for example) and filters 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, it is just to iterate through events by day and by hour (use scopes or methods in the model or in the client itself)

    
26.06.2014 / 17:13