Reputation: 7277
I am trying to generate simple calendar in my app using simple calendar gem. i have project model which has project_title, client_name, description, startdate and enddate.
i need to show the view of calendar from startdate to enddate when i open the project view.how can i do that?
Here's the code:
<p>
<strong>Project title:</strong>
<%= @project.project_title %>
</p>
<p>
<strong>Client name:</strong>
<%= @project.client_name %>
</p>
<p>
<strong>Project desc:</strong>
<%= @project.project_desc %>
</p>
<p>
<strong>Project startdate:</strong>
<%= @project.project_startdate %>
</p>
<p>
<strong>Project enddate:</strong>
<%= @project.project_enddate %>
</p>
### here i need to get the calendar view from above startdate and enddate
Upvotes: 0
Views: 802
Reputation: 778
You can try this as well!
<%= calendar @[email protected]_enddate do |date| %>
<%= date %>
<% end %>
Upvotes: 1
Reputation: 169
First fetch the difference between :start_date
& end_date
:
total_days = end_date - start_date
Now create a custom calender by passing some arguments:
<%= calendar number_of_days: total_days, start_date: start_date_of_your_project do |date| %>
<%= date %>
<% end %>
Let me know! Thanks
Upvotes: 1