calendar_helperを使ってみる

calendar_helperのインストール

先日、NetBeansRailsプラグインのcalendar_helperはインストールしたので
今日はcalendar_helperを使ってみる。
calendar_helperのインストール方法はこちら↓
http://d.hatena.ne.jp/kurusaki/20080831/p1

calendar_helperのREADME.txt

calendar_helperの
vendor/plugins/calendar_helper/README.txt
を見ると使い方は下記のように書いてある。

Usage

See the RDoc (or use "rake rdoc").

To copy the CSS files, use

  ./script/generate calendar_styles

CSS will be copied to subdirectories of public/stylesheets/calendar.

./script/generate calendar_styles

NetBeansからこれを実行するにはプロジェクトのメニューから「生成...」を選択


Rails ジェネレータ」ダイアログが表示される。


Generatoeメニュー からcalendar_stylesを選択する。


「了解」ボタンを押下


Railsジェネレータの出力
      create  public/stylesheets/calendar
      create  public/stylesheets/calendar/red
      create  public/stylesheets/calendar/red/style.css
      create  public/stylesheets/calendar/blue
      create  public/stylesheets/calendar/blue/style.css
      create  public/stylesheets/calendar/grey
      create  public/stylesheets/calendar/grey/style.css

カレンダーを表示するページを作成

Railsジェネレータでmy_calendarコントローラーを作成する。
名前にmy_calendar、ビューにindexを指定し「了解」ボタンを押下。

Railsジェネレータの出力
      exists  app/controllers/
      exists  app/helpers/
      create  app/views/my_calendar
      exists  test/functional/
      create  app/controllers/my_calendar_controller.rb
      create  test/functional/my_calendar_controller_test.rb
      create  app/helpers/my_calendar_helper.rb
      create  app/views/my_calendar/index.html.erb
my_calendar_controller.rb
class MyCalendarController < ApplicationController
  def index
  end

end
my_calendar_controller_test.rb
require 'test_helper'

class MyCalendarControllerTest < ActionController::TestCase
  # Replace this with your real tests.
  def test_truth
    assert true
  end
end
my_calendar_helper.rb
module MyCalendarHelper
end
index.html.erb
<h1>MyCalendar#index</h1>
<p>Find me in app/views/my_calendar/index.html.erb</p>

カレンダーを表示してみる。

index.html.erbを下記の行を追加
<%=calendar(:year => 2008, :month => 9)%>
index.html.erb
<h1>MyCalendar#index</h1>
<p>Find me in app/views/my_calendar/index.html.erb</p>

<%=calendar(:year => 2008, :month => 9)%>
実行してみる

http://localhost:3000/my_calendarにアクセスし表示してみる。

開発環境