顯示具有 Ruby on Rails 標籤的文章。 顯示所有文章
顯示具有 Ruby on Rails 標籤的文章。 顯示所有文章

2009年6月8日 星期一

[RoR] 好用的自動連結方法 auto_link

auto_link(text, *args, &block)

Turns all URLs and e-mail addresses into clickable links.
自動將網址或是E-mail轉成超連結

You can add HTML attributes to the links using :href_options.
你可以用:href_options來加入HTML 的超連結屬性

:href_options => { :target => '_blank' }

The :link option will limit what should be linked.
Possible values for :link are :all (default), :email_addresses, and :urls.
:link可以限制只有網址或是E-mail成為連結

If a block is given, each URL and e-mail address is yielded and the result is used as the link text.

Examples
ActionView::Helpers::TextHelper

[RoR]表單相關方法

----------------------------------
ActionView::Helpers::FormHelper

Methods

2009年6月2日 星期二

[RoR]We're sorry, but something went wrong.

今天只是要用Ruby on Rails試寫一個Ajax的小功能,沒想到一直出錯給我看,害我懷疑我設定錯誤還是啥的。

We're sorry, but something went wrong.
We've been notified about this issue and we'll take a look at it shortly.

結果原來是Ruby on Rails沒有辦法在沒配置Database Engine的情形下跑。

解決方法就是:安裝資料庫

MySQL:htp://www.mysql.org
SQLite:http://www.sqlite.org

使用Rails建立專案時預設是用SQLite3,如果你想用MySQL,建立專案時請加上-d mysql

C:\> rails project_name -d mysql

然後再到config/database.yml設定密碼即可。
當然你也可以用其他的資料庫:
  • MySQL
  • PostgreSQL
  • SQLite
  • IBM DB2
  • Microsoft SQL Server
  • Oracle
  • Sybase
  • Firebird

2009年5月28日 星期四

[RoR] 相關資源網站整理


Ruby is…

A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.

Ruby Programming Language
http://www.ruby-lang.org

Try Ruby! in your browser
http://tryruby.hobix.com/

Ruby-Doc
- Help and documentation for the Ruby programming language.
http://www.ruby-doc.org/

RDoc
- Documentation from Ruby Source Files
http://rdoc.sourceforge.net/

Ruby-Forum
http://www.ruby-forum.com/

RubyForge is a home for open source Ruby projects
https://rubyforge.org/

Rubular - a Ruby regular expression editor
http://www.rubular.com/

RMagick - Graphics Processing for Ruby and Ruby on Rails
http://rmagick.rubyforge.org/

REXML: Processing XML in Ruby
http://www.xml.com/pub/a/2005/11/09/rexml-processing-xml-in-ruby.html

JSON implementation for Ruby
http://json.rubyforge.org/

MySQL API Module for Ruby
http://www.tmtm.org/en/mysql/ruby/

Ruby on Rails
http://rubyonrails.org/

Rails Framework Documentation
http://api.rubyonrails.org/

Railscasts - Free Ruby on Rails Screencasts
http://railscasts.com/

Crossing borders: Ajax on Rails
http://www.ibm.com/developerworks/java/library/j-cb12056/?S_TACT=105AGX52&S_CMP=cn-a-j

2008年8月6日 星期三

Ruby on Rails : Step by Step建立線上書籤

跟著iThome Online的一篇文章:Step By Step建立線上書籤,體驗一下Ruby on Rails,不過他的過程有些似乎沒講很清楚或是錯誤,所以做個更正筆記。

Step 1. 安裝Rails
gem install rails--include-dependencies

Step 2. 建立專案(預設是SQLLite,所以要自行指定資料庫,也可以直接打rails看詳細指令用法)
rails bookmarker -d mysql

Step 6. 使用Migration 建立資料表
rake migrate 會有錯誤,改用 rake db:migrate

Step 7. 使用Scaffold方法 產生頁面
bookmark_controller.rb在.\app\controllers

Step 8. 啟動內建伺服器
ruby script\server

用瀏覽器開啟http://localhost:3000/bookmark/
會出現以下錯誤:
undefined method `scaffold' for BookmarkController:Class
undefined method `paginate' for #

要另外安裝scaffold跟paginate,因為Ruby把它視為plug-in
參考「這篇

ruby script/plugin install scaffolding

ruby script/plugin install http://tools.assembla.com/svn/breakout/breakout/vendor/plugins/classic_pagination/


Step 10. 透過Scaffold 產生程式碼 (原文多一個bookmark)
Ruby script/generate scaffold bookmark


CRUD - Create, Read, Update, Delete


Related Posts Plugin for WordPress, Blogger...