DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone >

View Code For Calendar Helper

Snippets Manager user avatar by
Snippets Manager
·
Aug. 28, 06 · · Code Snippet
Like (0)
Save
Tweet
453 Views

Join the DZone community and get the full member experience.

Join For Free
This is the view template for an action that has all the events in @events
it links to the event, too ( I used the trestle generator, and the calendar helper plugin )


<%=
calendar({:year => @year, :month => @month}) do |d|
  cell_text = "#{d.mday}
" cell_attrs = {:class => 'day'} @events.each do |e| if e.starts_at.mday == d.mday cell_text << link_to( e.title, :action => 'show', :id => e ) << "
" cell_attrs[:class] = 'specialDay' end end [cell_text, cell_attrs] end %>
Here is the controller action snippet if you need it. This could probably be improved by only finding the events in the certain month you are looking at. def show @event = Event.find(params[:id]) end def calendar @year = @params[:year].to_i @month = @params[:month].to_i @events = Event.find(:all) end Here is my migration for my events table. class CreateEvents < ActiveRecord::Migration def self.up create_table :events do |t| t.column "title", :string t.column "description", :text t.column "starts_at", :datetime t.column "ends_at", :datetime t.column "recurring", :boolean t.column "created_by", :string t.column "updated_by", :string t.column "updated_on", :datetime t.column "created_on", :datetime end end def self.down drop_table :events end end
Calendar (Apple)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Cloud-Based Integrations vs. On-Premise Models
  • Real-Time Supply Chain With Apache Kafka in the Food and Retail Industry
  • How to Configure Git in Eclipse IDE
  • 3 Predictions About How Technology Businesses Will Change In 10 Years

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo