Archive for June, 2008

How to get phpmyadmin setup with nginx on slicehost

I used this forum post and this article

ssh with a different port

Usually the standard port for ssh is 22 on your server, but if you choose to change this to help stop dirty scripts then you have to ssh in with the following command

For example, if your port # was changed to 8888

 ssh -p 8888 yourusername@youriporwebsite.com

Setting up slicehost

1. Sign up for an account at slicehost
2. Use the Deploying Rails Applications Book Chapter 4. Starting at p. 74. (Simultaneously, read the Slicehost Wiki to make sure you aren’t missing something specific to slicehost (I actually mostly followed the wiki)
a. Once it got to the point of installing Ruby on Rails though (from the wiki), I opted to go with the install instructions from podcast episode 042 from sd.rb (San Diego Ruby group)
b. ACTUALLY, turns out that the video did not work so well. I had the following issue with gem update so I reverted back to the wiki which basically installs the gems from source. (My slice was apparently too small to handle all the gems for a gem update)
c. That, also did not do the trick. Came across this about an issue with Gem 1.1.1 and from there I found a link to here posted just 8 hours ago
d. But it looks like 1.1.2 is coming out tomorrow anyway so I’ll probably just end up updating
e. Still didn’t get it to work. I either need to upgrade to a faster slice, wait for 1.1.2 (1 day away), or downgrade to an early gem version. I am going to wait for 1.1.2. Hopefully, that will solve the problem.

3. Two days later 1.1.2 came out, and the following forum was updated with info for how to do things. - specifically, how to install ubuntu and rails

4. Then I went through improving nginx configuration

5. Next I went through installing multiple domains through virtual hosts with nginex, but it’s pretty easy you just do a sudo gem install capistrano

6. To install git I used the following tutorial

7. Then i used this to install capistrano

8. There quite a few more configurations I made. Too many to really keep track of until I become more familiar with the process. This was quite helpful though.

Vim editing cheatsheet

Vim editing can be a pain in the arse, but you pretty much need to know it to do anything on the server properly. (I know, there are alternatives like nano, but pretty much all the examples use vim)

Go for a cheatsheet. Old, tried, and true.

By the way, nano is much easier though, and it lists the commands right in front of you. Awesome. To use it type nano and then the name of the file in you server terminal.

For example,

nano /etc/ssh/sshd_config

Removing and Deleting old git releases

There comes a time when you don’t need all your releases of your gitified app on your server. It just takes up way too much space. In this event, you can issue the following command for your capistrano deploy

This, of course, assumes you’ve already setup Capistrano to work with Git for your project.

cap deploy:cleanup

It might take a while to delete all those though so just be patient. I had 150 releases to delete and it took about 7 minutes.

How to remove and delete old git releases

motte_cms - a basic rails based content management system

I’ve created a freely available content management system. It is rails based and easy to install. It includes wysiwyg editing using tinymce, image insertion, page management, sub pages, page re-ordering using ajax, and user management.

motte_cms - project page

motte_cms - github

SQLite Manager

I am starting to using sqlite in my rails apps for experimentation sake, and to keep up with the community. However, no one seems to have any advice on what sql manager to use. For MySQL, previously, I was using CocoaMySQL. It was free and worked pretty well.

So far, for sqlite3, all I can find that seems useful is the SQLiteManager.

Adding/Inserting content into a table within a rails migration

class CreatePages < ActiveRecord::Migration
  def self.up
     create_table :pages do |t|
        t.integer :parent_id, :default => 0, :null => false
        t.string :title
        t.text :body
        t.integer :position
        t.boolean :hidden, :default => false
        t.boolean :main_nav
        t.boolean :top_nav
        t.boolean :footer_nav
        t.timestamps
      end

      Page.create :title => 'Home', :body => 'This is the home page. Enjoy motte_cms. Be sure to send improvement requests to scott@scottmotte.com.', :main_nav => '1', :footer_nav => '1'
  end

  def self.down
    drop_table :pages
  end
end

Others ways to do this - including fixtures.

Ryan Bates also has an episode on fixtures in Rails 2.0.

syntax error, unexpected ‘\n’, expecting tCOLON2 or ‘[’ or ‘.’ in rails migrations, sqlite3

Are you getting the following error:

syntax error, unexpected '\n', expecting tCOLON2 or '[' or '.'

I was too, and it was a stupid mistake.

I had my migrations’ lines mixed up and containing a comma where there should not have been one.

Incorrect format:

class CreatePages < ActiveRecord::Migration
  def self.up
     create_table :pages do |t|
        t.parent_id, :integer, :default => 0, :null => false
        t.string :title
        t.text :body
        t.position, :integer
        t.boolean :hidden, :default => false
        t.main_nav, :boolean
        t.top_nav, :boolean
        t.footer_nav, :boolean
        t.timestamps
      end
  end

  def self.down
    drop_table :pages
  end
end

Correct format:

class CreatePages < ActiveRecord::Migration
  def self.up
     create_table :pages do |t|
        t.integer :parent_id, :default => 0, :null => false
        t.string :title
        t.text :body
        t.integer :position
        t.boolean :hidden, :default => false
        t.boolean :main_nav
        t.boolean :top_nav
        t.boolean :footer_nav
        t.timestamps
      end
  end

  def self.down
    drop_table :pages
  end
end

Getting sqlite3 to work on Tiger with Rails 2.1.0

Two steps:
1. Install sqlite3 on your mac
2. Install the sqlite gem

Step 1:
On Mac OS X Leopard - no worries. It’s already installed and working great!

On Mac OS X Tiger - be careful. It is technically already installed, but you might have problems with migrations still.
If you are having problems, you need to do the following:
A. sudo gem uninstall sqlite3-ruby
B. run the following commands in your terminal command line

curl -O http://www.sqlite.org/sqlite-3.5.9.tar.gz
$ tar xzf sqlite-3.5.9.tar.gz
$ cd sqlite-3.5.9
$ ./configure --prefix=/usr/local
$ make
$ sudo make install

(Thanks to Accidental Technologist.)

Step 2:
run ’sudo gem install sqlite3-ruby’ in your terminal.

———-
Miscellaneous comments as I was trying to figure this out. These really are not all that useful.
RailsWiki instructions for sqlite3

HOWEVER, you might still get this error like I did. Also here.

Unfortunately, those forum links did not help.

Try this: “I had the above problem with Rails 2.0.2 and sqlite3 3.1.2, but the same procedure (compiling sqlite3 3.5.4 from source, removing the sqlite3-ruby gem, and reinstalling it) worked for me. I didn?t uninstall and reinstall all my gems, just sqlite3-ruby.?Ben Kimball”

And thank you mislav for instructions on how to get it going. Never mind. Not helpful to Tiger users.