就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the help center为指导。
8年前关闭。
再次...选择框架。我已经停在这两个 TowerJS 和 RailwayJS 上,但它们看起来非常相似,很难选择哪种方式
两者都基于 Express,两者都是 RoR 风格的框架......
哪一款最有前途,哪一款会更受欢迎?
或者也许我已经走错路了?也许我应该选择其他框架。
我讨厌有这么多框架可供选择,没有可以依赖的行业标准,或多或少地确定该框架将在近两年内开发出来......
请帮助,需要专家的建议。谢谢
最佳答案
这是一个简要的概述表,我将在下面讨论一些内容。
+-----------------------+------------------------------+------------------------------------+
| | RailwayJS | Tower.js |
+-----------------------+------------------------------+------------------------------------+
| First commit | Jan 2011 | Oct 2011 |
| Rails | 2.3.x | 3.x |
| Node.js | >= 0.4.x | >= 0.4.x |
| Server | ✓ | ✓ |
| Client | | ✓ |
| Template agnostic | ✓ | ✓ |
| Default engine | EJS | CoffeeKup |
| Database agnostic | ✓ | ✓ |
| Default datastore | MongoDB | MongoDB |
| Model validations | validatesPresenceOf('email') | validates('email', presence: true) |
| Query scopes | ✓ | ✓ |
| Chainable scopes | | ✓ |
| Param parsing | | ✓ |
| Controllers | ✓ | ✓ |
| Resource controllers | | ✓ |
| File naming | users_controller.js | usersController.coffee |
| vm.runInCustomContext | ✓ | |
| Asset pipeline | | ✓ |
| Asset compression | | ✓ |
| Routing | map.resources('posts') | @resources 'posts' |
| Nested routes | ✓ | ✓ |
| Generated url helpers | ✓ | |
| Generators | ✓ | ✓ |
| Command-line api | ✓ | ✓ |
| REPL (console) | ✓ | ✓ |
| CoffeeScript console | | ✓ |
| Asset cache method | timestamp | md5 hash |
| Production asset path | /app.css?123123123 | /app-859c828c89288hc8918741.css |
| Preferred Language | JavaScript | CoffeeScript |
| CoffeeScript support | ✓ | ✓ |
| Internationalization | ✓ | ✓ |
| Heroku support | ✓ | ✓ |
| String case | snake_case | camelCase |
| Form builder | ✓ | ✓ |
| Semantic form builder | | ✓ |
| Table builer | | ✓ |
| File watcher API | | ✓ |
| Live-reload assets | | ✓ |
| Test suite | | ✓ |
| Generators for tests | | ✓ |
| Twitter Bootstrap | ✓ | ✓ |
| HTML5 Boilerplate | | ✓ |
+-----------------------+------------------------------+------------------------------------+
I created Tower.js to achieve several goals which none of the existing frameworks did adequately. Here are some of those goals.
Since Node.js made JavaScript possible on the server, there's no reason to be writing one part of the app in Rails, and the other in Backbone. That's anything but DRY. You should be able to define the models once and use them on both the client and the server.
RailwayJS only works on the server because it was built around express. Tower.js is also built around express but in a way that makes it work for both the client and server. Tower.js provides the same exact API for the client and server. This meant I had to rewrite some things like the router so it works the same on the client and the server (plus it allows you to do things like history.pushState with the # fallback, using the same set of routes).
I spent a lot of time in Rails and writing Haml templates. Alongside I was writing web and mobile JavaScript interfaces using template languages like Mustache. That's more code duplication… You should be able to use the same set of views/templates on both the client (as JavaScript templates) and server (rendering static HTML).
Since Haml was pretty awesome (super clean, allowed you to execute arbitrary ruby, built in pretty-printing, etc.), the closest JavaScript alternative was CoffeeKup. And it works on both the client and server. CoffeeKup allows you to write templates with all the power of JavaScript, so you have no limitations. Building a FormBuilder in Mustache is either going to take a lot of work or a lot of code, or both.
Do note though, you're free to swap out template engines and use Jade, Mustache, Handlebars, etc. for the client or server. CoffeeKup is just a clean and powerful default.
ActiveModel (implemented by ActiveRecord for SQL and Mongoid for MongoDB for Rails) is a very thorough and well-tested API allowing developers to define and interact with data. It's both powerful and enjoyable. All of the previous (and current) JavaScript implementations were never close to as robust and well designed, and I didn't see anything happening in the near future.
If you can write this in Rails:
User.where(:email => /[a-z/).page(2).limit(20)
App.User.where(email: /[a-z/).page(2).limit(20)
User.validatesUniquenessOf "email" 与 User.validates "email", presence: true )。其次,它没有 Rails 3 那样丰富的可链接查询。第三,我希望能够快速地将代码添加到代码库中,而且由于我非常挑剔,我可能最终会重构整个事情以使用 CoffeeScript,哈哈。而且我不想围绕它构建一个层,因为它也必须在客户端上工作,因此保持库架构尽可能小是一个高优先级。class App.UsersController extends App.ApplicationController
@param "email"
index: ->
App.User.where(@criteria()).all (error, users) =>
@respondTo (format) =>
format.json => @render json: users
format.html => @render "index", locals: {users}
/users?email=abc&something=random 的网址,然后 @criteria()会给你一个哈希{email: /abc/} .rake assets:precompile您的 Assets ,您将获得为 S3 准备的 md5 哈希压缩 Assets 。自己构建起来非常困难,而且我没有看到有人为 Node.js 做这方面的工作。/stylesheets/application-51e687ad72175b5629f3b1538b65ea2c.css
/stylesheets/application.css?1306993455524
Expires标题并且您更改了 CSS,之前访问过您网站的任何人都必须清除其缓存或强制刷新您的页面才能看到更新。关于node.js - RailJS 与 TowerJS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9897017/
我开始了一个新的Rails3.2.5项目,Assets管道不再工作了。CSS和Javascript文件不再编译。这是尝试生成Assets时日志的输出:StartedGET"/assets/application.css?body=1"for127.0.0.1at2012-06-1623:59:11-0700Servedasset/application.css-200OK(0ms)[2012-06-1623:59:11]ERRORNoMethodError:undefinedmethod`each'fornil:NilClass/Users/greg/.rbenv/versions/1
rails新手。只是想了解\assests目录中的这两个文件。例如,application.js文件有如下行://=requirejquery//=requirejquery_ujs//=require_tree.我理解require_tree。只是将所有JS文件添加到当前目录中。根据上下文,我可以看出requirejquery添加了jQuery库。但是它从哪里得到这些jQuery库呢?我没有在我的Assets文件夹中看到任何jquery.js文件——或者直接在我的整个应用程序中没有看到任何jquery.js文件?同样,我正在按照一些说明安装TwitterBootstrap(http:
我有一个包含多个组件的存储库,其中大部分是用JavaScript(Node.js)编写的,一个是用Ruby(RubyonRails)编写的。我想要一个.travis.yml文件来触发一个运行每个组件的所有测试的构建。根据thisTravisCIGoogleGroupthread,目前还没有官方支持。我的目录结构是这样的:.├──构建服务器├──核心├──扩展├──网络应用├──流浪文件├──package.json├──.travis.yml└──生成文件我希望能够运行特定版本的Ruby(2.2.2)和Node.js(0.12.2)。我已经有了一个make目标,所以maketest在每
在安装了openssllib的linux机器上,当您执行带有“-nodes”选项的“opensslpkcs12”时,您将获得带有未加密私钥的输出,但如果您跳过–nodes选项,则输出将具有加密的私钥。e.g.opensslpkcs12-intest.pfx-outtest.pem你应该看到像下面这样加密的私钥-----BEGINENCRYPTEDPRIVATEKEY-----MIIFDjBABgkqhkiGG7s=-----ENDENCRYPTEDPRIVATEKEY-----如何使用ruby的开放ssl库实现上述目标?这就是我用ruby生成私钥的方式:@private_key
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visitthehelpcenter指导。关闭9年前。多年来,我一直在使用多种语言进行编程,并且认为自己总体上相当擅长。但是,我从未编写过任何自动化测试:没有单元测试,没有TDD,没有BDD,什么都没有。我已经尝试开始为我的项目编写适当的测试套件。我可以看到在进行任何更改后能够自动测试项目中所有代码的理论值(value)。我可以看到像RSpec和Mocha这样的测试框架应该如何使设置和运行所述测试变得相当容易
我需要一些指导来了解如何将Angular整合到rails中。选择Rails的原因:我喜欢他们偏执的做事方式。还有迁移,gem真的很酷。使用angular的原因:我正在研究和寻找最适合SPA的框架。Backbone似乎太抽象了。我不得不在Angular和Ember之间做出选择。我首先开始阅读Angular,它对我来说很有意义。所以我从来没有去读过关于ember的文章。使用Angular和Rails的原因:我研究并尝试使用小型框架,例如grape、slim(是的,我也使用php)。但我觉得需要坚持项目的长期范围。我个人喜欢用Rails的方式做事。这就是我需要帮助的地方,我在Rails4中有
目标:我想从动画GIF中抓取最佳帧并将其用作静态预览图像。我相信最好的帧是显示最多内容的帧-不一定是第一帧或最后一帧。以这张动图为例:--这是第一帧:--这是第28帧:很明显,第28帧很好地代表了整个GIF。我如何以编程方式确定一帧是否比另一帧具有更多像素/内容?如果您能向我指出任何想法、想法、包/模块或文章,我们将不胜感激。 最佳答案 实现此目的的一种直接方法是估计entropy每个图像的帧,并选择具有最大熵的帧。在信息论中,熵可以被认为是图像的“随机性”。单一颜色的图像是非常可预测的,分布越平坦,越随机。这与Arthur-R描述
我正在尝试在一个新元素中测试less.js。我100%确定javascript文件加载正常,但我的css文件夹中的less文件一直出现此错误。我打算在启动之前使用less.app编译它,但我宁愿让less.js在开发期间进行编译。由于它是.less或其他文件而不允许浏览器访问该文件是否存在问题?谢谢(运行ubuntu11.04和rubyv1.9.2,在firefox和chrome中同样的错误)这是我的head.haml文件,我在其中链接到less.js和app.less(它们都在正确的文件夹中)%link{:rel=>"stylesheet/less",:type=>"text/c
我在让asseticsass过滤器与node-sass而不是ruby替代品一起工作时遇到了一些困难。我的config.yml文件中有以下配置:assetic:debug:"%kernel.debug%"use_controller:falsebundles:[]write-to:"%kernel.root_dir%/../web/assets"read_from:"%kernel.root_dir%/../web/assets"node:"%%PROGRAMFILES%%\nodejs\\node.exe"node_paths:["%%USERPROFILE%%\\AppData\
我正在OSX10.13.4上使用Rails3.2.22.4、Ruby2.2.7开发一个应用程序。有多个翻译文件,例如。en.yml,sq.yml基于国家。从下面的rubymine执行命令时,加载网页时出现错误。rake--tracei18n:js:export来自en.yml的yaml内容已经过验证并且是正确的。从文件中删除后引发错误的特定行将在其他一些.yml文件中给出错误。正在使用当前版本的gemi18n(0.9.5)。Rails服务器启动但加载Web应用程序第一页时因同样的错误而中断。代码遇到i18n翻译代码时抛出错误,当错误从一个文件转移到另一个文件时,yml格式不是问题。