2013年5月30日 星期四
英雄總是寂寞孤獨!自信?自負?
英雄總是寂寞孤獨的 都覺得他人都後知後覺 自己是先知先覺
但是英雄又有分自信與自負兩種
自信的英雄會想辦法讓自己不再寂寞、不再孤獨
想辦法指引大家 教導大家正確的方向
自負的英雄總是活在自我的世界 自己享受的寂寞與孤獨而終老
在自己的世界總是自信 但在別人眼中卻是個自負的人
坐而言不如起而行,想辦法讓這個世界活絡過來吧
讓大家不再寂寞與孤獨,各位英雄豪傑
2013年5月25日 星期六
Rails Form Helper使用說明
表單欄位
| 名稱 | 用途 |
|---|---|
| form_tag | 產生表單 |
| label_tag | label:<label> |
|
text_field_tag
text_field |
input text:<input type="text"> |
| password_field_tag | input password:<input type="password"> |
| hidden_field_tag | input hidden:<input type="hidden"> |
| submit_tag | input submit:<input type="submit"> |
| check_box_tag | input checkbox:<input type="checkbox"> |
| radio_button_tag | input radio:<input type="radio"> |
| text_area_tag | textarea:<textarea> |
| search_field | input search:<input type="search"> |
| telephone_field | input tel:<inputtype="tel"> |
| url_field | input url:<input type="url"> |
| email_field | input email:<input type="email"> |
| select_tag | select:<select> |
| options_for_select | option:<option> |
| select_date | <select id="start_date_year" name="start_date[year]"></select> <select id="start_date_month" name="start_date[month]"></select> <select id="start_date_day" name="start_date[day]"></select> |
| file_field_tag | input file:<input type="file"> |
2013年5月23日 星期四
Rails Migration使用說明
關鍵字
| 名稱 | 用途 |
|---|---|
| add_column | 增加欄位 |
| change_column | 變更欄位 |
| remove_column | 移除欄位 |
| rename_column | 重新命名欄位 |
| create_table | 新增資料表 |
| change_table | 變更資料表 |
| drop_table | 丟棄資料表 |
| add_index | 增加索引 |
| remove_index | 移除索引 |
變數型態
| 名稱 | 資料範例 | 用途 |
|---|---|---|
| :binary | 010101101011 | 二進制資料 |
| :boolean | true / false | 布林值 |
| :date | 2013-04-01 | 日期 |
| :datetime | 2013-04-01 23:59:59 | 日期時間 |
| :decimal | 3.141 :precision => 6 |
浮點數 |
| :float | 3.141 :precision => 6 |
浮點數 |
| :integer | 0,1,2,3... | 整數 |
| :primary_key | 0,1,2,3... | 主鍵 |
| :string | KeJyun | 字串 |
| :text | KeJyun KeJyun KeJyun KeJyun... | 長字串 |
| :time | 23:59:59 | 時間 |
| :timestamp | 2013-04-01 23:59:59 | 使用時間欄位(created_at , updated_at) |
關鍵變數
| 名稱 | 範例 | 用途 |
|---|---|---|
| :default | :default => 'default_value' | 預設值 |
| :null | :null => false | 是否可以空值 |
| :limit | :limit => 255 | 最大長度 |
參考資料
2013年5月17日 星期五
2013年5月7日 星期二
Rails模組(Model)資料驗證(Validates)
驗證規則
# validates 欄位名稱 驗證規則
validates :email, :presence true,
:uniqueness { case_sensitive: true } ,
:length => {:in => 10..200 },
:format => {:with => /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/ , :message => 'Email格式錯誤'}
| 變數名稱 | 範例 | 用途 |
|---|---|---|
| :presence | :presence true | 一定存在這個欄位資料 |
| :uniqueness | :uniqueness => { :case_sensitive => false } :uniqueness => true |
唯一值(條件) |
| :length | :length => { :minimum => 2 } :length => { :maximum => 500 } :length => { :in => 6..20 } :length => { :is => 6 } |
資料長度 :minimum:最短長度 :maximum:最長長度 :in:長度範圍 :is:長度唯一值 |
| :format | format: {:with=> /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/ , :message => 'Email格式錯誤'} | 正規表示式判斷 :with:正規表示式 :message:錯誤訊息 |
| 變數名稱 | 範例 | 用途 |
參考資料
2013年5月5日 星期日
在Rails安裝Twitter Bootstrap套件
在Gemfile中加入下列文字
重新啟動伺服器
可以開始在rails中使用Twitter Bootstrap了~
gem 'bootstrap-sass'安裝bootstrap-sass套件
bundle install在
app/assets/javascripts/application.js檔案中加入//= require bootstrap引用 Twitter Bootstrap JS//= require jquery建立Twitter Bootstrap的scss檔
//= require jquery_ujs
//= require bootstrap
//= require_tree .
app/assets/stylesheets/bootstrap_and_overrides.css.scss,並在檔案中輸入下列文字以引用Twitter Bootstrap@import "bootstrap";
body { padding-top: 60px; }
@import "bootstrap-responsive";
重新啟動伺服器
sudo service apache2 restart
可以開始在rails中使用Twitter Bootstrap了~
參考文章
訂閱:
文章 (Atom)
