T-14 to Course Start

Rails Tutorial Continued – Chap 4, 5

Started off with another git reset --hard hash_here, and noticed this last commit was missing a little change, so I made the change, and did a git commit -va --amend to update the last commit

      • Defining a new helper method
        • Since our layout file does yield(:title) , if there is no provide(:title) helper method on one of out pages, there will be a partially constructed title
        • our helper method will go in app/helpers/application_helper.rb , and contain a conditional, spcifying that if page_title.empty? some specific base title will be provided
      • A little css
        • id is just like class but can only be used once
        • div is just a generic division
      • Twitter Bootstrap
        • added gem 'bootstrap-sass', '2.1' to Gemfile, and ran bundle install
        • created a custom.css.scss file in app/assets/stylesheets and added the line: @import "bootstrap"; . Plus, all the twitter bootstrap setting went into here.
          • also installed the Sass syntax into Sublime Text
          • and I added a couple of tabs to a ST2 file that will lead ST2 to auto recognize scss as sass
        • keywords
          • navbar
            • -fixed-top suffix fixes navigation bar to the top
            • -inverse suffix changes the nav bar from white to black
          • .center  the dot indicates that it styles a class called center, so that everything with the class center will be styled with text-align: center  (the pound sign would style an id)
          • nav
          • pull-right
          • container
          • hero-unit
          • btn
      • link_to is Rail’s method for creating links
        • a commonly used “stub uri” can work as a placeholder: '#'
        • its 3rd argument (after name and a uri), is an options hash, that can for example take a CSS id tag
      • image_tag generates an html tag
      • Partials in Rails
        • using a call to the Rails helper render 'layouts/shim' in the application.html.erb (in app/views/layout), Rails will look for app/views/layouts/_shim.html.erb and insert its contents
          • the leading underscore is a naming convention for partials. It looks for a file named _shim (this is the IE<9 consolation)
        • great for making additional sections to a page, like a header or footer
      • Assets in Rails
        • static assets go in three locations:
          • app/assets: assets specific to the present application
          • lib/assets: assets for libraries written by your dev team
          • vendor/assets: assets from third-party vendors
        • Manifest files
          • in app/assets/stylesheets/application.css comments such as *= require_tree are used by the Sprockets gem, in this case loading the CSS files from this directory and all subdirectories
        • chained extensions show the order of that file’s processing
      • Sass
        • works well with nesting
        • define variables: $grayLight: #999; (Bootstrap default)
        • competitor Less uses @ signs where Sass uses $ signs

Random Tidbits

    • ran into an error with Ruby Test: /bin/sh: rspec: command not found , quitting Sublime Text, and then relaunching it from the terminal fixed this issue
    • Random Ruby
      • single quotes don’t have as many escape sequences. "\n" makes a new line, but '\n' prints a backslash and an n just like "\\n" would
      • Array(0..9) is equivalent to (1..9).to_a
      • using is just like appending .inspect , to return sting literals
      • when hashes are the last argument in a call, the braces are optional
      • the module_function  method will take an instance method and make a copy of it as a class method, and makes the original private
      • Procs
        • can be called using square brackets: myproc.call(“arg”) = myproc[“arg”] = myprov.(“arg”)
        • return in a proc will stop execution of a method that it is in
        • Can make a method that contains data, and that can take in a method to process that data, in any way, and has a single argument that is expected to be  a proc
          • can either yield something
          • expect a block: &incomming_block that will then be called with data as arguments
          • or just expect a proc that is called (no ampersand needed)
    • Journaled file systems: modifications to data are recorded – if system crashes while data is writing, then there will be a record of what the write is supposed to be, so the Journal is replayed when you launch the machine, and it will correct the data according to the journal. Alternate is checking the file system – fsck – block by block checking of inodes; fine on small disc, but a huge disk is impossible. Journalling speeds up fsck enormously.

Postgres.app install attempt 2 – failed

  1. Downloaded Postgress.app, unzipped, and placed into applications folder
  2. According to a blog, I added the line: PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH" to the bottom of my ~/.bash_profile
  3. Quit and relaunched Terminal
  4. Following another blog, at the command line, I typed psql , and then CREATE DATABASE rails_db , and then quit with \q

because I have an app I want to move from sqlite3 to Postgres…

  1. added ‘gem pg' to my app’s Gemfile
  2. edited my development: in /config/database.yml according to this blog, and commented out the test: and :production parts

Failed and gave up: Cannot create a new app, migrate my old app, followed many instructions online, no dice… Next step, forget the Postgres.app, and follow a Screencast that goes step by step with Homebrew.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s