http://sailsdoc.swift.ren/ 这里有 sails中文文档

一、安装时:

先装nodejs,成功标志 node -v

安装sails 全局安装 node install sails@version -g 安装成功 sails -v

创建 项目 sails new projectname

安装grunt : npm install grunt@version --save-dev(在项目的目录中)

启动sails服务:sails lift

在启动时提示的错误,可以用 npm install 在当前的项目下进行安装。

在创建api时用命令:sails generate api book(在安装后很可能sails lift时会出现错误,此次的处理是npm install sails-config --save-dev

测试浏览:http://localhost:1337/user 创建http://localhost:1337/user/create?name=xy&password=fc12345

note:to avoid the migration warning from sails when generating the book api,add the following to config/env/development.js

models:{

migrate:"alter"

}

二、文件夹:

assets下可以放直接被url调用的网页,图片,js,等文件,url http://localhost:1337/在assets下的路径。

三、路由

config/routes.js

'/':{view:'homepage'} localhost:1337

'/about':{view:'about'} localhost:1337/about  在views下创建 about.ejs

路由蓝图包括以下三种:

restful路由

These routes always have the path of /:modelName or /:modelName/:id

and send the request to the appropriate action by using the HTTP "verb".Middleware policies should be used in a production environment to protect these routes fromuauthorized access.

shortcut路由

these routes only respod to "get" requests and determine which action to send the request to by decoding the path.An example path would look like

/:modelName/<action> and data would be passed to the controller action using query parameters. While great for development work o a prototype,these routes should be disabled in production.

action路由

Thes routes create shortcut routes for custom actions tat don't come for free as part of the restful routes.So for any custom action on a controller,a corresponding path followingthe format /:controllerName/:actionName whill respond to get requests and send the request to the controller.

Blueprit Actions

The Blueprint API creates a number of generic actions tohandleall of the standard behaviour of a restful JSON API to match the BluePrint routes.The following default controller actions,which can be overridden,are provided by the Blueprint api:

find findOne create update destory populate add remove

如何使用 http verb?

'get /posts':{

controller:'postsController',

actio:'list'

}

这个配置告诉应用对get 的请求做出回应,在url处理方式为postscontroller下的list操作。

‘put  /posts/:id':{

controller: 'postsController',

action:'update'

}

这个配置对put请求做出回应,更新一个已存在的用户,其中id为参数,update是postsController中的一个操作。

如何更改模板?

1.用jade 代替 Ejs

npm install jade --save

更改config/views.js文件:

