小编use*_*898的帖子

如何获取HTML表中的<td>以适应内容,并让特定的<td>填写其余部分

这是一个假设的例子:

table, thead, tbody, tr { width: 100%; }
    table { table-layout: fixed }
    table > thead > tr > th { width: auto; }
Run Code Online (Sandbox Code Playgroud)
<table>
      <thead>
        <tr>
          <th>Column A</th>
          <th>Column B</th>
          <th>Column C</th>
          <th class="absorbing-column">Column D</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>Data A.1 lorem</td>
          <td>Data B.1 ip</td>
          <td>Data C.1 sum l</td>
          <td>Data D.1</td>
        </tr>
        <tr>
          <td>Data A.2 ipsum</td>
          <td>Data B.2 lorem</td>
          <td>Data C.2 some data</td>
          <td>Data D.2 a long line of text that is long</td>
        </tr>
        <tr>
          <td>Data A.3</td>
          <td>Data …
Run Code Online (Sandbox Code Playgroud)

html css html-table width

45
推荐指数
2
解决办法
13万
查看次数

Rails/Nginx/Capistrano/Puma:连接到上游时(111:Connection拒绝)

我一直在nginx.error.log中收到此错误:

2016/06/06 20:14:02 [error] 907#0: *1 connect() to unix:///home/user/apps/appname/shared/tmp/sockets/appname-puma.sock failed (111: Connection refused) while connecting to upstream, client: 50.100.162.19, server: , request: "GET / HTTP/1.1", upstream: "http://unix:///home/user/apps/appname/shared/tmp/sockets/appname-puma.sock:/", host: "appname.com"

(here it is with manually added newlines for your convenience)
2016/06/06 20:14:02 [error] 907#0: *1 connect() to
unix:///home/user/apps/appname/shared/tmp/sockets/appname-puma.sock failed
(111: Connection refused) while connecting to upstream, client: 
50.100.162.19, server: , request: "GET / HTTP/1.1", upstream: 
"http://unix:///home/user/apps/appname/shared/tmp/sockets/appname-
puma.sock:/", host: "appname.com"
Run Code Online (Sandbox Code Playgroud)

这是我的nginx.conf:

upstream puma {
  server unix:///home/user/apps/appname/shared/tmp/sockets/appname-puma.sock;
}

server {
  listen 80 default_server …
Run Code Online (Sandbox Code Playgroud)

connection nginx puma ruby-on-rails-4 capistrano3

4
推荐指数
1
解决办法
4016
查看次数

Ruby(Rails)gsub:将捕获的字符串传递给方法

我正在尝试匹配字符串:

text = "This is a #hastag"
raw(
  h(text).gsub(/(?:\B#)(\w*[A-Z]+\w*)/i, embed_hashtag('\1'))
)

def embed_hashtag('data')
  #... some code to turn the captured hashtag string into a link
  #... return the variable that includes the final string
end
Run Code Online (Sandbox Code Playgroud)

我的问题是,当我传入'\1'我用gsub调用的embed_hashtag方法时,它只是"\1"字面上传递,而不是我的正则表达式中第一个捕获的组.还有其他选择吗?

供参考:

  1. 我正在将文本包装h成转义字符串,但后来我将代码嵌入到用户输入的文本(即主题标签)中,这些文本需要原始传递(因此raw).

  2. 保持"#"符号与文本分开很重要,这就是为什么我认为我需要捕获组.

  3. 如果你有更好的方法做到这一点,请不要犹豫让我知道,但为了回答这个问题,我仍然想要一个答案,以防其他人有这个问题.

ruby regex ruby-on-rails gsub ruby-on-rails-4.1

3
推荐指数
1
解决办法
1678
查看次数