Getting Started with Ruby on Rails

1.)一個不肯定性修改"WARN Could not determine content-length of response body": html

http://michael-roshen.iteye.com/blog/1612848 git

2.)關於routes.rb的疑問,爲何我使用rails generate沒有自動更新route呢?致使沒法映射,還好官方有文檔:http://guides.rubyonrails.org/routing.html
關於hello.html.erb的中文編碼問題:

http://stackoverflow.com/questions/6731071/rails-and-html-encoding-error github

將文件格式保存爲UTF-8便可。
undefined method `key?' for nil:NilClass
不是什麼語法錯誤,就是不能輸中文,保存成UTF-8也無濟於事。更跟下面這句話半毛錢關係都沒有:
if price.nil ? || price < 0.01
3.)照書上的方法(第三版)寫了下面這一行在config/environments/development.rb目錄下(看樣子路徑變了):
config.action_controller.session_store = :active_record_store

因而在environment.rb裏寫道: 數據庫

Depot::Application.config.session_store = :active_record_store 瀏覽器

4.)雖然重啓沒報錯,可是貌似cookie沒有存到sessions表裏去。
納尼?Rails3改動這麼大,session存儲的配置放在了config\initializers\session_store.rb,坑跌啊~
In Rails 3 you have to do NameOfYourApp::Application.config.session_store :mongoid_store without the "=" in config/initalizers/session_store.rb


把cookie_store改爲:active_record_store ruby

5.)OK!成功保存到sessions表,最好建成memory表。建內存表時發現的一個問題:

root@localhost  :[depot_development]<11:13:38>alter table sessions modify data varchar(21582);
ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs cookie

原來utf8類型最大隻能到21581,超過一點點就報錯,可是超過不少的話就不會報錯而是自動轉爲mediumtext類型了。。 session

才發現保存到數據庫還有一個好處是,全部瀏覽器之間的狀態能夠共享,這個大部分是優勢,但有時候會是不順手的地方~ ide

6.)button_to方法生成的是表單按鈕,因此route配置得用post方式:post "store/add_to_cart"
相關文章
相關標籤/搜索