Slide 1

Slide 1 text

UIJOSFQPSUTSBJMTͷ͝঺հ *OUSPEVDUJPOPGUIJOSFQPSUTSBJMT 12೥9݄16೔೔༵೔

Slide 2

Slide 2 text

ࣗݾ঺հ wࣰా݈ ͠ͷ͚ͩͨ͠ w5BLFTIJ4)*/0%" w!UBLFTIJOPEB w4*FSʹͯاۀ৘ใγεςϜΛ࡞͍ͬͯ·͢ w஍Ҭ3VCZJTUूஂ"TBLVTBSC༓ྶஂһ w೔ຊ044ਪਐϑΥʔϥϜ3VCZ5' IUUQEIBUFOBOFKQUBLFTIJOPEB IUUQTHJUIVCDPNUBLFTIJOPEB 12೥9݄16೔೔༵೔

Slide 3

Slide 3 text

ࣗݾ঺հ wࣰా݈ ͠ͷ͚ͩͨ͠ w5BLFTIJ4)*/0%" w!UBLFTIJOPEB w4*FSʹͯاۀ৘ใγεςϜΛ࡞͍ͬͯ·͢ w஍Ҭ3VCZJTUूஂ"TBLVTBSC༓ྶஂһ w೔ຊ044ਪਐϑΥʔϥϜ3VCZ5' IUUQEIBUFOBOFKQUBLFTIJOPEB IUUQTHJUIVCDPNUBLFTIJOPEB 12೥9݄16೔೔༵೔

Slide 4

Slide 4 text

ΑΖ͘͠ ͓Ͷ͕͍͍ͨ͠·͢ 12೥9݄16೔೔༵೔

Slide 5

Slide 5 text

ۀ຿ΞϓϦέʔγϣϯ 12೥9݄16೔೔༵೔

Slide 6

Slide 6 text

Ϊϣʔϛʔͳ3VCZJTUͷΑ͋͘Δ೰Έ wாථग़͍ͨ͠ͳʔ w΍ͬͺॻྨจԽΛ੍ͯ͠φϯϘͰ͢Θʔ wϛϦ୯Ґͷमਖ਼ͯ͠ாථ৬ਓ͍ͨ͠ͳʔ wࠃ࢈ͷţŠƄŘιϑτͳ͍͔ͳʔ 12೥9݄16೔೔༵೔

Slide 7

Slide 7 text

