By Rob Orsini
Book Price: $39.99 USD
£28.50 GBP
PDF Price: $27.99
Cover | Table of Contents
$ gem_server
$ sudo gem install cheat --source require.errtheblog.com
mysql
command-line client and several other administration utilities, such
as mysqldump. PATH, allowing you to call the MySQL
utilities from the Windows command line. Once the installation is
complete, you can start up mysql
as the root user at the command prompt as shown in .
net command:C:\> net start mysql
C:\> net stop mysql
C:\> gem install mysql
$ cat /etc/apt/sources.list
deb http://archive.progeny.com/debian/ etch main
deb-src http://archive.progeny.com/debian/ etch main
deb http://security.debian.org/ etch/updates main
deb-src http://security.debian.org/ etch/updates mainapt-get update to
resynchronize the package index files from the repository
sources:$ sudo apt-get update
psql tool (the command-line user
interface) is included; if you prefer a GUI administration tool,
also include pgAdmin III.apt-get update to resynchronize the
package index files from the repository sources.$ cat /etc/apt/sources.list
deb http://archive.progeny.com/debian/ etch main
deb-src http://archive.progeny.com/debian/ etch main
deb http://security.debian.org/ etch/updates main
deb-src http://security.debian.org/ etch/updates main$ sudo apt-get update
postgresql-8.1 as of this writing) and
development package. These packages include dependent packages for
the PostgreSQL client and common libraries as well as header files
necessary for compilation of the Ruby PostgreSQL driver.$ sudo apt-get install postgresql-8.1 postgresql-dev
su to the postgres user, and connect to the server
with the client program psql:$ sudo su postgres $ psql Welcome to psql 8.1.0, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help with psql commands \g or terminate with semicolon to execute query \q to quit postgres=# \l List of databases Name | Owner | Encoding -----------+----------+----------- postgres | postgres | SQL_ASCII template0 | postgres | SQL_ASCII template1 | postgres | SQL_ASCII (3 rows) postgres=#
$ which ruby
/usr/local/bin/ruby$ ruby -v
ruby 1.8.4 (2005-10-29) [i486-linux]$ cd /usr/local/src/ruby-1.8.4
./configure
make
sudo make installlibreadline is required for
Readline support in irb).$ apt-get update
$ sudo apt-get install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 \
irb1.8 libreadline-ruby1.8 libruby1.8
$ tar xzvf rubygems-0.9.0.tgz $ cd rubygems-0.9.0 $ sudo ruby setup.rb
PATH variable to
include /usr/local/bin and
/usr/local/sbin. Add the
following line to your ~/.bash_profile:~$ export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
PATH variable is
available to your current shell.~$ source .bash_profile
cd into it. This will be a working
directory where you’ll download and configure a number of source
files.irb, and the
Rails console to work correctly./usr/local/src$ curl -O ftp://ftp.cwru.edu/pub/bash/readline-5.1.tar.gz /usr/local/src$ tar xzvf readline-5.1.tar.gz /usr/local/src$ cd readline-5.1
/usr/local/src/readline-5.1$ perl -i.bak -p -e \
"s/SHLIB_LIBS=.*/SHLIB_LIBS='-lSystem -lncurses -lcc_dynamic'/g" \
support/shobj-conf
prefix option of
configure:/usr/local/src/readline-5.1$ ./configure --prefix=/usr/local /usr/local/src/readline-5.1$ make /usr/local/src/readline-5.1$ sudo make install /usr/local/src/readline-5.1$ cd ..
/usr/local/src$ curl -O \
ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.4.tar.gzdemo:C:\InstantRails\rails_apps>rails demo
demo
application are demo_development,
demo_test and demo_production. You’ll need to create these
in phpMyAdmin; you
must also create a user named “root” with no .cds table that
you’ve created in your database, open a Rails console window, and
navigate to the root of the project. To execute a command in the
scripts directory, pass the path to the command
as an argument to the Ruby binary:C:\InstantRails\rails_apps\demo>ruby script\generate scaffold cdgem command and probably other Ruby packages as well. You want to
manage these packages and upgrade as new versions are released, without worrying
about dependencies.$ sudo gem update rails --include-dependencies
~/project$ rake rails:update:javascripts
gem command-line
utility lets you install, upgrade, remove, and inspect gems.gem list, you can view
which gems you have installed. To get a list of all your installed
gems and their versions, use:$ gem list --local
$ gem list --remote
gem
command is gem command [arguments...]
[options...]. Many of the commands take either --local or --remote as arguments. To search your local
repository as well as the remote repository for gems with “flick” in
the name, use :$ gem search --both flick
$ sudo gem install --remote rails --rdoc
specification
:$ gem specification rails
gem help or just
gem (with no arguments) to get more
information on available gem commands and options./home/svn$ svnadmin create blog
/home/svn$ ls blog/
conf dav db format hooks locks README.txt/home/svn$ cd ~/projects/blog; ls
app components config db doc lib log public Rakefile README script
test vendor. in the following command is critical. It specifies to
“import everything within this directory”:~/projects/blog$ svn import -m "initial import" . \ > file:///home/svn/blog Adding test Adding test/unit Adding test/test_helper.rb ... Adding public/favicon.ico Committed revision 1. ~/projects/blog$
~/projects$ cd ..; rm -rf blog/
~/projects$ svn checkout file:///home/svn/blog
A blog/test
A blog/test/unitL
...
A blog/public/favicon.ico
Checked out revision 1.
~/projects$~/projects$ cd blog ~/projects/blog$ svn remove log/* D log/development.log D log/production.log D log/server.log D log/test.log ~/projects/blog$
~/projects/blog$ svn commit -m 'removed log files'
Deleting log/development.log
Deleting log/production.log
Deleting log/server.log
Deleting log/test.log
Committed revision 2.
~/projects/blog$ ~/projects/blog$ svn propset svn:ignore "*.log" log/
property 'svn:ignore' set on 'log'
~/projects/blog$rails command with the path to your new
application as an argument. For example, to create your new
application at /var/www/cookbook
(and the cookbook directory doesn’t exist yet),
type the following command in a terminal window:rails command with the path to your new
application as an argument. For example, to create your new
application at /var/www/cookbook
(and the cookbook directory doesn’t exist yet),
type the following command in a terminal window:$ rails /var/www/cookbook
rails command creates the directory for your project using the path
you supplied, as well as a number of subdirectories that organize your
project’s code by the function it performs within the MVC environment. The rails command also accepts several
command-line options. You can view these options by typing:$ rails --help
--database=database_type, where database_type is one of the following:
mysql, oracle, postgresql, sqlite2, or sqlite3. For example, to use PostgreSQL as
your database instead of the default, MySQL, enter the following
command:$ rails /var/www/cookbook --database=postgresql
ActionController::Base. Each of these
files should be named after the model they control followed by
scaffold method
of Action Controller. The second is to use the Rails
scaffolding generator to create the scaffolding code in your
application directory.$ ruby script/generate migration build_db
class BuildDb < ActiveRecord::Migration
def self.up
create_table :languages, :force => true do |t|
t.column :name, :string
t.column :description, :string
end
end
def self.down
drop_table :languages
end
end$ rake db:migrate
scaffoldruby-dev and
build-essential packages installed,
and Mac OS X users should have Apple’s XCode Tools. Once the
prerequisites are satisfied, install Mongrel using RubyGems:$ sudo gem install mongrel
$ mongrel_rails start -d
$ mongrel_rails stop
$ tail -f log/development.log
mongrel_rails
command to your path. For a list of available options, type that
command by itself:$ mongrel_rails
Usage: mongrel_rails <command> [options]
Available commands are:
- restart
- start
- stop
Each command takes -h as an option to get help.Employees.Employee model is created based on a
table named employees.EmployeesController or AccountsController.class Chapter < ActiveRecord::Base has_many :recipes end
--pretend option (or simply -p) when using script/generate to create scaffolding,
controllers, or models.$ ruby script/generate scaffold -p recipe
exists app/controllers/
exists app/helpers/
create app/views/recipes
exists test/functional/
dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
create app/models/recipe.rb
create test/unit/recipe_test.rb
create test/fixtures/recipes.yml
create app/views/recipes/_form.rhtml
create app/views/recipes/list.rhtml
create app/views/recipes/show.rhtml
create app/views/recipes/new.rhtml
create app/views/recipes/edit.rhtml
create app/controllers/recipes_controller.rb
create test/functional/recipes_controller_test.rb
create app/helpers/recipes_helper.rb
create app/views/layouts/recipes.rhtml
create public/stylesheets/scaffold.cs
$ rake rails:freeze:edge
svn:externals
property with the svn propedit
command:$ svn propedit svn:externals vendor
svn propedit opens your default editor (as indicated by the EDITOR
environment variable) on an empty page. In that page, type the
following value for svn:externals:
rails http://dev.rubyonrails.org/svn/rails/trunk/
Set new value for property 'svn:externals' on 'vendor'
$ svn ci -m 'modified externals on vendor to fetch from the Rails trunk' Sending vendor Committed revision 4.
$ svn proplist --verbose vendor
Properties on 'vendor':
svn:externals : rails http://dev.rubyonrails.org/svn/rails/trunk/externals property
set on vendor, the next time you
update your project with svn, the
vendor directory will pull down the latest Rails
version from the trunk:$ svn update
rake rails:freeze:edge command performs a
Subversion export of the last version of Rails from the public
subversion repository ($ ssh-keygen -t dsa
$ cat ~/.ssh/id_dsa.pub | ssh rob@myhost "cat >> .ssh/authorized_keys2"
myhost with the domain name or
IP address of your server.$ chmod 700 ~/.ssh
$ chmod 600 ~/.ssh/authorized_keys2