rails sql 多表联查
Posted on
俩表联查(A中有B的外键)
1 | A.joins(:B) |
三表联查
1)如果A中有B和C的外键
1 | A.joins(:B, :C) |
2)如果A中有B的外键,B中有C的外键
1 | A.joins(B: :C) |
js--字符串包含
Posted on
indexOf用法:
if (route.indexOf(“repaire_staffs”) != -1){
document.title = “维修人员”
}
用 -1这个值来判断 不包含就会返回-1
微信小程序
Posted on
2.条件渲染:
在框架中,我们用 wx:if=”“ 来判断是否需要渲染该代码块:
1 | <view wx:if="{{condition}}"> True </view> |
也可以用 wx:elif 和 wx:else 来添加一个 else 块:
1 | <view wx:if="{{length > 5}}"> 1 </view> |
在vue 中 放大缩小图片
Posted on
Vue-preview
1.在package.json dependencies里面加上
“vue-preview”: “^1.0.5”,
2.在main.js里面引用:
import VuePreview from ‘vue-preview’
Vue.use(VuePreview)
3.html:
<img class=”preview-img” v-for=”(item, index) in list” :src=”item.src” height=”100” @click=”$preview.open(index, list)”>
注意 : 图片形式必须为
{
src: ‘https://placekitten.com/600/400',
w: 600,
h: 400
}
搭建环境 --mysql安装的坑
Posted on
代码拉下来以后,bundle install 的时候 mysql2死活安装不上
要先
$ brew install mysql
之后才能安装上gemfile中的mysql
rspec---单元测试
Posted on
配置环境
- add to Gemfile:
1
2
3
4
5
6
7
8# Gemfile:
gem 'rspec-rails', '~> 3.5.2'
然后运行:
$ bundle exec rails generate rspec:install
记得要把生成的.rspec 文件做个修改,删掉
# .rspec file:
--color
# NO --warning, --require spec_helper
js--根据选择不同 页面局部刷新
Posted on
1 | <div class="detail-tr form-action"> |