躺在沙灘上的小豬

          快樂的每一天

          #

          Feedburner

          http://feeds.feedburner.com/martinx

          posted @ 2006-05-19 09:27 martin xus| 編輯 收藏

          Integrate FCKEditor with your Ruby on Rails application

          http://www.joshuamcharles.com/rails/fckeditor.html

          posted @ 2006-05-17 17:04 martin xus| 編輯 收藏

          Rails Document

          http://delynnberry.com/pages/rails-chm-documentation/

          posted @ 2006-05-16 20:30 martin xus| 編輯 收藏

          Post and Get

          在《Agile Web Development with Rails》中看到如下的一句話

          ???? If it has no associated data, it will come in as a GET request. If instead it contains form data, we’ll see a POST. Inside a Rails controller, the request information is available in the attribute request. We can check the request type using the methods get?( ) and post?( ).

          也就是說當沒有數據的時候,是get,而有數據的時候則是post.

          例如我們在用戶登錄的時候,首先轉到登錄界面,這個時候當然還沒有數據,那么

          request.get?

          為true,輸入相應的數據,提交為false,這樣我們可以通過一個action來控制流程
          ?
          ??def?login
          ??????
          if?request.get?
          ??????????session[:user_id]
          =nil
          ??????????@user?
          =?User.new
          ??????
          else
          ??????????@user?
          =?User.new(params[:user])
          ??????????logged_in_user?
          =?@user.try_to_login
          ??????????
          if?logged_in_user
          ??????????????session[:user_id]
          =logged_in_user.id
          ??????????????redirect_to?:action
          =>'index'
          ??????????
          else
          ??????????????flash[:notice]
          ="Invalid?user/password?combination"
          ??????????end
          ??????end
          ??end?

          posted @ 2006-05-16 10:08 martin xus| 編輯 收藏

          rails 中文亂碼的問題

          在使用rails+mysql的時候遇到了中文亂碼的問題,google了一下,解決了,把它貼出來,防止以后又忘記了

          首先在application.rb中增加utf-8的filter:

          class ?ApplicationController? < ?ActionController::Base
          ??before_filter?:configure_charsets??

          ????
          def ?configure_charsets????????
          ????? ??@headers[
          " Content-Type " ]? = ? " text/html;?charset=utf-8 " ???
          ????end
          end

          修改數據庫的編碼為utf-8

          CHARSET=utf8

          其中有一點要說明的是,我看到有人說,不能使用InnoDB,可是我測試下來的結果是,可以正常使用。

          posted @ 2006-05-16 09:41 martin xus| 編輯 收藏

          僅列出標題
          共28頁: 上一頁 1 2 3 4 5 6 7 8 9 下一頁 Last 
          主站蜘蛛池模板: 安化县| 建始县| 汶上县| 南部县| 黑龙江省| 东宁县| 济宁市| 壶关县| 安仁县| 汉川市| 东兴市| 宜良县| 紫阳县| 晋州市| 佳木斯市| 宜春市| 盘锦市| 宁波市| 常州市| 昭苏县| 分宜县| 通辽市| 邢台县| 都匀市| 鸡东县| 墨玉县| 新野县| 佛学| 子洲县| 金寨县| 张掖市| 沈丘县| 甘洛县| 邛崃市| 温宿县| 罗定市| 且末县| 玛纳斯县| 咸丰县| 安溪县| 曲阜市|