puts "hello world"
Interactive ruby:
irb
Type exit
to get out.
From the bash command prompt, type clear
to clear the screen.
Let's make some people!
rails g scaffold person first_name:string last_name:string spirit_animal:string favorite_color:string favorite_number:float zipcode:integer --pretend
rake db:migrate
To list all available rake tasks:
rake -T
rake -T | grep db
People are live at https://tts-rails2-zeke-1.c9.io/people
Add this to config/routes.rb
:
root to: 'people#index'
Working on a stylesheet:
$table-heading-color: #999;
body {
font-family: "helvetica neue", helvetica, arial;
}
th {
font-weight: normal;
color: $table-heading-color;
text-align: left;
}
table {
border-collapse: collapse;
width: 100%;
}
th, td {
padding: 5px;
}
tr:nth-child(even) {
background: #EEE;
}
.color-box {
width:20px;
height:20px;
}
HTML for the color-box to be added to app/views/people/show.html.erb
:
<div class="color-box" style="background:<%= @person.favorite_color %>;"></div>
HTML for making each person's name a link to their page:
<td>
<%= link_to person.first_name, person %>
</td>
Add a first name method to app/models/person.rb
:
class Person < ActiveRecord::Base
def full_name
[first_name, last_name].join(" ")
end
end
Futility! Open up irb
in your shell:
color = "red"
phrase = "My favorite color is #{color}"
phrase.upcase.reverse.split(" ").join(" ").reverse.downcase
State of the person model:
class Person < ActiveRecord::Base
def full_name
[first_name, last_name].join(" ")
end
def cleaned_up_favorite_color
favorite_color.gsub(" ", "")
end
def spirit_animal_wikipedia_url
"https://en.wikipedia.org/wiki/#{spirit_animal}"
end
def spirit_animal_lucky_url
"http://www.google.com/search?&sourceid=navclient&btnI=I&q=#{spirit_animal}"
end
end
Go to the shell and type:
rails console
The stylesheets are located at app/assets/stylesheets.