5IJO3FQPSUT͝ଘ͡Ͱ͢ʁ .BU[ߐࢢ͕ތΔاۀʮϚπέΠʯ͞Μͷ ೔ߴࠀ໵͞Μ !IJEBLBUTVZB Β͕࡞ͬͨ 3VCZʹΑΔ3VCZͷͨΊͷ ாථιϦϡʔγϣϯ ೥ϑΫΦΧ3VCZେ৆ 12೥9݄16೔೔༵೔

Slide 8

Slide 8 text

5IJO3FQPSUT &EJUPS UMG SC 5IJO3FQPSUT (FOFSBUPS QEG PVUQVU PVUQVU JOQVU SFRVJSF 12೥9݄16೔೔༵೔

Slide 9

Slide 9 text

5IJO3FQPSUT&EJUPS ˠbPSEFSUMG` 12೥9݄16೔೔༵೔

Slide 10

Slide 10 text

require 'thinreports' # ... ThinReports::Report.create layout: 'order.tlf' do |report| report.start_new_page do |page| page.item(:company_name).value(@customer.name) page.item(:ordered_at).value(Time.now) page.list(:list) do |list| list.config.events.on :footer_insert do |e| e.section.item(:total).value(@orders.total) end @orders.each do |order| list.add_row do |row| row.values(name: order.name, num: order.num, price: order.price, order_total: order.total) end end end end end.generate_file('order.pdf') HFNbUIJOSFQPSUT` 5IJO3FQPSUTHFOFSBUPS 12೥9݄16೔೔༵೔

Slide 11

Slide 11 text

12೥9݄16೔೔༵೔

Slide 12

Slide 12 text

Pŋ㱼ŋ ੋඇզ͕ࣾͷ 3BJMTϓϩμΫπʹಋೖΛ 12೥9݄16೔೔༵೔

Slide 13

Slide 13 text

͔͠͠ʜ 12೥9݄16೔೔༵೔

Slide 14

Slide 14 text

7JFXʹॻ͖͍ͨ 12೥9݄16೔೔༵೔

Slide 15

Slide 15 text

UIJOSFQPSUTSBJMT IUUQTHJUIVCDPNUBLFTIJOPEBUIJOSFQPSUTSBJMT IUUQTSVCZHFNTPSHHFNTUIJOSFQPSUTSBJMT 12೥9݄16೔೔༵೔

Slide 16

Slide 16 text

$ gem install thinreports-rails Gemfile gem ‘thinreports-rails’ $ bundle install 12೥9݄16೔೔༵೔

Slide 17

Slide 17 text

class OrdersController < ApplicationController def index @orders = Order.query(hogehoge) end end 12೥9݄16೔೔༵೔

Slide 18

Slide 18 text

report.start_new_page do |page| page.item(:company_name).value(@orders.first.company.name) page.item(:ordered_at).value(Time.now) page.list(:list) do |list| list.config.events.on :footer_insert do |e| e.section.item(:total).value(@orders.total) end @orders.each do |order| list.add_row do |row| row.values(name: order.name, num: order.num, price: order.price, order_total: order.total) end end end end JOEFYUMG BQQWJFXTPSEFSTJOEFYQEGUIJOSFQPSUT 12೥9݄16೔೔༵೔

Slide 19

Slide 19 text

IUUQMPDBMIPTUPSEFSTQEG 12೥9݄16೔೔༵೔

Slide 20

Slide 20 text

UIJOSFQPSUTSBJMT ͕͋Δͱ͜Μͳ೔ৗ΋ ؆୯ʹ߈ུͰ͖·͢ 12೥9݄16೔೔༵೔

Slide 21

Slide 21 text

偉い人 「呟き台帳が欲しい」 12೥9݄16೔೔༵೔

Slide 22

Slide 22 text

12೥9݄16೔೔༵೔

Slide 23

Slide 23 text

def twitter @user = Twitter.user(params[:id]) @tl = Twitter.user_timeline(params[:id]) end 12೥9݄16೔೔༵೔

Slide 24

Slide 24 text

require 'open-uri' report.start_new_page do |page| page.item(:icon).src(open(@user.profile_image_url)) page.values(twitter_id: params[:id], bio: @user.description) page.list(:timeline) do |list| @tl.take(4).each do |tweet| list.add_row do |row| row.values(created_at: tweet.created_at, tweet: tweet.text) end end end end UXJUUFSUMG BQQWJFXTUXJUUFSUXJUUFSQEGUIJOSFQPSUT 12೥9݄16೔೔༵೔

Slide 25

Slide 25 text

12೥9݄16೔೔༵೔

Slide 26

Slide 26 text

5JQT 12೥9݄16೔೔༵೔

Slide 27

Slide 27 text

class OrdersController < ApplicationController def index @orders = Order.all send_data render_to_string, filename: 'orders.pdf', type: 'application/pdf', disposition: 'attachment' end end %PXOMPBE 12೥9݄16೔೔༵೔

Slide 28

Slide 28 text

QBSUJBM # ... report.start_new_page report.partial! 'header' # ... BQQWJFXTPSEFST@IFBEFSQEGUIJOSFQPSUT 12೥9݄16೔೔༵೔

Slide 29

Slide 29 text

ৄ͘͠͸8FCͰ 12೥9݄16೔೔༵೔

Slide 30

Slide 30 text

12೥9݄16೔೔༵೔

Slide 31

Slide 31 text

ࣗ෼ͷCMPHʹ࠘Έ͕·͘͠ IUUQEIBUFOBOFKQUBLFTIJOPEB ໊લ͸thinreports-railsʹ͔͚ͨͬͨ͠Ͳɺຊ ՈϓϩδΣΫτνʔϜͷํ͕࢖͏༧ఆΈ͍ͨ Ͱۭͷಉ໊ϦϙδτϦ͕͢Ͱʹ͋ͬͨɻͳͷ Ͱɺthinreports-handler ͱͨ͠ɻͪΐͬͱΘ ͔Γʹ͍͔͘ͳɻςϯϓϨʔτϋϯυϥͬͯ ҙຯͰ͢ɻ 12೥9݄16೔೔༵೔

Slide 32

Slide 32 text

12೥9݄16೔೔༵೔

Slide 33

Slide 33 text

UIJOSFQPSUTIBOEMFS UIJOSFQPSUTSBJMT 改�名 12೥9݄16೔೔༵೔

Slide 34

Slide 34 text

wۀ຿ͳΤϯδχΞͰ΋ιʔγϟϧίʔσΟϯάʹ ͞͞΍͔ͳ͕ΒࢀՃͰ͖Δͷ͔ͳ w͜Μͳ΍ΓͱΓָ͍͠Ͷ w5IJO3FQPSUT UIJOSFQPSUTSBJMTڞʑΑΖ͘͠ wUMGϑΝΠϧΛ$ rails generateίϚϯυͰ ੜ੒ग़དྷΔΑ͏ʹ͍ͨ͠ 12೥9݄16೔೔༵೔

Slide 35

Slide 35 text

͋Γ͕ͱ͏ ͍͟͝·ͨ͠ 5IBOLZPV 12೥9݄16೔೔༵೔