阅读更多

9顶
1踩

编程语言

原创新闻 DHH发表《破除Rails迷思》系列之三

2008-11-16 22:38 by 见习编辑 robbin 评论(1) 有5782人浏览
Rails创始人DHH首次回应Zed Shaw对Rails的抨击新闻当中,我们介绍了Rails创始人DHH最近开始撰写关于围绕Rails话题的一个系列文章,意在对围绕Rails周围的种种置疑和争议给出一个私人的看法,希望消除对Rails的一些不正确的看法。这个系列现在DHH已经写了五篇,分别是:

http://www.loudthinking.com/posts/29-the-rails-myths

DHH 写道
    * Myth #1: Rails is hard to deploy
    * Myth #2: Rails is expected to crash 400 times/day
    * Myth #3: Rails forces you to use Prototype
    * Myth #4: Rails is a monolith
    * Myth #5: Rails is hard because of Ruby


在前面新闻当中我们已经介绍了前两篇,在本文当中我们继续介绍接下来的三篇:

三、Rails强迫你使用prototype JavaScript库吗?

事实并非如此,如果你想用JQuery其实也很容易。首先加载jquery库:

<%= javascript_include_tag "jquery", "jquery-ui" %>


假设有这样一个html form:

<% form_for(Comment.new) do |form| %>
  <%= form.text_area :body %>
  <%= form.submit %>
<% end %>


使用jquery去操作他很简单:

$(document).ready(function() {
  $("#new_comment").submit(function() {
    $.post($(this).attr('action') + '.js', 
      $(this).serializeArray(), null, 'script');
    return false;
  });
});


在服务器端响应代码:

def create
  @comment = Post.create(params[:comment])
  respond_to do |format|
    format.html { redirect_to(@comment) }
    format.js
  end
end


对于返回的format.js,可以这样:

$('#comments').append('<%= escape_javascript(render(:partial => @comment)) %>');
$('#new_comment textarea').val("");
$('#<%= dom_id(@comment) %>').effect("highlight");


这个例子告诉我们,在Rails当中使用jquery其实非常简单,Rails喜爱所有的AJAX库,而不仅仅是prototype。此外你还可以使用一些Rails的插件,让jquery和mtools可以和Rails集成的更加紧密,例如jRails项目。

9
1
评论 共 1 条 请登录后发表评论
1 楼 liusong1111 2008-11-17 15:24
http://merbist.com/2008/11/15/rails-vs-merb-drama/

DHH不止针对Zed,看看Merb社区的反应:

http://merbist.com/2008/11/15/rails-vs-merb-drama/

    * part 3:

At this point, DHH already started addressing some of the reproaches the Merb community has brought on Rails. Interesting enough, DHH carefully never mentions Merb though. However just after wycats/Yehuda’s post, DHH releases a post entitled: Rails is a monolith. In his post, DHH calls LOC comparison an “inverse dick measurement match”. He goes even further and gives the size of some of Rails’ components, mentions that there is a way in Rails to remove parts you don’t want but that anyway “Why would you bother? And that’s an answer I [DHH] don’t quite have for you.”

    * part 4 (I told you it was a real drama)

Yehuda considers that even though, DHH didn’t mention him or Merb, “they” means the Merb community. Unfortunately, DHH doesn’t allow comments on his site so Yehuda decides to write yet another blog post. In his post, Yehuda deconstructs DHH arguments and tries to explain the philosphical difference between the two frameworks.

发表评论

您还没有登录,请您登录后再发表评论

