Permalink
Browse files

renamed rails directory

  • Loading branch information...
1 parent 3d5a69b commit d33069fa094d754bb99bb53f0511415c0c91ea88 @craftstudios committed Oct 1, 2010
@@ -1,26 +0,0 @@
-date: Date: 2007-03-21 16:30:08 +1200
-categories: Rails
-read more: Read more
-summary: Do not write your own initialiser to instantiate the object.
-
-# Active Record Constructors
-============================
-
-Do not write your own initialiser to instantiate the object. e.g:
-
- class MyClass < ActiveRecord::Base
- def initialize(params)
- @params = params
- end
- end
-
-Instead do this:
-
- my_object = MyClass.new(:params => params)
- my_object.save
-
-Or this:
-
- MyClass.create :params => params
-
-The above will automatically save the record to the DB.
@@ -1,162 +0,0 @@
-date: Date: 2007-07-05 13:45:08 +1200
-categories: Rails
-read more: Read more about deploying rails on windows
-summary: You CANNOT access the session hash from within a controllers `initialize()` method.
-
-# Deploy Rails with Oracle on Windows
-=====================================
-
-An application I'm developing is due to go public around Christmas. I thought the best way to get to grips with deployment would be to set up a little test application, before trying to move all my code onto the server. This guide will consist of 3 parts:
-
- 1. Installing Rails
- 2. My-first-app with Oracle
- 3. Pen of pesky Mongrels
-
-I'll be using Windows Server, Oracle 10g, Mongrel & Pen. Many thanks to [Brian Hogan](http://www.napcs.com/) for his informative talk at RailsConf which made the whole process very easy. See [Deployment Strategies for Rails on Windows Servers](http://www.napcs.com/howto/rails/deploy/index.html) for more detailed information.
-
-
-Part 1: Installing Rails
-------------------------
-
-### Install Ruby
-
-Download the [one click windows installer](http://www.rubyonrails.org/down). When installing, uncheck 'SciTE' – there are better editors available. Also, make sure ‘Enable RubyGems’ is checked. This is the package manager for Ruby, used to install Rails itself and myriad of other stuff.
-
-Install to 'c:\program files\ruby' (or your installation path), then add ‘c:\program files\ruby\bin’ to your PATH for command line stuff.
-
-Goto ‘Control Panel\System’, select the ‘Advanced’ tab and click ‘Environment Variables’. Look under user variables. If PATH isn’t already defined, click ‘New’.
-
- * Variable name = ‘PATH’
- * Variable value = ‘%PATH%;c:\program files\ruby\bin’
-
-Note the ‘;’ separator in the value string. If PATH is already defined just add ‘;c:\program files\ruby\bin’ to the end of it.
-
-
-### Install Rails
-
-Now that we have ruby installed, we can use RubyGems to install rails.
-
- gem install rails --include-dependencies
-
-Yes, it is that easy.
-
-### My-first-app
-
-Create your application skeleton and start the server:
-
- rails path/to/your/new/application
- cd path/to/your/new/application
- ruby script/server
-
-Congratulations! You’re now on Rails.
-
-
-Test Oracle with a simple app
------------------------------
-
-This post is part of a guide to deploying a small Rails application on a windows server using Oracle, Mongrel & Pen. My thinking: get it working with a simple app first, to minimise headaches later. The other posts can be found here:
-
-This part heavily references a [tutorial provided by Oracle](http://www.oracle.com/technology/pub/articles/haefel-oracle-ruby.html).
-
-This guide assumes you are either:
-
- * connecting to an Oracle Database installed on your local machine.
- * connecting to a remote database using Oracle Instant Client installed on your local machine.
-
-If you do not have at least the [client software](http://www.oracle.com/database/index.html) installed, the Ruby-Oracle driver will complain that it can’t find files such as `oci.dll`.
-
-
-### Install Oracle Database Driver
-
-Download the [ruby oracle driver](http://rubyforge.org/projects/ruby-oci8) and install with:
-
- ruby ruby-oci8-1.0.0-rc3-mswin32.rb
-
-You can test your connection to the database with the following one-liner:
-
- ruby -r oci8 -e "OCI8.new('username', 'password', '127.0.0.1:1521/orcl').exec('SELECT * FROM test_table') do |r| puts r.join('|'); end"
-
-Of course, make sure the schema & table that you are testing exists!
-
-### Create a User
-
-Using SQL*Plus, create a user with DBA privileges that you can use for this application.
-
- GRANT dba TO ruby IDENTIFIED BY ruby;
- ALTER USER ruby DEFAULT TABLESPACE users TEMPORARY TABLESPACE temp;
- EXIT
-
-Granting DBA access is not advised. Does this advice come from an old Oracle article? Only the necessary privileges (CREATE TABLE, CREATE SEQUENCE) etc should be used.
-
-Create a Table
-
- CREATE TABLE comics (
- id NUMBER(10) NOT NULL,
- title VARCHAR2(60),
- issue NUMBER(4),
- publisher VARCHAR2(60),
- PRIMARY KEY (id)
- );
- CREATE SEQUENCE comics_seq;
-
-Alternatively use [this SQL file](http://www.oracle.com/technology/pub/files/comics.sql) to create the application table, `COMICS`.
-
- sqlplus ruby/ruby@rails @comics.sql
-
-Note, in this case the database SID is `rails`. The default SID for Oracle Enterprise Edition 10g is `orcl`, for Express Edition it’s `XE`.
-
-### Create a dinky Application
-
-Your application skeleton:
-
- rails comics_catalog
- cd comics_catalog
-
-Edit `comics_catalog/config/databases.yml` – rails needs to know your login & password info.
-
-Within your project directory, there is a directory called config and in it is a file named `database.yml`. You need to edit `database.yml` using your favourite text editor. Initially, the file will look like this:
-
- development:
- adapter: mysql
- database: rails_development
- host: localhost
- username: root
- password:
-
- # Warning: The database defined as 'test' will be erased and
- # re-generated from your development database when you run 'rake'.
- # Do not set this db to the same as development or production.
- test:
- adapter: mysql
- database: rails_test
- host: localhost
- username: root
- password:
-
- production:
- adapter: mysql
- database: rails_production
- host: localhost
- username: root
- password:
-
-Change the development properties as follows:
-
-development:
- adapter: oci
- username: ruby
- password: ruby
- host: 127.0.0.1:1234/orcl
-
-`host:` takes a connect string of the form `<ip_address>:<port>/<database>` for the machine that your Oracle instance resides on.
-
-Use the magical scaffold command to build a web based CRUD interface to the table we created above...
-
- ruby script/generate scaffold Comic
-
-Now you can access your Rails Comic Catalog application on your own development machine, using your favourite Web browser. Just access the following URL: (http://localhost:3000/comics/list)
-
-Phew! Done. Last step is Part 3: Pen of pesky Mongrels...
-
-References
-http://www.oracle.com/technology/pub/articles/haefel-oracle-ruby.html
@@ -1,23 +0,0 @@
-date: Date: 2007-03-23 15:40:08 +1200
-categories: Rails
-read more: Read more
-summary: Active Record (AR) is slow. All that nice reflection comes at a price. You should use AR to prototype your app, then take a look at the logs to see where SQL can be tweaked.
-
-# Improve Default Rails Database Performance
-============================================
-
-Active Record (AR) is slow. All that nice reflection comes at a price. You should use AR to prototype your app, then take a look at the logs.
-
-1. Sort your development log.
-
-If a database query is only run a few times, let AR handle it. If one is being run a 1000 times then we should pull it out and tweak it.
-
-2. Pull the SQL from the log
-
-Rails has already done the hard work for us, right?
-
-3. Tweak the SQL
-
-For example:
-
-Stick the tweaked DB query into your model using `find_by_sql()` and things should move along nicely...
@@ -1,32 +0,0 @@
-date: Date: 2007-03-22 10:11:08 +1200
-categories: Rails
-read more: Read more on Named Callbacks
-summary: Coming from a Java background I often find myself wanting to override constructors and other hooks. Using named callbacks better conveys your intention, making your code more readable.
-
-# Named Callbacks
-=================
-
-Coming from a Java background I often find myself wanting to override constructors and other hooks. I should really pay more attention to the [documentation](http://www.pragmaticprogrammer.com/titles/rails/). #fishpond!!
-
-Instead of:
-
- class MyClass
- def after_initialize
- #Do Something...
- end
- end
-
-Do:
-
- class MyClass
- after_initialize :do_something
-
- def do_something
- #Do Something...
- end
- end
-
-Using named callbacks better conveys your intention, making your code more readable.
-
-References:
-[RailsConf Recap: Named Callbacks](http://www.therailsway.com/2007/6/7/railsconf-recap-named-callbacks)
@@ -1,15 +0,0 @@
-date: Date: 2007-03-21 13:00:08 +1200
-categories: Rails
-read more: Read more
-summary: The fixture file has to be TABLENAME.yml (not case sensitive)
-
-# Rails Fixtures with Legacy Database
-
-My setup was:
-
-MySQL Table name: `TABLENAME` (all caps)
-Rails Model name: `TableName` (camel case)
-
-1. The fixture file has to be `TABLENAME.yml` (not case sensitive)
-2. `fixtures()` takes the symbol name of the Model, in this case `:tableName` (note the first lowercase letter) This is the bit that drove me mad - i was writing fixtures `:TableName` which appeared to work, but then the test failed if I tried `TableName(:foo)`
-3. Now you can write `tableName(:foo)`
@@ -1,26 +0,0 @@
-date: Date: 2007-03-21 13:02:08 +1200
-categories: Rails
-read more: Read more
-summary: I don't think the explanation of 'selection lists' in Agile Web Development with Rails(1st ed) is very clear.
-
-# Selection List syntax
-=======================
-
-I don't think the explanation of 'selection lists' in Agile Web Development with Rails(1st ed) is very clear. It mentions:
-
- select(:variable, :attribute, choices, options, html_options)
-
-Where you can then set the default selection with:
-
- @variable.attribute
-
-However this variable is not available automatically, you need to create it yourself. The def in the api is more intuitively described as:
-
- select(:my_object, :method, choices, options, html_options)
-
-You must then create your own class with the accessor methods you need so that in the controller you can do something like:
-
- def action
- @my_object = MyClass.new
- @my_object.method = params[:my_object][:method]
- end
@@ -1,8 +0,0 @@
-date: Date: 2007-03-21 13:01:08 +1200
-categories: Rails
-read more: Read more
-summary: You CANNOT access the session hash from within a controllers `initialize()` method.
-
-# Session variable not available
-
-You CANNOT access the session hash from within a controllers `initialize()` method.

0 comments on commit d33069f

Please sign in to comment.