1

Hi I need to create recurring event in rails. i.e) every monday i want to conduct meeting for 6months. so i want to make this event as recurrance event in calendar.as I am new to rails, i have followed some links. but i dont get any code or idea about how to do it. I have searched well in SO and got one link.

http://stackoverflow.com/questions/10148960/recurring-events-in-calendar-rails

But really dnt understand what they said. and also i have reviewed few suggested links but those are written in php. so i am unable to follow those links too. pls provide me some code to achieve this task. someone said we cannot achieve recurring event in fullcalendar. but i dont knw exactly whether it is right or wrong. if it is wrong then provide me some code to do this. or guide me if you have idea. thanks in advance.

This is my controller:

class EventsController < ApplicationController
  before_action :set_event, only: [:show, :edit, :update, :destroy]

  # GET /events
  # GET /events.json
  def index
    @events = Event.all
  end

  # GET /events/1
  # GET /events/1.json
  def show
  end

  # GET /events/new
  def new
    @event = Event.new
  end

  # GET /events/1/edit
  def edit
  end

  # POST /events
  # POST /events.json
  def create
    @event = Event.new(event_params)

    respond_to do |format|
      if @event.save
        format.html { redirect_to @event, notice: 'Event was successfully created.' }
        format.json { render :show, status: :created, location: @event }
      else
        format.html { render :new }
        format.json { render json: @event.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /events/1
  # PATCH/PUT /events/1.json
  def update
    respond_to do |format|
      if @event.update(event_params)
        format.html { redirect_to @event, notice: 'Event was successfully updated.' }
        format.json { render :show, status: :ok, location: @event }
      else
        format.html { render :edit }
        format.json { render json: @event.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /events/1
  # DELETE /events/1.json
  def destroy
    @event.destroy
    respond_to do |format|
      format.html { redirect_to events_url, notice: 'Event was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_event
      @event = Event.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def event_params
      params.require(:event).permit(:title, :description, :start_time, :end_time)
    end
end

This is my view:

<p id="notice"><%= notice %></p>

<h1>Listing Events</h1>

<table>
  <thead>
    <tr>
      <th>Title</th>
      <th>Description</th>
      <th>Start time</th>
      <th>End time</th>
      <th colspan="3"></th>
    </tr>
  </thead>

  <tbody>
    <% @events.each do |event| %>
      <tr>
        <td><%= event.title %></td>
        <td><%= event.description %></td>
        <td><%= event.start_time %></td>
        <td><%= event.end_time %></td>
        <td><%= link_to 'Show', event %></td>
        <td><%= link_to 'Edit', edit_event_path(event) %></td>
        <td><%= link_to 'Destroy', event, method: :delete, data: { confirm: 'Are you sure?' } %></td>
      </tr>
    <% end %>
  </tbody>
</table>

<br>
<%= link_to 'New Event', new_event_path %>
<div id="calendar"></div>
<script>
$('#calendar').fullCalendar({
    events: '/events.json'});
</script>

enter image description here

Anitha
  • 1,045
  • 3
  • 18
  • 31
  • can you explain little more what are you trying to achieve ? ie what do you want as recurrence.. is it events on specific dates?? – SRDP Mar 25 '15 at 08:38
  • yeah exactly... ie. every monday i want to conduct meeting for 6months – Anitha Mar 25 '15 at 09:14
  • and you are using fullcalendar/fullcalendar.js right ,plz do specify the version number too – SRDP Mar 25 '15 at 09:31
  • fullCalendar version no?? is that needed?? – Anitha Mar 25 '15 at 09:32
  • you using this http://fullcalendar.io right.. there v1 and v2 for this – SRDP Mar 25 '15 at 09:34
  • where is v1 and v2?? where are they mentioned?? – Anitha Mar 25 '15 at 09:36
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/73742/discussion-between-srdp-and-anita-shalu). – SRDP Mar 25 '15 at 09:38
  • okies leave that i will post a solution and lest see if helps k – SRDP Mar 25 '15 at 09:43
  • @SRDP Did you ever post a solution for this? – Jarrel09 Sep 09 '16 at 19:02
  • @Jarrel09 : The solution to this question is the back-end logic your gone implement for recursive events. The FullCallender.js will just act as interface for the logic your gone implement. You can use for recurring https://www.ruby-toolbox.com/categories/recurring_events OR Combination of https://github.com/jmettraux/rufus-scheduler (for scheduling) https://github.com/mojombo/chronic (for nlp) Hope that will help you in some way, Let me know you if further help is required – SRDP Sep 13 '16 at 11:13

0 Answers0