Lydia's blog

Every day to be a little better


  • Home

  • Archives

  • Search

OC-页面跳转

Posted on 2017-03-09 17:20

1.新建一个controller,在目标controller.h文件下
@property (nonatomic, strong) NSString * currentRoute;

2.在源头文件下webview下
1)if ([currentRoute containsString:@”slider_show”]) {
SliderDetailViewController * sliderShow = [[SliderDetailViewController alloc]init];
sliderShow.currentRoute = currentRoute;

2)interface之后添加
@property(nonatomic,strong)UIWebView *webView;

3)上方添加#import “HomeViewController.h”—想要跳转到的页面

ps:.m文件是显示的页面webview
.h是封装各种方法使用的
vue.js 如果是与h5交互的页面跳转 要在main.js中添加

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
router.beforeEach((to, from, next) => {
console.info(to)
console.info(from)
console.info('跳转了')
let link
if (to.query.client === 'ios') {
link = true
} else if (from.query.client === 'ios'){
console.info('full_path ===' + to.fullPath)
window.location.href = 'http://link_to' + to.fullPath
link= false
} else {
link = true
}
next(link)
})

要不然会只在一个页面进行h5页面之间的跳转 不会进行webview之间的跳转
rails 则不需要 可以直接进行跳转

远程部署代码

Posted on 2017-03-08 15:23

web:
1.登录到远程
ssh root@www.siwei.tech -p 35888
2.进到
/opt/app/pin_tuan_bao_web/current

3.git pull 将代码拉下来
如果有migration就
bundle exec rake db:migrate
如果有js或者css就
bundle exec rake assets:precompile RAILS_ENV=production

4.重启远程服务器:
bundle exec thin restart -C config/thin.yml

h5:
首次就是先bundle
在本地
bundle exec cap deploy

程序基础

Posted on 2017-03-04 21:56

对象:数据
方法:对象的行为
参数:执行方法时必须的条件

将按钮变成图片

Posted on 2017-03-02 11:15
1
2
3
4
5
6
7
<div class="image-upload">
<label for="file-input">
<img src="placeholder.jpg"/>
</label>

<input id="file-input" type="file"/>
</div>

With styling:

1
2
3
4
.image-upload > input
{
display: none;
}

rails--model删除

Posted on 2017-02-25 16:15

destroy: 会删掉 关联表的 数据(通过调用关联表的方法) delete : 不会。 只会删掉当前对象对应的表。

例子:

老王去世了。 老王有20张银行卡。

如果: 我们是上帝。 我们就可以这样写:

laowang.destroy (老王的银行卡也会被删掉)

laowang.delete (只删掉老王, 保留银行卡)

form

Posted on 2017-02-25 15:57

2017/2/22--做从h5页面往后台传数据有感

Posted on 2017-02-22 17:38

之前一直做接口,都是将后台的数据集成到前端页面,好容易熟悉了。。。。今天就要做从前端向后台传送数据(用户预约,后台显示数据)混乱的一天,心得如下
如果想像后台传id但不是网址后方的那个而是另一个的话要在h5页面的script标签中data里面,加上你要传的id名称。初始值 赋为0,类似于index。
然后在created里面加上this.xxx = response.body.xxx(后面的这个xxx为你所在的这个界面接口中的这个变量的名称)
之后在method里定义的方法中里面的params加上 xxx: this.xxx
最后在后台的你要执行的操作的接口后面加上这个参数

或者

直接在接口的那个action中添加用case_id找到相对应的case,然后找到对应的设计师。
再将参数写在要执行的接口后面

rails 加断点&查看log

Posted on 2017-02-21 16:48

查看log:
在terminal中
$ tail -f/名称log

Read more »

rails N+1

Posted on 2017-02-21 16:10

解决方案:
使用 includes, 在 where, 或者 find 等查询之前。

例如:

@fans = Fan.joins(:sales_checks)
           .includes([:sales_checks => [{:wins => :award}, :cash_desk]])

如果, fan : sales_checks = 1 : n,

sales_checks : wins = 1 : n , sales_checks : cash_desk = n : 1

wins : award = n : 1

那么,我们在查询fan的时候,要带上 sales_checks, 那么就 Fan.includes(:sales_checks)

也可以写成: Fan.includes( [:sales_checks])

如果在查询时,要带上 wins, 那么就: Fan.includes([:sales_checks => [:wins]])

如果再带上 cash_desk的话, 那么就 Fan.includes([:sales_checks => [:wins, :cash_desk]) (注意这里 cash_desk是单数, 因为一个 cash_desk对应多个 sales_checks )

如果要带上 wins的 award的话, 那么就是:

Fan.includes([:sales_checks => [{:wins => :award}]])

推荐大家使用bullet 这个gem .特别好用.

rails 初始化数据&代码中有中文

Posted on 2017-02-21 11:53

1.在script文件夹下建立init_xxx.rb文件
2.在terminal中运行:ruby script/init_xxx.rb


在文件顶端加上
-- encoding : utf-8 --

1…232425…28

Lydia

This is lydia's blog

277 posts
1 categories
46 tags
© 2020 Lydia
Powered by Hexo
|
Theme — NexT.Muse v5.1.4