Problem
You want to work with sqlite3 in Mandriva (2009), but the standard installation doesn’t work, and you cannot use urpmi sqlite3.
Solution
You need to install the sqlite3 command line tools, like:
urpmi sqlite3-tools
Problem
You want to work with sqlite3 in Mandriva (2009), but the standard installation doesn’t work, and you cannot use urpmi sqlite3.
Solution
You need to install the sqlite3 command line tools, like:
urpmi sqlite3-tools
Problem
After a recent upgrade to a newer rails version the gem package manager seems to be broken. Everytime you try to use gem install gem_name, you get the following error:
ERROR: While executing gem ... (Gem::GemNotFoundException)
Deleting the cached files as suggested in other posts results in the error:
ERROR: While executing gem ... (ArgumentError)
Solution
As suggested here, you need to do:
gem install rubygems-update update_rubygems
which should be updating the gem version to the latest one, ie 1.3.0
Problem
When trying to use facebooker according to the Developing facebook platform applications with rails book, in the network_test step you are getting the following error:
FBML Error (line 5): illegal tag "body" under "fb:canvas"
Solution
It should be caused because you are using the facebooker gem instead of the plugin.
Install the plugin:
ruby script/plugin install git://github.com/mmangino/facebooker.git
Problem
You want to install the git (Fast version control system) in Mandriva, but using:
urpmi git
installs the GNU Interactive Tools.
Solution
Use the following to install the version control system
urpmi git-core
Problem
You want to send emails from a Ruby on Rails application, when there is a specific condition on a database table. If the database table gets modified by another application outside Rails you cannot use an observer model.
Solution
We already assume that:
So the steps we have to follow are:
ActionMailer::Base.smtp_settings = {
:address => "yourmailserver.com",
:port => 25,
:domain => "your.domain.com",
:authentication => :login,
:user_name => "your_smtp_username",
:password => "your_smtp_password",
:raise_delivery_errors => true}
class VoicemailMailer < ActionMailer::Base
# We need the open-uri to be able to open url *** if the file to attach is in an http location ***
require 'open-uri'
def sent(email_to,email_from,email_subject,email_body,voicemail_to_send)
# Check to see if we have a file for the email body message
@subject = email_subject
@body = email_body
@recipients = email_to
@from = email_from
@sent_on = Time.now
# Split the file in directory and filename
file_path = File.split(voicemail_to_send)
file_dir = file_path[0]
file_name = file_path[1]
# Get the file
tmp_file = open(voicemail_to_send).read
part( :content_type => "application/wav",
:disposition => "attachment; filename=#{file_name}",
:transfer_encoding => "base64") do |attachment|
attachment.body = tmp_file
end
end
end
#!/usr/bin/env /path_to_your_app/script/runner
# get all the voicemails that have not been sent yet
voicemails_to_email = VoiceMail.find(:all, :conditions => 'updated_at is null')
# For all the voicemails we have, send them and update the field date_sent
for vm2email in voicemails_to_email do
# Get the number for the voicemail
number = Number.find(vm2email.number_id)
# check to see if the send to email is set for the number
if number.voicemail_email_set
# Get number details (email_to,email_from etc)
email_to = number.voicemail_email
voicemail_to_send = vm2email.audio
# Set other details
email_from = 'Service@yourdomain.com'
email_subject = 'Please find attached your voicemail message'
email_body = "Received on: #{Time.now} \n for number: #{number.phone_no}"
# Now send the email
VoicemailMailer.deliver_sent(email_to,email_from,email_subject,email_body,voicemail_to_send)
# And update the record's date_sent field
vm2email.updated_at = Time.now
vm2email.save
end
end
0,5,10,15,20,25,30,35,40,45,50,55 * * * * path_to_your_ror_app/lib/email_scheduler.rb
Today, there was an announcement about Dreamhost, having the new Passenger (mod_rails) feature ready for use with Ruby on Rails applications.
The full announcement is here.
It should be changing the way Rails applications are deployed, making it much easier.
Problem
You want to find out your UID for a specific domain that you have set up with google analytics.
Solution
When you first create the tracking code for your website, it’s quite obvious how to get the UID for that specific website.
If you decide later on to change your site, from drupal to wordrpess for example, it’s not quite clear where to get this UID, to use it with the new tracking plugin in the new site (which still uses the same domain name).
After some searching it turns out that to be able to find it you have to do the following:
Problem
You want to pass the £ sign to an http service, but the ruby CGI.escape encodes it incorrectly.
Solution
After using ruby’s CGI.escape for the string as:
sms_msg_tmp=CGI.escape(sms_code)
then replace the encoding with the pound sign encoding as in:
sms_msg=sms_msg_tmp.gsub('%C2%A3','%A3')
It should then pass the correct value for the £ sign.
Problem
Trying to use the heroku gem to clone a project and do local modifications I got the following error:
git: fatal error: `chdir' failed: permission denied.
Solution
It turns out that in Mandriva, when using:
sudo urpmi git
what gets installed is the ‘GNU Interactive Tools’ that has nothing to do with the git version control system.
So make sure you first uninstall the git installed:
sudo rpm -e git
and then install the Git – Fast version control system, by doing:
sudo urpmi git-core
You should then be able to clone a heroku application:
heroku clone myapp
Problem
You want to convert some legacy tables created in Paradox (.db, .px) to another format so you can use it in MySQL.
Solution
Download the px tools from here.
Follow the instructions, in the INSTALL file after you untar the file.
You should have to do the usual three step linux installation:
configure make sudo make install
Afterwards to make sure that the .db file is a paradox file run:
pxinfo -f path/to/paradox/db/file.db
The program should read the header and report back with something along the lines:
File-Version: Paradox 7.x Filetype: indexed .DB ....
To export each Paradox db file to an sql statement run the following:
pxsqldump -d mysql -f path/to/paradox/file.db > path/to/mysql/exported/file.sql