2008年12月24日 星期三
rails default mode
一般如果只有用
bin/count_ad_render_num.rb 就是在 development mode
要在production 就要特別指定
bin/count_ad_render_num.rb -e production
bin/count_ad_render_num.rb 就是在 development mode
要在production 就要特別指定
bin/count_ad_render_num.rb -e production
標籤:
rails set mode
rails default mode
一般如果只有用
bin/count_ad_render_num.rb 就是在 development mode
要在production 就要特別指定
bin/count_ad_render_num.rb -e production
bin/count_ad_render_num.rb 就是在 development mode
要在production 就要特別指定
bin/count_ad_render_num.rb -e production
標籤:
rails set mode
2008年12月23日 星期二
2008年12月19日 星期五
Gem dependencies
Gem dependencies
What is new :Gem Dependencies
把application 需要的gem 可以直接寫在設定檔裡, 綁在app 上
不過我在2.2 想用, 卻爆了看起來應該是這個問題 Handle missing dependencies in gem loading
不過現在有點懶之後再用 orz
What is new :Gem Dependencies
把application 需要的gem 可以直接寫在設定檔裡, 綁在app 上
不過我在2.2 想用, 卻爆了看起來應該是這個問題 Handle missing dependencies in gem loading
不過現在有點懶之後再用 orz
標籤:
Gem dependencies
Gem dependencies
Gem dependencies
What is new :Gem Dependencies
把application 需要的gem 可以直接寫在設定檔裡, 綁在app 上
不過我在2.2 想用, 卻爆了看起來應該是這個問題 Handle missing dependencies in gem loading
不過現在有點懶之後再用 orz
What is new :Gem Dependencies
把application 需要的gem 可以直接寫在設定檔裡, 綁在app 上
不過我在2.2 想用, 卻爆了看起來應該是這個問題 Handle missing dependencies in gem loading
不過現在有點懶之後再用 orz
標籤:
Gem dependencies
liquid,dynamic content
railscast liquid
liquid
liquid wiki
如果想要動態去編輯網頁上的 content 傳些變數進去, 就是需要這個, 什麼意思勒
就是例如我是admin, 我想要編輯公告時, 傳些人名的參數進去, 可是不想要改 code, 想要直接改db的內容就好, 就可以用這個,
liquid
liquid wiki
如果想要動態去編輯網頁上的 content 傳些變數進去, 就是需要這個, 什麼意思勒
就是例如我是admin, 我想要編輯公告時, 傳些人名的參數進去, 可是不想要改 code, 想要直接改db的內容就好, 就可以用這個,
標籤:
dynamic content,
liquid
liquid,dynamic content
railscast liquid
liquid
liquid wiki
如果想要動態去編輯網頁上的 content 傳些變數進去, 就是需要這個, 什麼意思勒
就是例如我是admin, 我想要編輯公告時, 傳些人名的參數進去, 可是不想要改 code, 想要直接改db的內容就好, 就可以用這個,
liquid
liquid wiki
如果想要動態去編輯網頁上的 content 傳些變數進去, 就是需要這個, 什麼意思勒
就是例如我是admin, 我想要編輯公告時, 傳些人名的參數進去, 可是不想要改 code, 想要直接改db的內容就好, 就可以用這個,
標籤:
dynamic content,
liquid
2008年12月18日 星期四
rails 2.2 extra, delegate,gem
9.3. Delegates With Prefixes
還有一堆玩具
#
past?, today? and future? for Date and Time classes to facilitate date/time comparisons.
#
Array#second through Array#tenth as aliases for Array#[1] through Array#[9]
#
Enumerable#many? to encapsulate collection.size > 1
#
Inflector#parameterize produces a URL-ready version of its input, for use in to_param.
#
Time#advance recognizes fractional days and weeks, so you can do 1.7.weeks.ago, 1.5.hours.since, and so on.
10.1. config.gems
To avoid deployment issues and make Rails applications more self-contained, it's possible to place copies of all of the gems that your Rails application requires in /vendor/gems
*
config.gem gem_name in your config/environment.rb file
*
rake gems to list all configured gems, as well as whether they (and their dependencies) are installed or frozen
*
rake gems:install to install missing gems to the computer
*
rake gems:unpack to place a copy of the required gems into /vendor/gems
*
rake gems:unpack:dependencies to get copies of the required gems and their dependencies into /vendor/gems
*
rake gems:build to build any missing native extensions
*
rake gems:refresh_specs to bring vendored gems created with Rails 2.1 into alignment with the Rails 2.2 way of storing them
You can unpack or install a single gem by specifying GEM=gem_name
還有一堆玩具
#
past?, today? and future? for Date and Time classes to facilitate date/time comparisons.
#
Array#second through Array#tenth as aliases for Array#[1] through Array#[9]
#
Enumerable#many? to encapsulate collection.size > 1
#
Inflector#parameterize produces a URL-ready version of its input, for use in to_param.
#
Time#advance recognizes fractional days and weeks, so you can do 1.7.weeks.ago, 1.5.hours.since, and so on.
10.1. config.gems
To avoid deployment issues and make Rails applications more self-contained, it's possible to place copies of all of the gems that your Rails application requires in /vendor/gems
*
config.gem gem_name in your config/environment.rb file
*
rake gems to list all configured gems, as well as whether they (and their dependencies) are installed or frozen
*
rake gems:install to install missing gems to the computer
*
rake gems:unpack to place a copy of the required gems into /vendor/gems
*
rake gems:unpack:dependencies to get copies of the required gems and their dependencies into /vendor/gems
*
rake gems:build to build any missing native extensions
*
rake gems:refresh_specs to bring vendored gems created with Rails 2.1 into alignment with the Rails 2.2 way of storing them
You can unpack or install a single gem by specifying GEM=gem_name
rails 2.2 extra, delegate,gem
9.3. Delegates With Prefixes
還有一堆玩具
#
past?, today? and future? for Date and Time classes to facilitate date/time comparisons.
#
Array#second through Array#tenth as aliases for Array#[1] through Array#[9]
#
Enumerable#many? to encapsulate collection.size > 1
#
Inflector#parameterize produces a URL-ready version of its input, for use in to_param.
#
Time#advance recognizes fractional days and weeks, so you can do 1.7.weeks.ago, 1.5.hours.since, and so on.
10.1. config.gems
To avoid deployment issues and make Rails applications more self-contained, it's possible to place copies of all of the gems that your Rails application requires in /vendor/gems
*
config.gem gem_name in your config/environment.rb file
*
rake gems to list all configured gems, as well as whether they (and their dependencies) are installed or frozen
*
rake gems:install to install missing gems to the computer
*
rake gems:unpack to place a copy of the required gems into /vendor/gems
*
rake gems:unpack:dependencies to get copies of the required gems and their dependencies into /vendor/gems
*
rake gems:build to build any missing native extensions
*
rake gems:refresh_specs to bring vendored gems created with Rails 2.1 into alignment with the Rails 2.2 way of storing them
You can unpack or install a single gem by specifying GEM=gem_name
還有一堆玩具
#
past?, today? and future? for Date and Time classes to facilitate date/time comparisons.
#
Array#second through Array#tenth as aliases for Array#[1] through Array#[9]
#
Enumerable#many? to encapsulate collection.size > 1
#
Inflector#parameterize produces a URL-ready version of its input, for use in to_param.
#
Time#advance recognizes fractional days and weeks, so you can do 1.7.weeks.ago, 1.5.hours.since, and so on.
10.1. config.gems
To avoid deployment issues and make Rails applications more self-contained, it's possible to place copies of all of the gems that your Rails application requires in /vendor/gems
*
config.gem gem_name in your config/environment.rb file
*
rake gems to list all configured gems, as well as whether they (and their dependencies) are installed or frozen
*
rake gems:install to install missing gems to the computer
*
rake gems:unpack to place a copy of the required gems into /vendor/gems
*
rake gems:unpack:dependencies to get copies of the required gems and their dependencies into /vendor/gems
*
rake gems:build to build any missing native extensions
*
rake gems:refresh_specs to bring vendored gems created with Rails 2.1 into alignment with the Rails 2.2 way of storing them
You can unpack or install a single gem by specifying GEM=gem_name
each_with_object,inject
注意inject 和 each_with_object , hash 和 str 的參數位置是相反的,
而且inject 傳回去的是上次的結果, 所以要把那個 hsh 傳回去
而且inject 傳回去的是上次的結果, 所以要把那個 hsh 傳回去
標籤:
each_with_object,
inject
each_with_object,inject
注意inject 和 each_with_object , hash 和 str 的參數位置是相反的,
而且inject 傳回去的是上次的結果, 所以要把那個 hsh 傳回去
而且inject 傳回去的是上次的結果, 所以要把那個 hsh 傳回去
標籤:
each_with_object,
inject
header, redirect_to , render js, polymorphic_path
6.4. Other Action Controller Changes
HTTP Accept header 現在default 是 disable 啦, 想要打開要自己開
不然就是自己在生時後面要有type啦 像 url /customers/1.xml
redirect_to now fully supports URI schemes (so, for example, you can redirect to a svn+ssh: URI).
有js 參數可以用不用在自己設response.headers['Content-Type']='text/javascript'
render now supports a :js option to render plain vanilla javascript with the right mime type.
Polymorphic URLs behave more sensibly if a passed parameter is nil. For example, calling polymorphic_path([@project, @date, @area]) with a nil date will give you project_area_path
HTTP Accept header 現在default 是 disable 啦, 想要打開要自己開
不然就是自己在生時後面要有type啦 像 url /customers/1.xml
redirect_to now fully supports URI schemes (so, for example, you can redirect to a svn+ssh: URI).
有js 參數可以用不用在自己設response.headers['Content-Type']='text/javascript'
render now supports a :js option to render plain vanilla javascript with the right mime type.
Polymorphic URLs behave more sensibly if a passed parameter is nil. For example, calling polymorphic_path([@project, @date, @area]) with a nil date will give you project_area_path
header, redirect_to , render js, polymorphic_path
6.4. Other Action Controller Changes
HTTP Accept header 現在default 是 disable 啦, 想要打開要自己開
不然就是自己在生時後面要有type啦 像 url /customers/1.xml
redirect_to now fully supports URI schemes (so, for example, you can redirect to a svn+ssh: URI).
有js 參數可以用不用在自己設response.headers['Content-Type']='text/javascript'
render now supports a :js option to render plain vanilla javascript with the right mime type.
Polymorphic URLs behave more sensibly if a passed parameter is nil. For example, calling polymorphic_path([@project, @date, @area]) with a nil date will give you project_area_path
HTTP Accept header 現在default 是 disable 啦, 想要打開要自己開
不然就是自己在生時後面要有type啦 像 url /customers/1.xml
redirect_to now fully supports URI schemes (so, for example, you can redirect to a svn+ssh: URI).
有js 參數可以用不用在自己設response.headers['Content-Type']='text/javascript'
render now supports a :js option to render plain vanilla javascript with the right mime type.
Polymorphic URLs behave more sensibly if a passed parameter is nil. For example, calling polymorphic_path([@project, @date, @area]) with a nil date will give you project_area_path
Rescue from dispatching, layout mailer
Rescue from dispatching
人家這個sample 太好 不知道要講啥 XD
Mailer Layouts
default 他會找 layout 裡 加上 _mailer的, 像這邊就是會去找layouts/user_mailer.html.erb
當然也可以自己指定 layou
人家這個sample 太好 不知道要講啥 XD
Mailer Layouts
default 他會找 layout 裡 加上 _mailer的, 像這邊就是會去找layouts/user_mailer.html.erb
當然也可以自己指定 layou
Rescue from dispatching, layout mailer
Rescue from dispatching
人家這個sample 太好 不知道要講啥 XD
Mailer Layouts
default 他會找 layout 裡 加上 _mailer的, 像這邊就是會去找layouts/user_mailer.html.erb
當然也可以自己指定 layou
人家這個sample 太好 不知道要講啥 XD
Mailer Layouts
default 他會找 layout 裡 加上 _mailer的, 像這邊就是會去找layouts/user_mailer.html.erb
當然也可以自己指定 layou
Shallow Routes, Resources With Specific Actions
Shallow Routes
不過books_path 還是不能叫的
6.3 Resources With Specific Actions
現在你可以指定你想要生哪個 action 的 path, 要route哪些, 因為Rails 生這些東西也是要耗memory的, 而這些設定會被nested resource 繼承
不過books_path 還是不能叫的
6.3 Resources With Specific Actions
現在你可以指定你想要生哪個 action 的 path, 要route哪些, 因為Rails 生這些東西也是要耗memory的, 而這些設定會被nested resource 繼承
Shallow Routes, Resources With Specific Actions
Shallow Routes
不過books_path 還是不能叫的
6.3 Resources With Specific Actions
現在你可以指定你想要生哪個 action 的 path, 要route哪些, 因為Rails 生這些東西也是要耗memory的, 而這些設定會被nested resource 繼承
不過books_path 還是不能叫的
6.3 Resources With Specific Actions
現在你可以指定你想要生哪個 action 的 path, 要route哪些, 因為Rails 生這些東西也是要耗memory的, 而這些設定會被nested resource 繼承
etag,last_modified,Get
Even Better Conditional GET Support
rails 2.2 release note
至於 browser什麼時候會發etag, last_modified, 讓你看見 304勒
就是看browser啦, 如果是reload大部分就是不發 etag, last_modified 就是要你server一定要吐view了, 直接連才會, 而且post 是不發etag, last_modified的
應該吧...
rails 2.2 release note
至於 browser什麼時候會發etag, last_modified, 讓你看見 304勒
就是看browser啦, 如果是reload大部分就是不發 etag, last_modified 就是要你server一定要吐view了, 直接連才會, 而且post 是不發etag, last_modified的
應該吧...
標籤:
etag,
last_modified
etag,last_modified,Get
Even Better Conditional GET Support
rails 2.2 release note
至於 browser什麼時候會發etag, last_modified, 讓你看見 304勒
就是看browser啦, 如果是reload大部分就是不發 etag, last_modified 就是要你server一定要吐view了, 直接連才會, 而且post 是不發etag, last_modified的
應該吧...
rails 2.2 release note
至於 browser什麼時候會發etag, last_modified, 讓你看見 304勒
就是看browser啦, 如果是reload大部分就是不發 etag, last_modified 就是要你server一定要吐view了, 直接連才會, 而且post 是不發etag, last_modified的
應該吧...
標籤:
etag,
last_modified
alias_method_chain
alias_method_chain
alias_method A, B 有點就是 B 把function copy 一份到B
Encapsulates the common pattern of:
這就像是foo 沒改feature之前 copy 一份 所以叫做 foo_without_feature
然後弄了個function 叫做foo_with_feature 然後蓋掉 foo
之後叫foo 就是有feature的 foo_with_feature
With this, you simply do:
And both aliases are set up for you.
Query and bang methods (foo?, foo!) keep the same punctuation:
is equivalent to
so you can safely chain foo, foo?, and foo! with the same feature.
alias_method A, B 有點就是 B 把function copy 一份到B
Encapsulates the common pattern of:
這就像是foo 沒改feature之前 copy 一份 所以叫做 foo_without_feature
然後弄了個function 叫做foo_with_feature 然後蓋掉 foo
之後叫foo 就是有feature的 foo_with_feature
With this, you simply do:
And both aliases are set up for you.
Query and bang methods (foo?, foo!) keep the same punctuation:
is equivalent to
so you can safely chain foo, foo?, and foo! with the same feature.
alias_method_chain
alias_method_chain
alias_method A, B 有點就是 B 把function copy 一份到B
Encapsulates the common pattern of:
這就像是foo 沒改feature之前 copy 一份 所以叫做 foo_without_feature
然後弄了個function 叫做foo_with_feature 然後蓋掉 foo
之後叫foo 就是有feature的 foo_with_feature
With this, you simply do:
And both aliases are set up for you.
Query and bang methods (foo?, foo!) keep the same punctuation:
is equivalent to
so you can safely chain foo, foo?, and foo! with the same feature.
alias_method A, B 有點就是 B 把function copy 一份到B
Encapsulates the common pattern of:
這就像是foo 沒改feature之前 copy 一份 所以叫做 foo_without_feature
然後弄了個function 叫做foo_with_feature 然後蓋掉 foo
之後叫foo 就是有feature的 foo_with_feature
With this, you simply do:
And both aliases are set up for you.
Query and bang methods (foo?, foo!) keep the same punctuation:
is equivalent to
so you can safely chain foo, foo?, and foo! with the same feature.
2008年12月17日 星期三
join,include
mysql, 是沒有include 這種東西的
在rails 下join 如
rails 用join 就是用inner join 弄成一整個大的object, association 就沒了
用include 有的時候因為條件裡直接需要用到另個table 的條件, 是用left join 但仍維持 association 的關係
另外rails 2.2 可以把 join 寫的high 一點了
Easy Join Table Conditions
在rails 下join 如
rails 用join 就是用inner join 弄成一整個大的object, association 就沒了
用include 有的時候因為條件裡直接需要用到另個table 的條件, 是用left join 但仍維持 association 的關係
另外rails 2.2 可以把 join 寫的high 一點了
Easy Join Table Conditions
join,include
mysql, 是沒有include 這種東西的
在rails 下join 如
rails 用join 就是用inner join 弄成一整個大的object, association 就沒了
用include 有的時候因為條件裡直接需要用到另個table 的條件, 是用left join 但仍維持 association 的關係
另外rails 2.2 可以把 join 寫的high 一點了
Easy Join Table Conditions
在rails 下join 如
rails 用join 就是用inner join 弄成一整個大的object, association 就沒了
用include 有的時候因為條件裡直接需要用到另個table 的條件, 是用left join 但仍維持 association 的關係
另外rails 2.2 可以把 join 寫的high 一點了
Easy Join Table Conditions
Block in views, concat, capture, content_for,yield,content_tag
rails 2.2 block in view
block in view before
concat source code
其他學到的 concat, capture, yield,content_tag
concat
capture
yield, content_for
content_tag
block in view before
concat source code
其他學到的 concat, capture, yield,content_tag
concat
capture
yield, content_for
content_tag
標籤:
Block in views,
capture,
concat,
content_for,
content_tag,
yield
Block in views, concat, capture, content_for,yield,content_tag
rails 2.2 block in view
block in view before
concat source code
其他學到的 concat, capture, yield,content_tag
concat
capture
yield, content_for
content_tag
block in view before
concat source code
其他學到的 concat, capture, yield,content_tag
concat
capture
yield, content_for
content_tag
標籤:
Block in views,
capture,
concat,
content_for,
content_tag,
yield
2008年12月16日 星期二
rails I18n sample
railscast i18n
Rails 2.2.0 I18n 的使用筆記
一般的預設訊息可以到
http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale
下載
超簡單的步驟有
1. 把翻譯的那些yml檔放到, 想放的地方去, 教學都是放在 config/locales 下
2. 在application 做個 before_filter 設定
3. 重啟server, 讓他load 一下, 設定檔
model 本身和column name 也可以用這樣的方式去做i18n
Rails 2.2.0 I18n 的使用筆記
一般的預設訊息可以到
http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale
下載
超簡單的步驟有
1. 把翻譯的那些yml檔放到, 想放的地方去, 教學都是放在 config/locales 下
2. 在application 做個 before_filter 設定
3. 重啟server, 讓他load 一下, 設定檔
model 本身和column name 也可以用這樣的方式去做i18n
rails I18n sample
railscast i18n
Rails 2.2.0 I18n 的使用筆記
一般的預設訊息可以到
http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale
下載
超簡單的步驟有
1. 把翻譯的那些yml檔放到, 想放的地方去, 教學都是放在 config/locales 下
2. 在application 做個 before_filter 設定
3. 重啟server, 讓他load 一下, 設定檔
model 本身和column name 也可以用這樣的方式去做i18n
Rails 2.2.0 I18n 的使用筆記
一般的預設訊息可以到
http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale
下載
超簡單的步驟有
1. 把翻譯的那些yml檔放到, 想放的地方去, 教學都是放在 config/locales 下
2. 在application 做個 before_filter 設定
3. 重啟server, 讓他load 一下, 設定檔
model 本身和column name 也可以用這樣的方式去做i18n
2008年12月15日 星期一
2008年12月14日 星期日
2008年12月12日 星期五
swfobject,flash,swf
google code swfobject
Flash object attr
swfobject sample
update: 2009042
廣告追蹤常在用的clickTag 在flash7, 8 要換成clickTAG 才work
Flash object attr
swfobject sample
update: 2009042
廣告追蹤常在用的clickTag 在flash7, 8 要換成clickTAG 才work
看不懂等級的mysql random
http://blog.gslin.org/archives/2008/07/02/1535/
http://blog.xdite.net/?p=598
http://jan.kneschke.de/projects/mysql/order-by-rand
http://blog.xdite.net/?p=598
http://jan.kneschke.de/projects/mysql/order-by-rand
2008年12月11日 星期四
2008年12月10日 星期三
2008年12月9日 星期二
2008年12月8日 星期一
2008年12月7日 星期日
rails2.2.2 default error message
“ActiveRecord::Errors.default_error_messages”沒啦, 換成“I18n.translate(activerecord.errors.messages)”
2008年12月3日 星期三
2008年12月2日 星期二
2008年11月29日 星期六
2008年11月27日 星期四
A quick way to get memcached status
http://www.mysqlperformanceblog.com/2008/11/26/a-quick-way-to-get-memcached-status/
echo stats | nc 127.0.0.1 11211
watch "echo stats | nc 127.0.0.1 11211"
echo stats | nc 127.0.0.1 11211
watch "echo stats | nc 127.0.0.1 11211"
2008年11月26日 星期三
upload file in rails
http://www.tutorialspoint.com/ruby-on-rails/rails-file-uploading.htm
http://manuals.rubyonrails.com/read/chapter/79
http://manuals.rubyonrails.com/read/chapter/78
http://manuals.rubyonrails.com/read/chapter/77
http://www.practicalecommerce.com/blogs/post/432-Multiple-Attachments-in-Rails
http://izumi.plan99.net/blog/index.php/2007/04/07/ruby-on-railss-handling-of-uploaded-files/
http://manuals.rubyonrails.com/read/chapter/79
http://manuals.rubyonrails.com/read/chapter/78
http://manuals.rubyonrails.com/read/chapter/77
http://www.practicalecommerce.com/blogs/post/432-Multiple-Attachments-in-Rails
http://izumi.plan99.net/blog/index.php/2007/04/07/ruby-on-railss-handling-of-uploaded-files/
About the uploaded file object
While the uploaded file is a special beast,it is not difficult to use. The object
rails receives are processed by a CGI object. The object that CGI returns to Rails
isn’t actually a file object, but it’s close enough for our purposes.
Details from the CGI class documentation
... the value is not a string, but an IO object, either an IOString for small files,
or a Tempfile for larger ones.
This object also has the additional singleton methods:
local_path(): the path of the uploaded file on the local filesystem
original_filename(): the name of the file on the client computer
content_type(): the content type of the file
2008年11月25日 星期二
訂閱:
文章 (Atom)