Slide 1

Slide 1 text

ࣲాതࢤ SHIBATA Hiroshi QBQFSCPZDP BTBLVTBSC paperboy&co., Inc. Awesome Inquiry Management System ൃද৔ॴେߐށ3VCZձٞ 2013-03-16(Sat) ΅͘ͷ͔Μ͕͑ͨ ͍͖͞ΐ͏ͷ໰͍߹ Θͤ؅ཧγεςϜ

Slide 2

Slide 2 text

TFMG

Slide 3

Slide 3 text

SHIBATA Hiroshi(@hsbt)

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

asakusa.rb

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

1.XXXSVCZMBOHPSH 4.FCBOTIVHPۀ 3.3VCZ"QQMJDBUJPO$* 2.CVHTSVCZMBOHPSH

Slide 10

Slide 10 text

ຊ୊

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

΍Γ͍ͨ ͜ͱ

Slide 13

Slide 13 text

@cs ͓໰͍߹Θͤͷݕࡧ͕ੌ ͘஗ͯ͘෼ܦͬͯ΋Ԡ౴ ແ͔ͬͨΓɺ෼ܦͬͯ ݟ͔ͭΒͳ͍ͱ͔ NKE @hsbt

Slide 14

Slide 14 text

ͦ͏͍΍TPMSͱ͔৮Β Μͱͳ͋ɺ͔ͤͬ͘ͷػձ ͩ͠࡞ͬͯݟΔ͔ Կͱ͔͠·͢Α @hsbt @cs NKE

Slide 15

Slide 15 text

೔ޙ

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

source 'https://rubygems.org' gem 'rails', '~> 4.0.0.beta1' gem 'activerecord-nulldb-adapter' gem 'mysql2' # gem 'pg' gem 'slim-rails' gem 'bootstrap-sass' gem 'jquery-rails' gem 'kaminari' gem 'omniauth-github' gem 'rails_config' gem 'sunspot_rails' gem 'progress_bar' gem 'system_timer' if RUBY_VERSION < '1.9' group :assets do gem 'sass-rails', '~> 4.0.0.beta1' gem 'coffee-rails', '~> 4.0.0.beta1' gem 'therubyracer' gem 'uglifier' end group :development, :test do gem 'sunspot_solr' gem 'spring' gem 'pry-rails' gem 'forgery' gem 'factory_girl_rails' end group :production do gem 'puma' end 5.TVOTQPU 1.3BJMT 4.PNOJBVUI 3.TMJN 2.OVMMEC

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

جຊํ਑

Slide 24

Slide 24 text

1.εΩʔϚϨε 2.&OHJOF׆༻

Slide 25

Slide 25 text

U@GPP@CBS

Slide 26

Slide 26 text

DSFBUF@EBUF VQEBUF@EBUF ͨͩ͠จࣈྻ

Slide 27

Slide 27 text

Settings.inquiries_tables.each do |table| class_name = table.name.singularize.classify self.class.const_set class_name, Class.new(ActiveRecord::Base) class_name.constantize.class_eval do |klass| klass.establish_connection table.database.to_hash klass.table_name = table.name def klass.text_columns columns.select{|c| [:string, :text].include?(c.type) && c.name != settings.created_at }.map{|c| c.name.to_sym} end def klass.display_columns settings.display_columns.map(&:to_sym) end def klass.settings Settings.inquiries_tables.detect{|table| table.name == self.table_name} end def created_at Time.parse(send(self.class.settings.created_at.to_sym)) rescue nil end if table.created_at && !respond_to?(:created_at) attr_accessible *text_columns if Rails.env.development? searchable do text *text_columns time :created_at if settings.created_at end end end if Settings.inquiries_tables.present?

Slide 28

Slide 28 text

.Z42-ͷεΩʔϚఆ ٛΛݟͯɺͦͷத͔Β ςΩετͬΆ͍ΧϥϜ ͚ͩΛऔΓग़ͯ͠ɺͦ ͷΧϥϜ໊ͷγϯϘϧ Λ഑ྻͰฦ͢ͷͬͯͲ ͏΍ΔΜ͚ͩͬʁʁʁ

Slide 29

Slide 29 text

def klass.text_columns columns.select do |c| [:string, :text].include? c.type end.map{|c| c.name.to_sym} end

Slide 30

Slide 30 text

module DynamicModel def all Settings.inquiries_tables.map do |table| table.name.singularize.classify.constantize end end module_function :all end

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

class InquiriesController < ApplicationController before_filter :login_required respond_to :html def index @inquiries = [] DynamicModel.all.each do |klass| @inquiries << klass.all(:limit => 5) end @inquiries.flatten! end def search @inquiries = [] DynamicModel.all.each do |klass| @inquiries << klass.search do fulltext params[:q] end.results end @inquiries.flatten! @inquiries = Kaminari.paginate_array(@inquiries).page(params[:page]).per(25) end def show @inquiry = params[:class_name].constantize.find(params[:id]) end end

Slide 33

Slide 33 text

- @inquiries.each do |inquiry| .row-fluid .span12 .fieldset .legend = link_to inquiry.send(inquiry.class.primary_key.to_sym), inquiry_path(inquiry, :class_name => inquiry.class) table.table - inquiry.class.text_columns.each do |c| - next unless inquiry.class.display_columns.include? c tr td= c.to_s td= truncate(inquiry.send(c.to_sym), length: 140) - if inquiry.class.settings.created_at tr td= inquiry.class.settings.created_at.to_s td= inquiry.send(inquiry.class.settings.created_at.to_sym)

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

1.SCFOW 4.OHJOY 3.TVQFSWJTPSE 2.TPMS

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

͍͍ͩͨͰ͖ͨ

Slide 39

Slide 39 text

@cs Ίͬ͞ૣ ƅшƅ :"55" @hsbt

Slide 40

Slide 40 text

https://github.com/hsbt/ whispered https://github.com/hsbt/ whispered-puppet