Skip to content

Instantly share code, notes, and snippets.

class CalendarTitle < ApplicationRecord
cattr_accessor :definition_file
self.definition_file = "#{Rails.root}/db/static_data/event_titles.yml"
include Findable
end
@ecmelkytz
ecmelkytz / calendar_title.rb
Created November 22, 2018 10:22
Calender event concern
# frozen_string_literal: true
class CalendarTitle < ApplicationRecord
# include EventTitle
# search
include PgSearch
pg_search_scope(
:search,
against: %i[name],
using: { tsearch: { prefix: true } }
@ecmelkytz
ecmelkytz / calendar_event.rb
Created November 21, 2018 10:47
Akademik takvim tarih aralıkları
class CalendarEvent < ApplicationRecord
def proper_range?
Time.zone.now >= start_date && Time.zone.now <= end_date
end
end

ActiveStorage

1. ActiveStorage Nedir?

Rails 5.2 ile gelen ActiveStorage özelliği, dosyaları Amazon S3, Google Cloud, Microsoft Azure Cloud gibi cloud bir servise upload etmemizi sağlar.

2. Kurulum

rails active_storage:install

Bu çalıştırılan kod active_storage_blobs ve active_storage_attachments tablolarını oluşturan bir migrate dosyası ve servis konfigürasyonları için config altında storage.yml dosyası oluşturur.

.gitignore'a sonradan ekleme yapıp, repo'daki ilgili dosyayı sildirip takipten çıkarmak için:

git rm -r --cached .
git add .
git commit -m "fixed untracked files"

Repoda dursun ve değişiklikleri takip etmesin istiyorsak:

Procfile dosyasını projenin ana dizininde oluştur ve içine şunu ekle:

web: bundle exec puma -p $PORT

Projenin ilgili dizininde:

$ heroku create # git'e heroku remote'ını eklemiş olacağız
<!-- Wraps every three items in div.row -->
<!-- Closes div.row even there is not enough items -->
{% for item in site.data.your_data %}
{% capture modulo %}{{ forloop.index | modulo: 3 }}{% endcapture %}
{% if modulo == '1' %}
<div class="row">
<div class="menu_section">
<h3>Raporlar</h3>
<ul class="nav side-menu">
<li><a><i class="fa fa-sitemap"></i> Sistem Raporları <span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu" style="display: none">
<li><a href="#level1_1">Level One</a>
<li><a>Level One<span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu" style="display: none">
<li class="sub_menu"><a href="level2.html">Level Two</a></li>
<li><a href="#level2_1">Level Two</a></li>
<%= javascript_include_tag 'http://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js' %>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog modal-lg" role="document" >
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">Duyuru</h4>
</div>
<div class="modal-body" >
<div class="row" ng-controller="ExpoCtrl">
<div class="col-md-6 col-md-offset-3">
<center><h1>Books</h1></center>
<form class="form-horizontal" ng-submit="addBook()">
<div class="input-group">
<input type="text" class="form-control" ng-model="book_title">
<span class="input-group-btn">
<input type="submit" class="btn btn-default" value="Ekle">
</span>
</div>