Ruby on Rails 开发手记

Ruby on Rails 开发手记

Rails 安装问题
1.安装Ubuntu 18.04LTS
2.安装 Ruby-full --注意环境权限
3.安装 Rails

gem install rails -v 5.2.4.4

推荐参考。。。反正能找到。

4. 安装Gem包问题:sudo rails new project

遇到问题,参考这个解决:安装git 可解决。

http://ask.sov5.cn/q/NdCbBd4VZZ

类似的很多都是安装Gem包解决。

5.权限不够问题1:rake permission denied
6.权限不够问题2:类似的还有bundle install There was an error while trying to write to…

参考https://blog.csdn.net/sunnylive863/article/details/84196412

sudo chmod -R 777 /Users/you_user_name/.bundle/
脚手架网站搭建问题–菜单作业
1.实用技巧1:数据库还原https://www.itranslater.com/qa/details/2583741022169728000
rake db:migrate VERSION=0
rake db:migrate
2.数据库冗余报错,比如有两个列标头重复。

这个需要注意migrate文件中,create文件和add文件,有一样的作用。

比如create recipes中有两个 string 量,一个叫title, 一个叫instruction

这时候如果再有AddInstructionToRecipes, 就是在原有instruction Colum的时候,添加了同名列。

3.加入新属性后,新属性没有在数据库中正常添加、更新。

已知数据库从特定form 的recipe string 读取信息更新。那么这个form在哪里呢?

在controllers/recipes_controllers.rb 中有对 recipe_params 的 定义:

def recipe_params
	params.require(:recipe).permit(:title, :category_id, :instruction)
end

•ActionRecord#update方法需要显式声明允许更新的param参数

•在这里,就是需要允许category_id参数

•修改为:
在这里插入图片描述

GitLab 使用问题
1. yml格式问题

主要是需要“- ”

例子:

test:
  stage: test
  script:
    - cd cookbook3
    - bundle install
    - rails db:migrate RAILS_ENV=test
    - rails test
  only:
    - cookbook3

deploy:
  stage: deploy
  script:
    - sudo apt-get install -y rsync
    - puma-stop 3000
    - rsync -arv --delete ./cookbook3 ~
    - cd ~/cookbook3
    - bundle install
    - rails db:migrate
    - nohup rails server -d -b 0.0.0.0 -p 3000 &
  only:    - cookbook3 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值