I am a rails rookie and fear that my question is woefully ignorant - please be gentle.
I am building an app that will catalog and monitor other websites, and need to synchronize with an external data source (thus overiding primary key).
I have the model below, but i cannot figure out the routing for accessing individual records (tho list works)
any pointers?
class Affiliate < ActiveRecord::Base
require 'resolv'
require 'rubygems'
require 'rwebthumb'
include Simplificator::Webthumb
self.primary_key = "domain"
validates_uniqueness_of :domain
validates_presence_of [:org_name, :url], :message => "can't be blank"
after_create :generate_thumbnail
def to_param
id.chomp.gsub(".","")
end
def generate_thumbnail
wt = Webthumb.new(APP_CONFIG['webthumb_api']['key'])
job = wt.thumbnail(:url => url)
job.write_file(job.fetch_when_complete(:medium2), "#{RAILS_ROOT}/public/data/#{id}.png")
end
def thumbnail_url
"/data/#{id}.png"
end
def thumbnail_localfile
File.exist?("#{RAILS_ROOT}/public/data/#{id}.png") ? "#{RAILS_ROOT}/public/data/#{id}.png" : nil
end
def thumbnail_last_updated
if thumbnail_localfile
File.new(thumbnail_localfile).mtime.to_s(:long)
else
"No such file"
end
end
end