- 2 小時 / 10:30 - 12:30
- 以電郵遞交
- 需要在課堂上完成
- 屆時會有試卷,參考影片/資料,同學需在兩小時內以 Dreamweaver 完成
- 可使用參考書
- 可使用筆記
### Keybase proof | |
I hereby claim: | |
* I am victorlamhk on github. | |
* I am victorlamhk (https://keybase.io/victorlamhk) on keybase. | |
* I have a public key ASDLgkDgXIh0ytSE1jU-C1SBacjVhXE3ApN7NtXwdC3jZQo | |
To claim this, I am signing this object: |
Rails 3.1 introduced force_ssl
. You can add config.force_ssl = true
in application.rb
.
By enabling force_ssl
, Rails send a HSTS (HTTP Strict Transport Security) header which will expired in a year.
So if you enabled force_ssl
once, even you change the config value to false
later, the browser you used to open you app before will still remember this website (using domain to identify) require to use HTTPS, and redirect you to HTTPS connection automatically. You may use chrome://net-internals/#hsts
to check the domain list in Google Chrome.
#routes.rb | |
get "blog/category/:category/" => "posts#by_category", as: :post_category | |
get "blog/category/:category/index.html" => "posts#by_category" | |
get "blog/page-:page/" => "posts#index", as: :blog | |
get "blog/page-:page/index.html" => "posts#index" | |
get "blog/:slug/" => "posts#by_slug", as: :post_slug | |
get "blog/:slug/index.html" => "posts#by_slug" | |
get "blog" => "posts#index", as: :blog | |
get "blog/index.html" => "posts#index" |
# define a method to run rake tasks | |
def run_rake(task, options={}, &block) | |
rake = fetch(:rake, 'rake') | |
rails_env = fetch(:rails_env, 'production') | |
command = "cd #{current_path} && #{rake} #{task} RAILS_ENV=#{rails_env}" | |
run(command, options, &block) | |
end | |
class GalleryImagesController < ApplicationController | |
def rotate | |
@image = GalleryImage.find(params[:id]) | |
rotation = params[:deg].to_f | |
rotation ||= 90 # Optional, otherwise, check for nil! | |
@image.rotate!(rotation) | |
flash[:notice] = "The image has been rotated" | |
end |