There was a great deal of buzz around getting your site listed on relevant news sites via press releases. Is there any merit to this? Hells yeah. Once you send your press release out o the wire there is a good chance that Yahoo news, Google news, Reuters and other aggregators will pick it up if it is press worthy material. If this happens then the blogosphere usually repurposes the release and takes out excerpts or references. Hopefully some of those references will be your website URL. The most common mistake that I see is companies forgetting to use an anchored link to their own website in their releases. Duh?? Many writers, especially bloggers are too lazy to strip this out of the releases and if they copy and paste the news then you get another inbound link hopefully from a blogger that has relevant content to your business or vertical. If you happen to have something press worthy enough to get to the home page of Digg or other social news media sites then it becomes a home run for your link strategy. Here are a few good press release distribution services and some of these guys even have SEO upgrades for releases. Money!
Live Search Webmaster Center
MSN has recently launched its own Webmaster Tools (Beta) center which is similar to the Google Webmaster and Yahoo Site Explorer webmaster areas. You can register you website and sitemaps with them now at:
Use the Webmaster Tools to troubleshoot the crawling and indexing of your website, submit sitemaps and view statistics about your websites. Once you have your site authenticated with a HTML tag then you can view a site summary, your rank on MSN, top keywords, top outbound links and top backlinks.
You can submit your XML sitemap for better results. Sitemaps help the Live Search robot find all of the files to be indexed. You’ll get the best indexing results by using robots.txt autodiscovery.
On the website status page you’ll see the date from the last crawl or your site along with the total number of pages that were indexed.
If you haven’t submitted your site and it doesn’t already appear in the MSN Live index then you can submit to MSN below:
{ Comments }
214-748-3647
The number is 214-748-3647, and as fate has it…somebody from Texas is very unlucky.
One of the sites I have been working on saves the phone numbers of condominiums to the database. Take a slight oversight on my part, mix in a improperly declared column type, and poof…you have phone numbers storing incorrectly.
What did I learn from this little fiasco? It seems that phone numbers should be stored as strings, and not integers. More importantly, I should never get a phone number that is 231 -1.
{ Comments }
Google Enforces Display URL Policy
Google has recently made a change to its display URL policy on it’s paid search ads. Google claims this has always been its policy however it has seldom been enforced. The new rules will require a ad’s display URL to match the destination URL. So for example: a display url of www.somewebsite.com must land the user who clicks on the ads to the somewebsite.com website.
Advertisers are still allowed to send users to either a subdomain foo.somewebsite.com or a subdirectory somewebsite.com/foo/foo.html. Google claims this policy is in effect to minimize any surprise or confusion on the surfers behalf if they land on a website not listed in the display url.
For now all ads currently running will not be disapproved unless a complaint is filed or Google is notified about the directly. However all new advertisers or new ad placements will need to comply to these new restrictions.
{ Comments }
Update a single record’s attribute
Need to update a single record’s attribute? This will allow you to update a single attribute and save your record. If you use this method, you will also bypass any validation…beware, attributes can be updated even if the object is invalid.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # find the first Condo # update the flagged column with the params current_condo = Condo.find(:first) current_condo.update_attribute(:flagged, params[:submission][:flagged]) # find the the condo by permalink # set the condo.name and condo.zipcode # save condo = Condo.find_by_permalink("114-pike-street-condos") condo.name = "114 Pike Street Condos" condo.zipcode = "98105" condo.save! |
{ Comments }
Rails send email tutorial
Want to send an email using Rails? I struggled with this for a while and I’m sure many of you do too. This post will cover the basic implementation of a mailer, it is tested to work in Rails 2.0.2.
Rails Mailer Overview
1) script/generate mailer postoffice
2) Create a method for your mailer (models/postoffice.rb)
3) Create your email template using welcome.text.html.erb and welcome.text.plain.erb (views/postoffice)
4) Deliver your message
5) If you’re testing locally, make sure postfix is running
Begin by opening your terminal:
add3-imac: jon$ rails mailer_example -- output truncated -- add3-imac: jon$ cd mailer_example/ add3-imac:mailer_example jon$ script/generate mailer postoffice exists app/models/ create app/views/postoffice exists test/unit/ create test/fixtures/postoffice create app/models/postoffice.rb create test/unit/postoffice_test.rb
Next, we are going to create a method for our mailer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | class Postoffice < ActionMailer::Base # located in models/postoffice.rb # make note of the headers, content type, and time sent # these help prevent your email from being flagged as spam def welcome(name, email) @recipients = "user@host.com" @from = params[:contact][:email] headers "Reply-to" => "#{email}" @subject = "Welcome to Add Three" @sent_on = Time.now @content_type = "text/html" body[:name] = name body[:email] = email end end |
Now that our method is created, let’s modify the email templates:
1 2 3 4 5 6 7 8 9 10 11 12 13 | # located in views/postoffice # we can access the variables we declared in models/postoffice.rb # body[:name] = name is accessed by @name # body[:email] = email is accessedby @email # welcome.text.html.erb # note the HTML <p>Welcome to AddThree <i><%= @name %></i>. </p> <p>The address we have on file for you is <b><%= @email %></b>, please let us know if this is incorrect.</p> # welcome.text.plain.erb Welcome to AddThree <%= @name %>. The address we have on file for you is <%= @email %>, please let us know if this is incorrect. |
Now that our mailer and templates arein place, let’s deliver the email!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | class Registration < ApplicationController # controllers/registration_controller.rb # assume the Registration controller already existed # assume @user.name and @user.email have been declared def send_welcome_email # triggered via: # http://localhost:3000/registration/send_welcome_email # note the deliver_ prefix, this is IMPORTANT Postoffice.deliver_welcome(@user.name, @user.email) # optional, but I like to keep people informed flash[:notice] = "You've successfuly registered. Please check your email for a confirmation!" # render the default action render :action => 'index' end end |
If you’re testing locally, make sure postfix is running
add3-imac:mailer_example jon$ sudo postfix start Password: postfix/postfix-script: starting the Postfix mail system
Everything should be working! Was this helpful? Link to me and leave a comment!
{ Comments }
Format phone number in Rails
Recently, I have needed to take a number string and format it to a phone number. This was a PITA in PHP, fortunately, Rails includes some methods that will make the formatting of phone numbers much easier.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | # number_to_phone(number, options = {}) # Formats a number into a US phone number (e.g., (555) 123-9876). # You can customize the format in the options hash. # # Options # # :area_code - Adds parentheses around the area code. # :delimiter - Specifies the delimiter to use (defaults to "-"). # :extension - Specifies an extension to add to the end of the generated number. # :country_code - Sets the country code for the phone number. # returns => 123-555-1234 number_to_phone(1235551234) # returns => (123) 555-1234 number_to_phone(1235551234, :area_code => true) # returns => 123 555 1234 number_to_phone(1235551234, :delimiter => " ") # returns => (123) 555-1234 x 555 number_to_phone(1235551234, :area_code => true, :extension => 555) # returns => +1-123-555-1234 number_to_phone(1235551234, :country_code => 1) # returns => +1.123.555.1234 x 1343 number_to_phone(1235551234, :country_code => 1, :extension => 1343, :delimiter => ".") |
Want to see it in action?
{ Comments }
Rails number to percentage helper
In the next few days I’m going to quickly touch on a few of Rail’s number helper methods. Lately I’ve been doing a lot of mathematical calculations that require percentages, the number_to_percentage method is quite handy.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # number_to_percentage(number, options = {}) # Formats a number as a percentage string (e.g., 65%). You can customize the format in the options hash. # Options # :precision - Sets the level of precision (defaults to 3). # :separator - Sets the separator between the units (defaults to "."). # Examples # returns 100.000% number_to_percentage(100) # returns 100% number_to_percentage(100, :precision => 0) # returns 302.24399% number_to_percentage(302.24398923423, :precision => 5) |
{ Comments }
Raise a value to a negative power in Ruby
I ran into a few kinks trying to raise some numbers to a negative power in Ruby. Ruby uses the ** operator for exponential calculations. Here’s the little hiccup I encountered:
1 2 3 4 5 6 7 8 | # 2^2 = 4 # here is the IRB dump >> 2**-2 => Rational(1, 4) # but I don't want the actual number! >> (2**-2).to_f => 0.25 |
{ Comments }
Rails 2.0 Timestamps
Thought timestamps were easy before? Timestamps in Rails 2.0 are super easy.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | # before class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.column :name, :string t.column :subscribed, :boolean, :default => true t.column :created_on, :timestamp t.column :updated_on, :timestamp end end def self.down drop_table :users end end # after class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.string :name t.boolean :subscribed, :default => true t.timestamps end end def self.down drop_table :users end end |
{ Comments }