Since we are developing an application using Simple Calendar, which is a Rails gem, we will explain the introduction and basic usage of Simple Calendar for later study.
The content is a Japanese translation of simple_calendar's official GitHub.
It is a gem that makes it easy to implement the calendar display function.
Write the following in the
Gemfile and enter
bundle install in the terminal.
gem "simple_calendar", "~> 2.0"
Load the default stylesheet into the
*= require simple_calendar
Alternatively, write the following in the
Describes how to use the Simple Calendar method to generate a calendar in a view file.
You can generate a monthly calendar using the
<%= month_calendar do |date| %> <%= date %> <% end %>
You can generate a weekly calendar using the
You can set how many weeks to display with the optional
number_of_weeks is not described, it will be displayed for one week by default.
<%= week_calendar(number_of_weeks: 2) do |date| %> <%= date %> <% end %>
You can customize the number of days displayed in the calendar by using the
You can set how many days are displayed with the option
number_of_days. If you do not write
number_of_days, it will be displayed for 4 days by default.
<%= calendar(number_of_days: 4) do |date| %> <%= date %> <% end %>
This is the end of the process from the introduction of Simple Calendar to the basic usage.
If you want to edit the appearance of each calendar, enter the following command and copy the view file to your own app.
rails g simple_calendar:views #Simple as follows_A calendar folder and each view file will be generated in your app create app/views/simple_calendar create app/views/simple_calendar/_calendar.html.erb create app/views/simple_calendar/_month_calendar.html.erb create app/views/simple_calendar/_week_calendar.html.erb