Skip to content

Instantly share code, notes, and snippets.

[
{
"title": "Rails Öğreniyorum",
"article": "Rails öğrenmeye giriş. MVC yapısını anlamaya çalışıyorum.",
"status": "draft"
},
{
"title": "ActiveRecord ile Veritabanı İşlemleri",
"article": "ActiveRecord ile veritabanı işlemleri oldukça pratik.",
"status": "published"
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 } }

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">
<%= 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" >
{ "records":[ {"Name":"Alfreds Futterkiste","City":"Berlin","Country":"Germany"}, {"Name":"Ana Trujillo Emparedados y helados","City":"México D.F.","Country":"Mexico"}, {"Name":"Antonio Moreno Taquería","City":"México D.F.","Country":"Mexico"}, {"Name":"Around the Horn","City":"London","Country":"UK"}, {"Name":"B's Beverages","City":"London","Country":"UK"}, {"Name":"Berglunds snabbköp","City":"Luleå","Country":"Sweden"}, {"Name":"Blauer See Delikatessen","City":"Mannheim","Country":"Germany"}, {"Name":"Blondel père et fils","City":"Strasbourg","Country":"France"}, {"Name":"Bólido Comidas preparadas","City":"Madrid","Country":"Spain"}, {"Name":"Bon app'","City":"Marseille","Country":"France"}, {"Name":"Bottom-Dollar Marketse","City":"Tsawassen","Country":"Canada"}, {"Name":"Cactus Comidas para llevar","City":"Buenos Aires","Country":"Argentina"}, {"Name":"Centro comercial Moctezuma","City":"México D.F.","Country":"Mexico"}, {"Name":"Chop-suey Chinese","City":"Bern","Country":"Switzerland"}, {"Name":"Comércio
["Andorra","United Arab Emirates","Afghanistan","Antigua and Barbuda","Anguilla","Albania","Armenia","Angola","Antarctica","Argentina","American Samoa","Austria","Australia","Aruba","Åland","Azerbaijan","Bosnia and Herzegovina","Barbados","Bangladesh","Belgium","Burkina Faso","Bulgaria","Bahrain","Burundi","Benin","Saint Barthélemy","Bermuda","Brunei","Bolivia","Bonaire","Brazil","Bahamas","Bhutan","Bouvet Island","Botswana","Belarus","Belize","Canada","Cocos [Keeling] Islands","Congo","Central African Republic","Republic of the Congo","Switzerland","Ivory Coast","Cook Islands","Chile","Cameroon","China","Colombia","Costa Rica","Cuba","Cape Verde","Curacao","Christmas Island","Cyprus","Czechia","Germany","Djibouti","Denmark","Dominica","Dominican Republic","Algeria","Ecuador","Estonia","Egypt","Western Sahara","Eritrea","Spain","Ethiopia","Finland","Fiji","Falkland Islands","Micronesia","Faroe Islands","France","Gabon","United Kingdom","Grenada","Georgia","French Guiana","Guernsey","Ghana","Gibraltar","Greenl