Skip to content

Instantly share code, notes, and snippets.

View kafaichoi's full-sized avatar
🍃

KaFai kafaichoi

🍃
View GitHub Profile
@kafaichoi
kafaichoi / gist:823266d43a04a902b468
Created September 5, 2014 08:37
Curl for nested json request
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d ' {"user":{"fullname":"Bob Chan","email":"[email protected]","password":"password"}}' http://localhost:3000/api/users
<p>This is deprecated, in future versions you may need to <code>bundle binstub rails</code> to work around a system/bundle conflict.<br>
/home/kafai/.rvm/gems/ruby-2.0.0-p481/gems/paratrooper-0.0.1/lib/paratrooper.rb:1:in <code>require': cannot load such file -- heroku (LoadError)<br>
from /home/kafai/.rvm/gems/ruby-2.0.0-p481/gems/paratrooper-0.0.1/lib/paratrooper.rb:1:in</code>'<br>
from /home/kafai/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in <code>require'<br>
from /home/kafai/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in</code>block (2 levels) in require'<br>
from /home/kafai/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in <code>each'<br>
from /home/kafai/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in</code>block in require'<br>
from /home/kafai/.rvm/gems/ruby-2.0.0-p481@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in <code>each'<br>
Quiz: Lesson 3
1. What's the difference between rendering and redirecting? What's the impact with regards to instance variables, view templates?
They both complete a request but redirect will tell the client (browser) to send a brand-new request to a new URL. Therefore, no instance variable from previous action triggering the redirect will be available to the redirected view template . For rendering, the instance variable from the action will be avaiable for the view template being rendered.
2. If I need to display a message on the view template, and I'm redirecting, what's the easiest way to accomplish this?
flash[:notice]
3.If I need to display a message on the view template, and I'm rendering, what's the easiest way to accomplish this?
@kafaichoi
kafaichoi / answer_for_quiz1_rail.md
Last active August 29, 2015 14:01
My answer for the quiz in the lesson 1 of Rails
  1. Why do they call it a relational database? Relational database are usually consisted of different tables which are related to other table by foreign key. And Foreign key in one table is the primary key of a record in another table. We can easily make a query base on different criteria on different table by joining the table.

2.What is SQL? SQL stands for Structured Query Language. It is a Domain Specific Language for managing data in RDBMS

  1. There are two predominant views into a relational database. What are they, and how are they different? They are the data and schema views. Data view displays like a spreadsheet. A schema view descripts the column names and the value type of each column.

  2. In a table, what do we call the column that serves as the main identifier for a row of data? We're looking for the general database term, not the column name.