ã½ã¼ã¹ã³ã¼ãã1è¡æ¯ã«QRã³ã¼ãã«ããRailsã¢ããªä½ã£ããã¼
ä½ãè¨ã£ã¦ããããããã¾ãããç§ãä½ãè¨ã£ã¦ãããåããã¾ããã
å
æ¥ãskypeã«ã¦ååã®Sãããããããªäºè¨ããã¾ããã
ãzenpou ãã acts_as_searchable ã« create_index ã追å ãã¦ããããã¸ã§ã¯ãã®ãªãã¸ããªã®å ´æãããã¦ãã ããã
acts_as_searchableのreindex!の高速化 - zenpouの日記
ã®ãã¨ã§ããã¼ï¼ã£ã¦è¿ãã¾ãã¨ã
ãããã¤ã§ããä¸è¡ãã¨ã«QRã³ã¼ãã«ãã¦å°å·ãããã®ãAããã«æ¸¡ãã¦ãã ããã
ä½ã«ä½¿ãã®ãç®çã¯åããã¾ããããåããããããäºã¯ãããã¾ããã
ã¨ããããã§1è¡ãã¨ã«QRã³ã¼ãã«å¤ããããã°ã©ã ãä½ãã¾ããã
ä½æ
ãRailsã使ã£ã¦ã
以ä¸ãã³ãã³ã
rails qrcode cd qrcode ruby script/generate controller qrcode index
ã§ãqrcodeã³ã³ããã¼ã©ã¼ã®indexã¡ã½ãããä½æã
app/views/qrcode/index.html.erbã以ä¸ã®æ§ã«ç·¨é
<html> <head> <title>QR Code</title> </head> <body> <% unless params[:source].blank? %> <%params[:source].each_with_index do |s, idx| %> <img src="http://chart.apis.google.com/chart?chs=150x150&cht=qr&chl=<%= CGI.escape(s)%>"> <%= "<br>" if (idx + 1)% 3 == 0 %> <% end %> <% end %> <br> <% form_tag do %> ã½ã¼ã¹ãæ¸ãå ´æ<br> <%= text_area_tag "source",params[:source], :rows => 10, :cols => 50 %> <br> <%= submit_tag "æ´æ°" %> <% end %> </body> </html>
ã§ã
ruby script/server
ã®å¾ãlocalhost:3000/qrcode/ã«ã¢ã¯ã»ã¹ããã¨ããããªè¡¨ç¤ºã«ãªãã®ã§ã
ãã®ã¾ã¾ã½ã¼ã¹å
¥ããã¨ãããªãã¾ã
ã¡ãªã¿ã«åºæ¥ä¸ãã£ãç©ããAããã«æã£ã¦è¡ãã¨ãå«ããããï¼ãã¨è¨ããã¾ããã*1
Railsã§ä½ãã¨ä½ãæ
£ãã¦ãã®ã§åã楽ã ã£ããã§ãããããããRailsã§ä½ãå¿
è¦æ§ã¯å
¨ãç¡ãã§ããã*2
*1:ã¾ããåè«ã§ãã£ããã§ããããªãã該å½ã®ã½ã¼ã¹ã³ã¼ãã¯å¥éã¹ã«ã¤ãã«ã¦å¼ã渡ãã¾ããã
*2:ã¡ãªã¿ã«ãrailsã³ãã³ãã«ããããã¸ã§ã¯ãä½æãããrhtmlãã¡ã¤ã«ã®å¤æ´ã¾ã§ããã¡ã¤ã«ã®æ¥ä»ãè¦ãã¨9åã§ãã£ã¦ã¾ããã