sublime trix: in terminal, instead of typing subl . to open a sublime text folder, type subl . & to force sublime to run in the background, that way your terminal is still active instead of hanging.
Ruby Forms: http://guides.rubyonrails.org/form_helpers.html
Ruby key words: http://ruby.learncodethehardway.org/book/ex37.html
rails- open source web framework for ruby. (rails is a collection of tools wrapped up in a web platform vs. sinatra being a more stand alone framework that require hard-coding of libraries, rails is omakase).
http://rubyonrails.org/core (DHH)
https://www.ruby-toolbox.com/ (rails toolbox resources.. gemfiles)
if you change anything in gem file or application.rb, you'll need to re-run your file.
asset pipeline - rails will combine all your js resources, to minimize http loading. When you're trying to render your website, it's going to combine all JS down to reduce html load time
helpers.rb - you can write stuff (methods) in here that's going to display in your "view"
config -routes.rb
use 'match' for now.. but for rails 4.0.. it's being deprecated to use 'get'
controllers are plural (plural_singular.rb), and models should be singular. class names should always be capitalized in Ruby.
# class
# ClassNames
# variables
# this_is_a_variable
# model (singular)
# User
# Controller (plural)
# Somthings_Controller
=> Booting WEBrick (this is a webserver being run by rails) => Rails 3.2.13 application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server [2013-07-08 11:00:02] INFO WEBrick 1.3.1 [2013-07-08 11:00:02] INFO ruby 1.9.3 (2013-06-27) [i686-linux] [2013-07-08 11:00:02] INFO WEBrick::HTTPServer#start: pid=3670 port=3000
Started GET "/assets/rails.png" for 127.0.0.1 at 2013-07-08 11:00:20 -0700 Served asset /rails.png - 200 OK (6ms)
-
rm public/index.html to remove default index.html
-
create a movies_controller.rb in app/controllers
class MoviesController < ApplicationController
def home
@message = "Anil"
end
end
#localhost:3000/movies/home
if we run now, we'll get "Template missing".. so now we need to add a view (4).
- look at app/ layout/ application.html.erb real quick:
<!DOCTYPE html>
<html>
<head>
<title>MondayApp</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %> <!-- this here is for security measure -->
</head>
<body>
<%= yield %>
</body>
</html>
-
in config / routes.rb change the first bit
# match 'products/:id' => 'catalog#view'to:get 'products/:id' => 'catalog#view' root :to => 'movies#home' #
get 'movies' => 'movies#home'
root :to => 'movies#home'
# the above code is same as:
# get '/movies', :controller => 'movies', :action => 'home'
forms: http://www.saalonmuyo.com/2010/01/27/using-form_tag-in-ruby-on-rails/
https://gist.github.com/aikalima/5808229
for mac users: http://www.grandtotal.biz/CheatSheet/
karl's weekend project: https://github.com/rails/docrails/blob/master/activemodel/lib/active_model/secure_password.rb
Tonight's HW: https://gist.github.com/bridgpal/7b11381f8375121e4aac