module.exports.views={

engine:'jade',

layout:fasle,这个只有ejs支持,所以换成jade后,要把layout设为false;

locals:{//any options you would like to pass to the jade parser}

}

最后从package.json中移走ejs;

样式文件的替换用sass 替换 less

1.把grunt-contrib-less从age.json中移走,npm install grunt-contrib-sass --save

2.改变所有Grunt task 中的less 引用为 sass.(需要改变的有如下文件)

tasks/cofig/copy.js

tasks/register/compileAssets.js

tasks/register/syncAssets.js

其实如果是新项目了只需更改 tasks/importer.less为importer.sass,其它的都由Sass自动适配。

用postgres 代替LocalDB

waterline (与许多流行的数据库一起工作)(如:Postgresql,MongoDB,Redis.)

关于sails 初学者常见问题汇总的更多相关文章

  1. CentOS安装Oracle数据库详细介绍及常见问题汇总

    一.安装前准备 1.软件硬件要求 操作系统:CentOS 6.4(32bit)Oracle数据库版本:Oracle 10g(10201_database_linux32.zip)最小内存:1G(检查命 ...

  2. SVN集中式版本控制器的安装、使用与常见问题汇总

    SVN是Subversion的简称,是一个开放源代码的版本控制系统,它采用了分支管理系统,集中式版本控制器 官方网站:https://www.visualsvn.com/ 下载右边的服务器端,左边的客 ...

  3. H5项目常见问题汇总及解决方案

    H5项目常见问题汇总及解决方案 H5   2015-12-06 10:15:33 发布 您的评价:       4.5   收藏     4收藏 H5项目常见问题及注意事项 Meta基础知识: H5页 ...

  4. Installshield脚本拷贝文件常见问题汇总

    原文:Installshield脚本拷贝文件常见问题汇总 很多朋友经常来问:为什么我用CopyFile/XCopyFile函数拷贝文件无效?引起这种情况的原因有很多,今天略微总结了一下,欢迎各位朋友跟 ...

  5. MVC 网站部署常见问题汇总

    一:TGIShare项目是一个MVC5的网站程序,部署在了IIS上,使用的Windows验证方式,并在本机设置了计划任务定时调用某个地址执行命令.问题汇总如下: 1.Window Server 200 ...

  6. J2EE进阶(十)SSH框架整合常见问题汇总(一)

    SSH框架整合常见问题汇总(一) 前言 以下所列问题具有针对性,但是遇到同类型问题时均可按照此思路进行解决. HTTP Status 404 - No result defined for actio ...

  7. mysql进阶(十六)常见问题汇总

    mysql进阶(十六)常见问题汇总 MySQL视图学习: http://www.itokit.com/2011/0908/67848.html 执行删除操作时,出现如下错误提示: 出现以上问题的原因是 ...

  8. 转---CentOS安装Oracle数据库详细介绍及常见问题汇总

    一.安装前准备 1.软件硬件要求 操作系统:CentOS 6.4(32bit)Oracle数据库版本:Oracle 10g(10201_database_linux32.zip)最小内存:1G(检查命 ...

  9. (转)CloudStack 安装及使用过程中常见问题汇总

    CloudStack 安装及使用过程中常见问题汇总             在做工程项目中对CloudStack 安装及使用过程中常见的几个问题及如何解决做一个总结.   1.Windows XP虚拟 ...

随机推荐

  1. jQuery和JS对比

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  2. AtomicReference与volatile的区别

    首先volatile是java中关键字用于修饰变量,AtomicReference是并发包java.util.concurrent.atomic下的类.首先volatile作用,当一个变量被定义为vo ...

  3. web automation 常用技术比较

    selenium2支持通过各种driver(FirfoxDriver,IternetExplorerDriver,OperaDriver,ChromeDriver)驱动真实浏览器完成测试. 除此之外, ...

  4. 【BZOJ】1699: [Usaco2007 Jan]Balanced Lineup排队(rmq/树状数组)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1699 我是用树状数组做的..rmq的st的话我就不敲了.. #include <cstdio& ...

  5. NYOJ 1009 So Easy[Ⅰ]【简单题】

    /* 题目大意:求三角形的外接圆 解题思路:c/sin(C)=2R,先求出cos,在求出sin 关键点:直接调用库 解题人:lingnichong 解题时间:2014-10-18 10:19:33 解 ...

  6. RabbitMQ组成及原理介绍-3

    rabbitmq作为成熟的企业消息中间件,实现了应用程序间接口调用的解耦,提高系统的吞吐量. 1.RabbitMQ组成 是由 LShift 提供的一个 Advanced Message Queuing ...

  7. ip地址查询系统和CMD查询的结果不一样

    由于cmd输入 ipconfig查看的IP是局域网内网IP,而用ip地址查看器查看是公网上网的ip地址.所以不一样. 查询内网ip: windows系统: 开始--运行--cmd,命令行输入: ipc ...

  8. 用原生Canvas写贪吃蛇及问题解决

    为了学习Canvas,写了这个小游戏贪吃蛇供自己和大家学习 Github: https://github.com/zhiyishou/Gsnake Play On: http://zhiyishou. ...

  9. XCODE5 真机測试

    原文地址: http://my.oschina.net/u/1245365/blog/196420  亲測 可用 ios申请真机调试( xcode 5)具体解析 摘要 我们做ios项目时.模拟器仅仅能 ...

  10. 打打基础,回头看看avr单片机的定时器、中断和PWM(转)

    以前小看了定时器,发现这东西还真的很讲究,那先复习复习吧. 先提提中断:我的理解就是cpu执行时,遇到中断——根据对应的中断源(硬件或软件)——pc定位中断入口地址,然后根据这里的函数指针——跳转到相 ...