https://github.com/zenizh/carender
📅 A monthly calendar for Rails application
https://github.com/zenizh/carender
calendar gem rails ruby
Last synced: 8 months ago
JSON representation
📅 A monthly calendar for Rails application
- Host: GitHub
- URL: https://github.com/zenizh/carender
- Owner: zenizh
- License: mit
- Created: 2018-01-17T12:50:59.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-19T16:47:51.000Z (over 8 years ago)
- Last Synced: 2025-09-30T20:33:54.857Z (9 months ago)
- Topics: calendar, gem, rails, ruby
- Language: Ruby
- Homepage: https://rubygems.org/gems/carender
- Size: 41 KB
- Stars: 15
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Carender
[](https://badge.fury.io/rb/carender)
[](https://travis-ci.org/kami-zh/carender)
This gem renders a monthly calendar for Ruby on Rails application.
## Usage
This gem automatically renders a monthly calendar as HTML table by fetching `params[:year]` and `params[:month]` at view context.
Following code renders a simple monthly calendar:
```erb
<%= carender do |date| %>
<%= date.day %>
<% end %>
```
The content passed as a block is rendered in each cell.
For example, above code renders like following HTML table.
```html
SunMonTueWedThuFriSat
123456
78910111213
...
```
### Collection
To render a calendar with a collection which is grouped by the specified column, you can pass `:collection` and `:column` arguments like as follows:
```erb
<%= carender collection: @posts, column: :posted_on do |date, posts| %>
<% posts.each do |post| %>
<%= link_to post.title, post %>
<% end %>
<% end %>
```
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'carender'
```
And then execute:
```bash
$ bundle
```
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/kami-zh/carender. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).