Sha256: db70faae3eeb522d00a105bb1d3d162c459828b73be767bd68b6428ac2444b6c

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

= EcmCalendarHelper

This project rocks and uses MIT-LICENSE.

== Installation

Add it to your Gemfile.

    # Gemfile
    gem 'ecm_calendar_helper'

== Usage

Add the helper to your controller:

    # app/controllers/application_controller.rb
    class ApplicationController < ActionController::Base
      helper Ecm::CalendarHelper
    end

    # app/controllers/reservations_controller.rb
    class ApplicationController < ActionController::Base
      before_action :initialize_calendar

      private

      def initialize_calendar
        @year  = params[:year]  ||= Time.zone.now.year
        @month = params[:month] ||= Time.zone.now.month

        @date = Date.strptime("#{@month}-#{@year}", "%m-%Y")

        @collection = Reservation.in_month(@date).all
      end
    end

Render the calendar:

    # i.e.app/views/reservations/index.html.haml
    = month_calendar @date, @collection, display_method: :name, start_day: :monday

== Pagination

Add routes for nice year and month params:

    # config/routes.rb
    Rails.application.routes.draw do
      resources :reservations do
        get "(/:year/:month)", action: :index, on: :collection
      end
    end

== Remote rendering

@TODO

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ecm_calendar_helper-1.0.1 README.rdoc
ecm_calendar_helper-1.0.0 README.rdoc