심플 캘린더로 캘린더를 넣었습니다. (Gem)
간단한 캘린더를 만들고 싶습니다.
이번 오리지널 앱으로 아래와 같은 캘린더를 작성했습니다.
 
이것은 simple_calendar라는 Gem을 사용합니다.
어떤 식으로 만들었는지 기억을 포함하여 게시합니다.
실수 등 있을지도 모르지만 잘합니다.
 버전
흐름
①
#Gemfileに記載
gem 'simple_calendar', '~> 2.0'
 기재 후 bundle install을 한다.
②
rails g로 컨트롤러 작성.
※라우팅을 잊지 않고.
③
rails g로 모델 작성.
④
이번은 투고한 일시를 표시시키고 싶으므로, 마이그레이션 파일에 기재.
t.datetime :daytime,null: false
중요합니다.
class CreateMuscles < ActiveRecord::Migration[6.0]
  def change
    create_table :muscles do |t|
      t.string :title,          null: false
      t.text :explain,          null: false
      t.integer :part_id,       null: false
      t.integer :difficult_id,  null: false
      t.datetime :daytime,      null: false
      t.references :user,       foreign_key: true
      t.timestamps
    end
  end
end
그럼 rails db:migrate를 실행!
⑤ 컨트롤러의 내용을 편집한다. (내 물건은 이해하기 어렵기 때문에 할애)
⑥ 뷰 편집.
<h1 class="training-title">MYカレンダー</h1>
<div class="calendar">
  <%= week_calendar events: @muscles do |date, muscles| %>
    <%= date.day %>
    <% muscles.each do |muscle| %>
      <div>
        <%= link_to muscle.title, muscle %>
      </div>
    <% end %>
  <% end %>
</div>
이번에는 일주일 분을 표시하고 싶었기 때문에
<%= week_calendar events: @muscles do |date, muscles| %>
의 부분이 week_calendar입니다.
덧붙여서 month_calender라면 1월분입니다.
외형 편집을 위해 다음을 수행
$ rails g simple_calendar:views
마지막 application.css에 다음을 기입.
 *= require simple_calendar #ここに追加
 *= require_tree .
 *= require_self
 */
거의 참고의 분과 같습니다만, 복습을 겸해 써 주셨습니다.
 참고
도입까지는, 이쪽을 참고로 했습니다!
 htps : // 코 m / 이사 아츠 0131 / ms / 아 d1d0 아 6130 4fd339d0
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Reference
                            
                            이 문제에 관하여(심플 캘린더로 캘린더를 넣었습니다. (Gem)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://qiita.com/hassi-INR/items/9c416f39b6e68954b1f8
                            
                            
                            
                                텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            
                                
                                
                                 우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            
#Gemfileに記載
gem 'simple_calendar', '~> 2.0'
class CreateMuscles < ActiveRecord::Migration[6.0]
  def change
    create_table :muscles do |t|
      t.string :title,          null: false
      t.text :explain,          null: false
      t.integer :part_id,       null: false
      t.integer :difficult_id,  null: false
      t.datetime :daytime,      null: false
      t.references :user,       foreign_key: true
      t.timestamps
    end
  end
end
<h1 class="training-title">MYカレンダー</h1>
<div class="calendar">
  <%= week_calendar events: @muscles do |date, muscles| %>
    <%= date.day %>
    <% muscles.each do |muscle| %>
      <div>
        <%= link_to muscle.title, muscle %>
      </div>
    <% end %>
  <% end %>
</div>
<%= week_calendar events: @muscles do |date, muscles| %>
$ rails g simple_calendar:views
 *= require simple_calendar #ここに追加
 *= require_tree .
 *= require_self
 */
도입까지는, 이쪽을 참고로 했습니다!
htps : // 코 m / 이사 아츠 0131 / ms / 아 d1d0 아 6130 4fd339d0
Reference
이 문제에 관하여(심플 캘린더로 캘린더를 넣었습니다. (Gem)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/hassi-INR/items/9c416f39b6e68954b1f8텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)