We are using mini_magick to resize images on Ruby.
The best way to install it on Rails is to copy the source code and put it in the plugin folder. Therefore, the running machine does not really need to install mini_magick.
Nevertheless, you will need ImgeMagick anyway. and that's it.
Nov 24, 2010
Rails's cookies
Here is some strange behaviour:
def index
cookies[:key] = "val"
puts cookies[:key]
redirect_to :second_index
end
def second_index
cookies[:key] = "newval"
puts cookies[:key]
end
## Output :
## Open index page for the first time
# nil
# val
## Open index page the second time
# newval
# val
cookies[] is to retrieve the current cookies
but cookies[]= is to assign outgoing cookies, not to re-assign the current cookies.
Actually, you can never re-assign the current cookies.
-----------------------------------------
Here is another different behaviour of using sign and string as indices:
## cookies and request.cookies are different
cookies.class #=> ActionController::CookieJar
request.cookies #=> Hash
## how to access value from cookies and request.cookies
# First set some value in cookies
cookies[:key] = "value"
cookies["key"] #=> "value"
cookies[:key] #=> "value"
# both the output are of type String
request.cookies["key"] #=> "value"
request.cookies["key"].class #=> CGI::Cookie
request.cookies[:key].empty? #=> true
request.cookies[:key].class #=> Array
Ref: http://www.quarkruby.com/2007/10/21/sessions-and-cookies-in-ruby-on-rails#scinrails
def index
cookies[:key] = "val"
puts cookies[:key]
redirect_to :second_index
end
def second_index
cookies[:key] = "newval"
puts cookies[:key]
end
## Output :
## Open index page for the first time
# nil
# val
## Open index page the second time
# newval
# val
cookies[] is to retrieve the current cookies
but cookies[]= is to assign outgoing cookies, not to re-assign the current cookies.
Actually, you can never re-assign the current cookies.
-----------------------------------------
Here is another different behaviour of using sign and string as indices:
## cookies and request.cookies are different
cookies.class #=> ActionController::CookieJar
request.cookies #=> Hash
## how to access value from cookies and request.cookies
# First set some value in cookies
cookies[:key] = "value"
cookies["key"] #=> "value"
cookies[:key] #=> "value"
# both the output are of type String
request.cookies["key"] #=> "value"
request.cookies["key"].class #=> CGI::Cookie
request.cookies[:key].empty? #=> true
request.cookies[:key].class #=> Array
Ref: http://www.quarkruby.com/2007/10/21/sessions-and-cookies-in-ruby-on-rails#scinrails
First use of Git to obtain whowish project
Assuming you have installed msysgit, you need to follow these steps in order to obtain whowish project.
1. First of all, you need to generate SSH Key for your computer by:
Run Git GUI > Help > Show SSH Key > then generate SSH key.
No need to set passphrase, just press 'enter'.
After you see the SSH key in the textarea, copy it and send it to me by any mean.
2. After I approve your key, you can test it by:
ssh git@github.com
If you see congratulation message, then you're fine.
3. Now you can check out by:
Right-click at a destination folder, select Git Bash,
Then:
git clone git@github.com:tanin47/whowish.git
* Don't forget to set username and email by:
git config --global user.name "your name"
git config --global user.email email@email.com
And there you go, the project will be downloaded to your computer.
1. First of all, you need to generate SSH Key for your computer by:
Run Git GUI > Help > Show SSH Key > then generate SSH key.
No need to set passphrase, just press 'enter'.
After you see the SSH key in the textarea, copy it and send it to me by any mean.
2. After I approve your key, you can test it by:
ssh git@github.com
If you see congratulation message, then you're fine.
3. Now you can check out by:
Right-click at a destination folder, select Git Bash,
Then:
git clone git@github.com:tanin47/whowish.git
* Don't forget to set username and email by:
git config --global user.name "your name"
git config --global user.email email@email.com
And there you go, the project will be downloaded to your computer.
Nov 23, 2010
How to use Git, really
1. When one wants to start working, he/she NEEDS to fork a new branch by using
git checkout -b branch_name
2. After making some changes, you can:
git commit -a -m "message here"
3. You can push your updates to the server, but if your friend worked on the same branch before, you might want to pull first:
git pull
Then:
git push
4. After sometimes, you might want to merge your branch with the main branch:
git checkout master (switch to the main branch)
git pull (get new updates)
git pull branch_name (merge with your branch)
Then after merging, you NEED to fork again in order to make another change.
git checkout -b branch_name
2. After making some changes, you can:
git commit -a -m "message here"
3. You can push your updates to the server, but if your friend worked on the same branch before, you might want to pull first:
git pull
Then:
git push
4. After sometimes, you might want to merge your branch with the main branch:
git checkout master (switch to the main branch)
git pull (get new updates)
git pull branch_name (merge with your branch)
Then after merging, you NEED to fork again in order to make another change.
Nov 22, 2010
The specified module could not be found ... mysql_api.so
But mysql_api.so does exist.
You just have to make sure that MySQL's bin path is in PATH environment variable.
You just have to make sure that MySQL's bin path is in PATH environment variable.
The specified module could not be found ... mysql_api.so
But mysql_api.so does exist.
You just have to make sure that MySQL's bin path is in PATH environment variable.
You just have to make sure that MySQL's bin path is in PATH environment variable.
Subscribe to:
Posts (Atom)