Weblog - 10 items
Rails 2.1 migrations conversion
If after upgrading to Rails 2.1 your migrations try and go from the first migration you need to populate the schema migrations table with all migrations that have been done.
Use the following sql statement, if you have to many migrations for this a ruby script with loop for the number of migrations should work well.
INSERT INTO schema_migrations VALUES ('1'),('2'),('3'),('4'),('5')
IE7 sercure and nonsecure items message with ssl
There are 2 non obvious content items that can be causing this
1. iframe with no valid src attribute.
2. background images that are not specified as https://
Recursively delete files on a wildcard match
find . -name "*.ext" -exec rm '{}' ';'
Will recursively delete all files under the current dir containing .ext in the filename.
Use name@domain.com pop, imap and smtp usernames with virtualmin
Go to "Server template settings"
and edit "mail for domain" settings
set to desired format.
If you still have trouble with smtp check this
/etc/sysconfig/saslauthd, find the line that starts with FLAGS=, and add "-r". So, you'd make it:
FLAGS="-r"
Ruby on Rails Making string primary key work for tests
If you want to have primary keys with a type of :string in Ruby on Rails you can do so by using the change_column method after creating a table in the migration.
eg.
create_table "g_languages", :force => true do |t|
t.column "name", :string, :limit => 50, :default => "", :null => false
end
change_column "g_languages", :id, :string, {:limit => 5, :default => "", :null => false}
Problem is if you want to use this Model in your tests the id is autmatically set to :integer and youre string change does not come accross. (The schema.rb is created without any id/primary key info so :integer is assumed)
The fix
Alter the table using ActiveRecord::Migration in test_helper.rb before the fixtures are loaded.
eg.
migrater = ActiveRecord::Migration
migrater.change_column :g_languages, :id, :string, {:limit => 5, :default => "", :null => false}
fixtures :all
Change / swtich subversion repository url on working copy
svn switch --relocate [from URL] [to URL]
Install exception notifier
run
script/plugin install exception_notification
Configure (put in environment.rb or /config/initializers file)
ExceptionNotifier.exception_recipients = %w(emial@address.net)
ExceptionNotifier.sender_address = %("Application Error" )
ExceptionNotifier.email_prefix = "[ error] "
Put the following in application_controller.rb
include ExceptionNotifiable
ActiveRecord Has many through and assignment
With Has many through associaitions if you do a simple assignment of an entire collection it does not work.
eg.
2 models Asset and Client have a has_many through relation ship with each other through AssetClient.
The following does not work
@asset.clients = @clients
So a method is needed in Asset like so to make it work.
def clients=(new_clients)
new_clients.each do |item|
clients << item unless clients.include?(item)
end
clients_to_remove = clients - new_clients
clients_to_remove.each do |item|
clients.delete(item)
end
end
Import Mail from Horde to Gmail in folders with Mac Os x
You can import all your emails into Gmail using the gmail's pop account reading but you loose all your folder orgainisation that you have setup in Horde.
The way I got around that was to read all the emails for particular account into mail on Mac os x using IMAP. This created an account on my Mac with all the emails sorted in there folders.
I then created another IMAP account for gmail and copied the various folders (5 at a time) over to my gmail IMAP account.
My Mac in turn updated gmail with all the correct folders (got turned into labels in gmail) with mails inside.
The only glich was that the sent items were put up in a folder/label rather than put in the Gmails sent folder.
Unwanted left and right margins in floating elements in IE6
In IE6 floating elements get assigned a compulsory 3px left and right margin. This is a real pain if you say have 10 images you want to float alongside each other with no margin.
Fix:
You can change their display to inline
ie. style=>"display: inline"
Then they will still have the floating affect but with out the margin.
The next problem is that IE6 will put a margin on the bottom of the bottom row of images (if inside a cell or div tag).
Fix:
Set the height of div or cell to the correct height and the overflow to hidden
ie. style=>"overflow: hidden"
Note: If your containing div is not a set hight you can instead put a div around each image setting the width and height and set overflow to hidden and float these divs instead.
