2009年9月14日 星期一

git memo

github 不知道為為啥我複製出來的網址是https 的
所以跑出 remote HEAD refers to nonexistent ref, unable to checkout. 的錯誤

git clone git@github.com:ooxx 這樣的才對

2009年9月13日 星期日

Railscast skill(9)

Complex Partials
Rendering partials with layouts
view 重複的部份 不只是裡面 也有可能是外面, render 的參數也可以代layout
Partials can have their own layouts applied to them. These layouts are different than the ones that are specified globally
for the entire action, but they work in a similar fashion. Imagine a list with two types of users:


Customize Field Error
可以自訂error msg 的格式

2009年9月11日 星期五

Railscast skill(8)

Logging Variables

eval 執行後面的 ruby code
binding 可以把當時的環境存起來


The Logger
message 四個等級 debug, info , error, fatal
development default 是 debug, 表示debug 以上的都可以看到, mysql instruction message 是在debug mode 所以 production 看不到
production 是 info


YAML Configuration File

整理變數的好方法, 放在yml 裡, 還可以靠程式根據不同的環境load 進不同的變數

2009年9月10日 星期四

Railscast skill (7)

in_groups_of
定量分組時在用的


group_by Month
group_by 好棒, 想用啥分類就分

Railscast skill (6)

Restricting Access

helper_method 可以把某些controller 的method 弄到helper 一起用


Console Tricks

Handling Exceptions


Catch-all Route
可以利用這招把所有奇怪的route 路徑都拿去 在controller 裡面在做些有的沒的處理

Railscast skill (5)

Refactoring Out Helper Object

某些 method 需要很多其他的小 method 可是放在application helper 裡 又不是算大家都會用到的東西, 這時候就可以把它搬到外面弄成一個class,




Site Wide Announcements
又用了controller 的 javascripts 的技巧 不過這邊這個要注意一下 route 要加上format

2009年9月9日 星期三

Railscast skill (4)

Pretty Page Title

把content_for 弄簡潔了, yield 也要有default


Markaby in Helper
也可以在helper 裡用render :partial 或者是用content_tag 去拼view