The calendar was set up.
I want to add the information of the posts table here.
https://github.com/excid3/simple_calendar Will you proceed with reference to the official page?
.calendar = month_calendar events: @posts do |date, meeting| = date -posts.each do |post| = post.calorie
class CalendarsController <ApplicationController def index @posts = Post.where(user_id: current_user.id) end end
This could not be displayed.
https://qiita.com/isaatsu0131/items/ad1d0a6130fe4fd339d0 According to this article, on the table you want to output to a calendar t.datetime :start_time It seems that you need to set it.
How can I display the data in the posts table?
Hypothesis 1: Prepare the start_time column in the posts table. Hypothesis 2: Allow the start_time column in permit of posts_controller strong parameter. Hypothesis 3: It is necessary to have some value in the start_time column, so put a default value in the start_time column.
@post = Post.new(post_params) #Get today's date (for simple_calendar) @post[:start_time] = Date.today.strftime('%Y-%m-%d')
With this, today’s date is fetched and automatically put in the start_time column of posts_table. By the way, the form for entering start_time is not prepared in the form for posting.
In other words, without filling in the form If you post, the date you posted will be automatically entered in the start_time column.
If there is no value in this red frame part Not displayed as an event.
Now that the start_time contains the date and time value, I was able to display the event in simple_calendar safely.