zoukankan      html  css  js  c++  java
  • Ruby China 积累

    安装

      1. sudo rm /var/lib/mongodb/mongod.lock
      2. sudo -u mongodb mongod -f /etc/mongodb.conf --repair
      3. sudo service mongodb start

    解读代码

    1. protect_from_forgery 可以防止CSRF攻击,这个功能会在所有的表单中自动插入安全验证码。关于CSRF攻击,请查看浅谈CSRF攻击方式
    2. Gemfile是你想要程序依赖的(愿望), Gemfile.lock是当前程序已经依赖的(事实)  所以你改了gemfile,要再bundle install一下,才更新gemfile.lock 。参考:Ruby bundle命令详解
    3. config.ru文件可以用来让你在Rack环境下启动你的应用程序。
    4. 路由解读一: 
      resources :pages, :path => "wiki" do
          collection do
            get :recent
            post :preview
          end
          member do
            get :comments
          end
        end
      对象是pages,路径是wiki,集合动作get的recent和post的preview,实例动作get的comments,

      集合动作的意思呢,就是不带id的,表示一个团伙的动作 例如/wiki/recent,这是个get请求

      实例动作呢,表示某一个具体的对象的动作 例如 /wiki/1/comments,这是get请求 就是说获取pagesid是1的所有的评论,comments应该是对应到评论对象

      可以用rake routes来查看路由

    5. 路由解读二:
        devise_for :users, :path => "account", :controllers => {
            :registrations => :account,
            :sessions => :sessions,
            :omniauth_callbacks => "users/omniauth_callbacks"
          }
      你现在只需要知道这个配置是给一个叫devise的gem用的,devise是用来做用户登陆注册模块的
    6. 数据库查询:
      rails c
      User.first
    7.  opts[:etag] << Setting.app_name  浏览器缓存使用
    8.  super(opts)  调用父方法
    9. RAILS_ENV=developement rails s

      

  • 相关阅读:
    dubbo springcloud区别
    rpc
    centos7 安装docker
    vibox安装
    知识点
    spring cloud
    微服务设计原则
    工具类
    xss--知识点
    java基础--注解
  • 原文地址:https://www.cnblogs.com/andrewcn/p/3041902.html
Copyright © 2011-2022 走看看