27th
I seem to be referencing this frequently
We’re a mac shop. Anytime we have to go back to a PC, I’m not a fan. These are notes for any future development, and if you can get use out of them: great.
Problem 1) We couldn’t get our mProjector apps to run on a PC. They would compile, but not run. And not even give the nice “Please go download adobe flash player” messages. We were getting the full blown windows error.
Turns out: we had installed flash player from firefox. This, apparently, is not the same thing as installing the flash player from internet explorer. Once we did that, we could run the applications.
Problem 2) We certainly didn’t want our clients running into the same issues. Solution is to include flash player with the build, right? Well, for some unknown reason, our app doesn’t like flash player 10.0.32.18 that comes bundled with mProjector. Opening this page in IE showed that we were running 10.1.53.64 (Note visiting that link in FF shows that were were running 10.0.32.18). But why couldn’t we choose that from the drop down?
Turns out: This one took a call to ScreenTime’s Jim Roberts. He pointed me in the direction of this folder on our PC:
C:\Program Files\mProjector 4\Flash Players\Win
Which has a bunch of .ocx files that correspond to the available flash players for inclusion in our projector. He said I should find a newer .ocx file and see how it works. With a little bit of searching I found this folder:
C:\WINDOWS\system32\Macromed\Flash
Which had a Flash10h.ocx file, which I copied to the mProjector flash players folder. After restarting mProjector, I was able to choose Flash10h as a included player, and the app built and launched fine.
Problem 3) The app is freaking slow-as-molasses on a PC! It’s speedy in the browser, speedy on my Mac, but on this PC it’s moving at about 0.5 fps.
Turns out: I hate this kind of stuff. I’m throwing in the towel here. If you have any insight into what we can do to speed this application up, please let me know.
github.com/nathancolgate/s3-swf-upload-plugin
The good stuff starts around 7:30!
S3SwfUpload allows user to upload a file to S3 directly, so you can save the cost of uploading process…
What I’d like to do:
message = Notifier.password_reset_instructions(self)
Delayed::Job.enqueue MailerJob.new(message)
What happens when I do:
TypeError in Public/password resetsController#create
can’t dump anonymous class Class
…
/lib/delayed/backend/base.rb:61:in `payload_object=’
Problem line 61:
self[‘handler’] = object.to_yaml
Console confirms:
> user = User.find(:first)
> message = Notifier.password_reset_instructions(user)
> message.to_yaml
TypeError: can’t dump anonymous class Class
How I fixed it. Note: all of my notifier methods take a user argument, so I thought this was a little cleaner than coming up with a new job class for every email method:
Delayed::Job.enqueue NotifierJob.new(:password_reset_instructions,user_id)
And my lib/notifier_job.rb file:
class NotifierJob < Struct.new(:notifier_method,:user_id)
def perform
user = User.find(user_id)
Notifier.send(notifier_method,user).deliver
end
end
Hope that helps.
Because this took way too much time to figure out:
s3=RightAws::S3Interface.new(S3SwfUpload::S3Config.access_key_id, S3SwfUpload::S3Config.secret_access_key)
old_name = "tmp/#{self.video_file_name}"
new_name = original_video_file_path
bucket = S3SwfUpload::S3Config.bucket
(1..5).each do |try|
begin
acl_prop = s3.get_acl(bucket, old_name)
s3.rename(bucket, old_name, new_name)
s3.put_acl(bucket, new_name, acl_prop[:object])
break
rescue Exception => e
self.video_log += "Problem renaming file, trying again... #{e}\n"
sleep 1
end
end
I installed Exception Notifier on one of our Apps running Rails 2.3.3 and kept running into this error:
Net::SMTPFatalError (555 5.5.2 Syntax error..
A little bit of insight provided this heads up:
But as of Rails 2.3.3, the from email address will get the angle brackets added, so it can only contain the address.
Rails 2.3.4 is/was supposed to fix that, and includes tests so it will be ensured in future versions.
A quick look at the Exception Notifier README and I tried this:
ExceptionNotifier.sender_address = %("app.error@myapp.com)
Success!
The Session
class UserSession < Authlogic::Session::Base
validate :check_if_verified
private
def check_if_verified
errors.add(:base, "You have not yet verified your account") unless attempted_record && attempted_record.verified
end
end
The Migration
class AddVerifiedToUser < ActiveRecord::Migration
def self.up
add_column :users, :verified, :boolean, :default => false
end
def self.down
remove_column :users, :verified
end
end
The User Controller
class UsersController < ApplicationController
...
def create
@user = User.new(params[:user])
if @user.save
flash[:notice] = "Thanks for signing up, we've delivered an email to you with instructions on how to complete your registration!"
@user.deliver_verification_instructions!
redirect_to root_url
else
render :action => :new
end
end
end
The Verification Controller
class UserVerificationsController < ApplicationController
before_filter :load_user_using_perishable_token
def show
if @user
@user.verify!
flash[:notice] = "Thank you for verifying your account. You may now login."
end
redirect_to root_url
end
private
def load_user_using_perishable_token
@user = User.find_using_perishable_token(params[:id])
flash[:notice] = "Unable to find your account." unless @user
end
end
The User Model
class User < ActiveRecord::Base
acts_as_authentic
def deliver_password_reset_instructions!
reset_perishable_token!
Notifier.deliver_password_reset_instructions(self)
end
def verify!
self.verified = true
self.save
end
The Mailer
class Notifier < ApplicationMailer
default_url_options[:host] = "www.myurl.org"
def verification_instructions(user)
subject "Email Verification"
from "myurl"
recipients user.email
sent_on Time.now
body :verification_url => user_verification_url(user.perishable_token)
end
end
The Mailer View
Thank you for signing up for this site. Please click the following link to verify your email address:
<%= @verification_url %>
If the above URL does not work, try copying and pasting it into your browser. If you continue to have problems, please feel free to contact us.