<script type="text/javascript">
var global_function = null; <= 宣告在這裡才是global的
(function($){
function local_funtion() { <= 這裡只是 local的
}
global_funcion = function() { <= 指定變數 成function
}
})(jQuery);
</script>
<script type="text/javascript">
global_function(); <= global這裡才叫的到
</script>
2008年10月16日 星期四
javascript, scope, function
2008年10月15日 星期三
How to limit users to one vote per IP address
http://railsauthority.com/tutorial/how-to-limit-users-to-one-vote-per-ip-address
http://railsauthority.com/tutorial/how-to-obtain-the-ip-address-of-the-current-user
http://ithelp.ithome.com.tw/question/10011184
http://railsauthority.com/tutorial/how-to-obtain-the-ip-address-of-the-current-user
http://ithelp.ithome.com.tw/question/10011184
- # 以 regular expression 的設法來指定可執行的 IP 或範圍
- unless request.env['HTTP_X_REAL_IP'] =~ /^192\.168\.1\.(101|204|77|9)$|^168\.95\.1\./
- render :text => '不准看!'
- end
2008年10月12日 星期日
layout, select_layout
layout :select_layout
def select_layout
case action_name
when 'action1', 'action2'
'layout1'
when 'action3'
'layout2'
end
end
標籤:
layout,
select_layout
image_tag, path, url
http://api.rubyonrails.com/classes/ActionView/Helpers/AssetTagHelper.html
ActionController::Base.asset_host = "assets.example.com"
image_tag("rails.png")
=> <img src="http://assets.example.com/images/rails.png" alt="Rails" />
stylesheet_link_tag("application")
=> <link href="http://assets.example.com/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" />
ActionController::Base.asset_host = Proc.new { |source| "http://assets#{rand(2) + 1}.example.com" }
image_tag("rails.png")
=> <img src="http://assets2.example.com/images/rails.png" alt="Rails" />
stylesheet_link_tag("application")
=> <link href="http://assets1.example.com/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" />
ActionController::Base.asset_host = Proc.new { |source|
if source.starts_with?('/images')
"http://images.example.com"
else
"http://assets.example.com"
end
}
image_tag("rails.png")
=> <img src="http://images.example.com/images/rails.png" alt="Rails" />
stylesheet_link_tag("application")
=> <link href="http://assets.example.com/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" />
ActionController::Base.asset_host = Proc.new { |source, request|
if request.ssl?
"#{request.protocol}#{request.host_with_port}"
else
"#{request.protocol}assets.example.com"
end
}
訂閱:
文章 (Atom)