2017年5月8日 星期一

顯示部分字的方法 rails

<%= post.content[0,20] %>
最簡單,但html tag也會跑出來

Rails3之後已經預設不讓html tag逸出

解釋一下下面這個
raw是讓content逸出,但會對網站造成風險
strip_tags  移除html標籤
truncate 擷取前幾個字元
<%= truncate(strip_tags(raw(post.content)),:length=>200) %>


或是直接使用白名單sanitize
<%= sanitize( @event.description ) %>
參考資料
https://ihower.tw/rails/actionview-helpers.html#sec4

https://apidock.com/ruby/Curses/raw/class

http://stackoverflow.com/questions/10129408/show-only-some-words-from-post-as-preview

https://ruby-china.org/topics/6539

https://ruby-china.org/topics/599

bootstrap v3 v4 改版差異

改版差異,沒事改這個幹麼....

grid sytem

v3

.col-md-6 .col-md-offset-3


v4

.col-md-6 .offset-md-3



Shit!!It cost my 30 mins to debug this small change.

2017年5月4日 星期四

Rancher requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8080): Max retries exceeded with url: /v1 (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused',))

教學文章
https://blog.hellosanta.com.tw/%E7%B6%B2%E7%AB%99%E8%A8%AD%E8%A8%88/%E4%BC%BA%E6%9C%8D%E5%99%A8/%E8%A6%96%E8%A6%BA%E5%8C%96%E7%AE%A1%E7%90%86%E7%9C%BE%E5%A4%9A-docker-%E5%AE%B9%E5%99%A8%E8%88%87%E9%83%A8%E7%BD%B2%E7%9A%84%E5%A5%BD%E5%B7%A5%E5%85%B7%EF%BC%9Arancher

http://columns.chicken-house.net/2016/04/29/rancher-on-azure-lab/

Ubuntu16.04

I try to addhost in Rancher,but get this error

requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8080): Max retries exceeded with url: /v1 (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7f5b3588b810>: Failed to establish a new connection: [Errno 111] Connection refused',))


because the 

Host Registration URL

I use the http://localhost:8080 orginally
and the Rancher got find the top IP 192.168.1.109:8080
after that I modify the IP 192.168.1.109:8080

 just leave the 4th column blank is fine.
copy and paste to the terminal

official github
https://github.com/rancher/rancher/issues/1151