2014年4月21日 星期一

Rails - Deploying to Heroku : Why stylesheets can't work?

I found it on stackflow.

This may be the solution, add config.serve_static_assets = true to

config/environment/production.rb

 and run rake assets:precompile

You guess what? Everything is on rails!

Rails - Test fail ! Why?

I make that mistake many times,

 maybe just because of the database doesn't prepared to be tested.

Try 

rake db:test:prepare

AngularJS - Learning resource

http://www.thinkster.io/angularjs/GtaQ0oMGIl/a-better-way-to-learn-angularjs

2014年4月13日 星期日

jQuery - example - Checking Value

Html :





    






JavaScript here



function isValidEmail (email) {
  return email.indexOf('@') != -1;
};
$required = $('.required');
function requiredValues () {
  var inputs = new Array();
  $required.each(function(){
    inputs.push($(this).val());
  });
  return inputs;
  
};



2014年4月12日 星期六

JavaScript - NaN

NaN is a special type of "Number" which actually stands for "Not a Number".

What's special is it doesn't equal to itself,

shall using the isNaN method to detect it.

2014年4月11日 星期五

JavaScript - Hoisting

While initial variable during the middle of function,

Javascript initial a null varible for us at the top of the function whether it's assigned or not.

Example:

function bakery( ) {
    if(false) {
    var cake = "butter" ;
    }
  }
What it will actually do is:

function bakery() {
  var cake;
  if(false) {
    var cake = "butter" ;
    }
  }
That's what we call hoisting.

JavaScript - Scope

depends on function.



funciton(okgo) {
  var color = "Red";
  if (okgo) {
   var color = "Black";
  }
  console.log(color);
}
Result:
  okgo = true;
  "Black"

2014年4月10日 星期四

2014年4月9日 星期三

CSS - transition:

順序

 transition: transition-property duration-time transition-timing-function delay;

蠻好記的,其實就是p d f delay!

2014年4月7日 星期一

CSS - text rhythm

行距處理的好幫手:http://basehold.it/

用法是將<link rel="stylesheet" href="http://basehold.it/24">

最後面的24改成要的行高,最後將線對齊就完成了。

2014年4月2日 星期三

html Deep dive - form - What' your name?

常見的誤會:

<label for="name">
<input type="text" name="name" >


很容易誤以為label 裡面對應到的name是input element裡的name attribute。
但其實這樣是對應不到的,應該要加上id attribute後,
才能真正對應到,像這個樣子:


<label for="name">
<input type="text" name="name" id= "name">


2014年3月29日 星期六

Rails Tutorial - @user ? 實體變數(實例變量)

在Ruby中以@開頭的為實例變量,
@user就是一個實例變量,
它特殊的地方在於它能直接用於view中,
也常用於在同一類別中的不同方法間傳遞值。

舉個例子說明:
當我們使用User.new這個方法時,
會調用:


def initialize(attributes = {})  
    @name = attributes[:name]  
    @email = attributes[:email] 
end
    
而attributes是一個空的hash(雜湊),
為@name和@email這兩個實例變數設定值,
所以在同一類別中的其他方法也能直接調用這兩個實例變數,
像是formatted_email這個方法:


def formatted_email  
    "#{@name} <#{@email}>"
end 

2014年3月26日 星期三

Rails Tutorial - Migration

在學習rails的路上,
前面的ruby語法和coffee script入門的問題都不大,
雖然rails會幫我們處理好很多資料庫的問題。
不過我還是很常對 rake db:migrate這個指令質疑?
到底migrate是在遷移什麼?
什麼是migration?

這篇先留著以後再慢慢讀:
http://guides.ruby.tw/rails3/migrations.html

2014年3月23日 星期日

Rails Tutorial -ch6 User v.s Users

model模型是User。
controllers是Users。

Rails Tutorial -ch5 產生Users-controller

記得使用 “rails generate Users new”,

記憶邏輯:

因為到時候的User不只一個,

所以Controller的命名自然是複數。

2014年3月22日 星期六

Rails Tutorial -Ch5- stylesheet_link_tag

原來有人跟我遇到一樣的問題,
是sprockets的版本更新之後會遇到的bug,
只要把它鎖定在 gem 'sprockets', '2.11.0'
(原本是2.12.0)