Skip to content

Instantly share code, notes, and snippets.

desc "Import access control logs"
task :fetch_accesscontrol => :environment do
# Logs into website and retrieved list of events.
require 'rubygems'
require 'mechanize'
require 'logger'
# Create a new mechanize object
agent = Mechanize.new
@dannymcc
dannymcc / gist:2413677
Created April 18, 2012 13:48
Fix whenever gem ruby issue
sudo ln -s /usr/local/bin/ruby /usr/bin/.
@dannymcc
dannymcc / gist:2438840
Created April 21, 2012 17:59
Copy local ssh public key to remote ssh server
scp ~/.ssh/id_rsa.pub user@server:~/.ssh/authorized_keys
I'm having some trouble working with a legacy database. I've read through a few tutorials and have started work by simply listing everything in the database with the correct column names etc. It's going well but now I've come to try and associate the models with each other.
I'm getting the following error:
Mysql2::Error: Unknown column 'animal.client_id' in 'where clause': SELECT `animal`.* FROM `animal` WHERE `animal`.`client_id` = 1
The models are as follows:
**client.rb**
class Clinical < ActiveRecord::Base
# ... snip rest of model...
def self.income_by_month
select( 'YEAR(transactiondate) as year, MONTH(transactiondate) as month, SUM(LineBalance) as income' )
.where(:payment => 0 )
.where('LineBalance <> 0' )
.where('analysiscode <> 213' )
.group(:monthyear)
Started GET "/reports" for 192.168.239.1 at 2012-05-01 14:50:47 +0100
Processing by ReportsController#index as HTML
Clinical Load (0.7ms) SELECT YEAR(transactiondate) as year, MONTH(transactiondate) as month, SUM(LineBalance) as income FROM `clinical` WHERE `clinical`.`payment` = 0 AND (LineBalance <> 0) AND (analysiscode <> 213) GROUP BY monthyear ORDER BY FullDateTime DESC LIMIT 1
Mysql2::Error: Unknown column 'clinical.payment' in 'where clause': SELECT YEAR(transactiondate) as year, MONTH(transactiondate) as month, SUM(LineBalance) as income FROM `clinical` WHERE `clinical`.`payment` = 0 AND (LineBalance <> 0) AND (analysiscode <> 213) GROUP BY monthyear ORDER BY FullDateTime DESC LIMIT 1
Rendered reports/_income_by_month.erb (8.1ms)
Rendered reports/index.html.erb within layouts/application (8.8ms)
Completed 500 Internal Server Error in 18ms
ActionView::Template::Error (Mysql2::Error: Unknown column 'clinical.payment' in 'where clause': SELECT YEAR(transactiondate) as year, MONTH(transactionda
class ReportMailer < ActionMailer::Base
default from: "[email protected]"
mail to: "[email protected]", subject: "Practice Finance Report"
ReportMailer.deliver_income_by_month_report(Clinical.income_by_month)
end
------------------------------------------------------------------------------
RubyGems installed the following executables:
/usr/local/bin/gem
sudo: unable to resolve host hostname
sudo: add-apt-repository: command not found
@dannymcc
dannymcc / gist:2605327
Created May 5, 2012 20:18
Magento 1.5 to 1.6
rm -rf /var/cache session
./mage mage-setup .
./mage config-set preferred_state stable
./mage list-installed
./mage list-upgrades
./mage install http://connect20.magentocommerce.com/community Mage_All_Latest --force
./shell php indexer.php reindexall
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "smtp.postmarkapp.com",
port: 25,
enable_starttls_auto: true,
user_name: ENV["9eedsdasdaskdnasd"]
password: ENV["dsldkansdkad32-7eee2576ffe0"]
}