相关推荐

  • dw相对路径怎么改_用Dreamweaver写asp网站链接ACCESS数据库 绝对路径和相对路径转换...

    例如本人的一个客户配置绝对路径如下:' FileName="Connection_ado_conn_string.htm"' Type="ADO"' DesigntimeType="ADO"' HTTP="false"' Catalog=""' Schema=""Dim MM_conn_STRINGMM_conn_STRING = "dbq=d:\wwwroot\db\db.mdb;driver=...

  • ASP.NET 中得到网站绝对路径的几种方法

    在编写 ASP.NET 应用程序的时候,有时为了更好地进行控制静态文件的路径,如在模板页或者用户控件中设置js或者css文件的路径等,采用绝对路径是难免的。下面就是几种获取绝对路径的几种方法。   VirtualPathUtility.ToAbsolute(&quot;~/&quot;) HttpRuntime.AppDomainAppVirtualPath Request.ApplicationPath...

  • asp.net 获取当前,相对,绝对路径

    一、C#获取当前路径的方法: System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName -获取模块的完整路径。 System.Environment.CurrentDirectory -获取和设置当前目录(该进程从中启动的目录)的完全限定目录。 System.IO.Directory.GetCurrentDire...

  • asp.net获取网站路径

    网站在服务器磁盘上的物理路径: HttpRuntime.AppDomainAppPath 虚拟程序路径: HttpRuntime.AppDomainAppVirtualPath 任何于Reques...

  • asp.net绝对与相对路径

    对于asp.net 路径的问题,闲心有很多人和我一样,只是知道一点,理解并不深刻。下面我就来整理一下相路径和绝对路径的知识。 绝对路径: 每个网页都有一个唯一的地址,它就是该网页的绝对路径。绝对路径提供所链接文档的完整URL,而且包括所使用的协议(例如对于网页,通常使用HTTP)。例如上面的第一种写法就是一个绝对路径(虽然是一个不存在的地址)。 必须使用绝对路径才能链接到其他服务器上的文档。...

  • 在ASP中实现通用的绝对路径生成方法 (转)

    在ASP中实现通用的绝对路径生成方法 (转)[@more@]主页: .NET"&gt;www.maxss.net邮件: Mailto:maxchou@163.com"&gt;maxchou@163.com   在我...

  • Asp相对路径转换为绝对路径函数

    ================================================ 函数名:ChkMapPath 作  用:相对路径转换为绝对路径 参  数:strPath ----原路径 返回值:绝对路径================================================Function ChkMapPath(ByVal strPath)

  • C# ,asp.net 获取当前,相对,绝对路径

    一、C#获取当前路径的方法:1. System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName-获取模块的完整路径。2. System.Environment.CurrentDirectory-获取和设置当前目录(该进程从中启动的目录)的完全限定目录。3. System.IO.Directory.GetCurrentDirect

  • asp中的相对路径

    1、资源(图片、文件、网页等)的绝对路径:资源在磁盘中的位置。例:@&quot;D:\系统文件\destbook\test.xls&quot; 2、资源的相对路径指的是:该资源相对于你当前文件路径的路径。  所以不同位置的文件引用同一资源时,写的相对路径是不同的。  相对路径符号及如何用:/:根目录下          ./:该目录下           ../:该目录的上一层目录下          ../....

  • [Asp.net]绝对路径和相对路径

    目录 绝对路径 相对路径 总结 绝对路径 绝对路径就是你的主页上的文件或目录在硬盘上真正的路径。比如:E:\新概念英语\新版新概念英语第二册课文PDF.pdf。以Web 站点根目录为参考基础的目录路径。之所以称为绝对,意指当所有网页引用同一个文件时,所使用的路径都是一样的。 1 &quot;/&quot; -- 代表根目录,绝对路径。 2 如:&amp;lt;a href=&quot;/abc&quot;&amp;gt;文本&amp;lt;...

  • asp创建文件夹,创建路径

       推荐一个建立文件夹的函数吧:Sub CreateFolder(strFolder)    首选判断要建立的文件夹是否已经存在    Dim strTestFolder, objFSO    strTestFolder = Server.Mappath(strFolder)    Set objFSO = CreateObject("Scripting.FileSystemObje

Global site tag (gtag.js) - Google Analytics