12th
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.
Use Case Scenario: Watching movies on the TV via my Laptop. MacBook with Mini-DV to RGB adapter. RGB and 1/8” stereo headphone jack run to back of TV. Input: RGB. After about 15 minutes of…
Go here:
/Library/Ruby/Gems/1.8/gems/rails-X.X.X/lib/rails_generator/generators/components/
I was getting this error a lot:
VirtualHost *:80 — mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
The fix:
I had to remove the default site:
cd /etc/apache2/sites-enabled/
sudo rm 000-default
The file is still available here:
/etc/apache2/sites-available/
But is not conflicting with the config files that deprec sets up.
I over complicated things in my previous solution, and found a better solution while trying to get the WYSIWYG editor to work inside an AJAX form using rails’ remote_form_for.
Using the YUI editor example, set handleSubmit to false and add this right after the MyEditor.render();
// Nate's better Handle Submit
function myHandleFormSubmit(e){
if(state == 'off') {
myEditor.cleanHTML();
};
};
Event.on(myEditor.get('element').form, 'submit', myHandleFormSubmit, myEditor, true);
When doing this and using a AJAX form, try this:
// Nate's better Handle Submit (AJAX version)
function myHandleFormSubmit(e){
if(state == 'off') {
myEditor.cleanHTML();
};
Connect.setForm(e.target);
Connect.asyncRequest('POST', e.target.action, callback, '_method=put');
Event.stopEvent(e);
};
var handleSuccess = function(o){ eval(o.responseText); };
var callback = { success:handleSuccess };
Event.on(myEditor.get('element').form, 'submit', myHandleFormSubmit, myEditor, true);
Hope this helps