使用emacs在rails应用程序上开发ruby的提示和技巧

时间:2010-03-11 23:17:35

标签: ruby-on-rails emacs

有哪些最佳模式,配置设置或任何能够更好地在emacs上开发ruby on rails应用程序。

4 个答案:

答案 0 :(得分:29)

你应该尝试所有的RoR并选择你最喜欢的那个。

首先,您应该使用ECB,ruby-mode,emacs-rails和其他一些内容查看Marshall Vandegrift的excellent screencast。它让你对Emacs上写RoR的酷感很好。

总之,这里有一些你应该尝试的模式:

  • Rinari - 一个简单的框架,用于绕过代码,运行测试,管理控制台,Web服务器等。它是简约的,围绕着一系列键绑定。
  • Emacs-rails - Emacs RoR模式的祖父。它暂时没有更新,事实上主要主页不再存在。但它非常强大,几乎可以让你做任何事情。
  • Emacs-rails-reloaded - 这是对原始emacs-rails的重新设计,我相信同一个人。它使用了很棒的anything模式来帮助您找到并绕过。我目前正在使用这个AND rinari。

以下是一些有用的其他模式:

  • ECB - Emacs代码浏览器。用它来进行项目管理,并绕过你的代码。
  • Yasnippet - 提供各种有用的片段,使用TAB键自动插入。
  • Nxhtml - 用于编辑rhtml,erb等

您可以尝试更多模式:

  • Ri - 用于查看内联的ri文档。
  • Flymake-ruby - 即时语法检查。
  • Ri - 查看ri文档

哦,当然你需要ruby-mode,它带有ruby源,由Matz自己维护。

希望这有帮助

答案 1 :(得分:6)

rspec-mode(轻松运行单个或多个规格)

js2-mode(JavaScript语法高亮显示)

ido(快速查找项目中的文件/缓冲区)

答案 2 :(得分:4)

由于我是rails(和emacs)的新手,我不想马上使用rinari。我发现,如果一个工具对我来说太过神奇,我就不会像我想的那样快速地学习细节。我想我最终会用它。但是现在,我设置了一堆shell,我在emacs中为RAILS 3生成,只是在它们之间切换以完成我的工作。我用tmr作为前缀,以便我可以轻松找到它们。

   (defun tmr-spork-shell ()
      "Invoke spork shell" ; Spork - love that name
      (interactive)
      (pop-to-buffer (get-buffer-create (generate-new-buffer-name "spork")))
      (shell (current-buffer))
      (process-send-string nil "cd .\n"); makes sure rvm variables set with .rvmrc
      (process-send-string nil "spork\n"))

    (defun tmr-devlog-shell ()
      "Tail the development log, shell"
      (interactive)
      (pop-to-buffer (get-buffer-create (generate-new-buffer-name "devlog")))
      (shell (current-buffer))
      (process-send-string nil "cd .\n"); makes sure rvm variables set with .rvmrc
      (process-send-string nil "tail -f log/development.log\n"))

    (defun tmr-testlog-shell ()
      "Tail the test log, shell"
      (interactive)
      (pop-to-buffer (get-buffer-create (generate-new-buffer-name "testlog")))
      (shell (current-buffer))
      (process-send-string nil "cd .\n"); makes sure rvm variables set with .rvmrc
      (process-send-string nil "tail -f log/test.log\n"))

    (defun tmr-server-shell ()
      "Invoke rails ui server shell"
      (interactive)
      (pop-to-buffer (get-buffer-create (generate-new-buffer-name "server")))
      (shell (current-buffer))
      (process-send-string nil "cd .\n"); makes sure rvm variables set with .rvmrc
      (process-send-string nil "rails s\n"))

    (defun tmr-db-shell ()
      "Invoke rails dbconsole shell"
      (interactive)
      (pop-to-buffer (get-buffer-create (generate-new-buffer-name "dbconsole")))
      (shell (current-buffer))
      (process-send-string nil "cd .\n"); makes sure rvm variables set with .rvmrc
      (process-send-string nil "rails dbconsole\n"))

    (defun tmr-console-shell ()
      "Invoke rails console shell"
      (interactive)
      (pop-to-buffer (get-buffer-create (generate-new-buffer-name "console")))
      (shell (current-buffer))
      (process-send-string nil "cd .\n"); makes sure rvm variables set with .rvmrc
      (process-send-string nil "rails console\n"))

    ; I like to run all my tests in the same shell
    (defun tmr-rspec-shell ()
      "Invoke rspec shell"
      (interactive)
      (pop-to-buffer (get-buffer-create (generate-new-buffer-name "rspec")))
      (shell (current-buffer))
      (process-send-string nil "cd .\n"); makes sure rvm variables set with .rvmrc
      (process-send-string nil "rspec spec\n")) ; This is debatable, since spork wont be up yet

    ; The shell where I do most of my work
    (defun tmr-shell ()
      "Invoke plain old shell"
      (interactive)
      (pop-to-buffer (get-buffer-create (generate-new-buffer-name "sh")))
      (shell (current-buffer))
      (process-send-string nil "cd .\n")); makes sure rvm variables set with .rvmrc

    ; My everyday ide
    (defun tmr-ide-lite ()
      "Spawn several shells for a mini Rails IDE"
      (interactive)
      (progn (tmr-spork-shell)
             (tmr-shell)
             (tmr-server-shell)
             (tmr-rspec-shell)))

    ; When I am doing a big debug session
    (defun tmr-ide-full ()
      "Spawn several shells for a full Rails IDE"
      (interactive)
      (progn (tmr-spork-shell)
             (tmr-shell)
             (tmr-server-shell)
             (tmr-console-shell)
             (tmr-db-shell)
             (tmr-devlog-shell)
             (tmr-testlog-shell)
             (tmr-rspec-shell)))

答案 3 :(得分:3)

我觉得有用的另一种模式是web-mode。它对于编写视图很有用,并且可以很好地处理.html.erb文件。它具有语法高亮和标签完成等功能。您可以在here找到它。