Rails 3 csv import to local database

May 30, 2012 |

I am a novice at best but this has worked for me multiple times so I figured I would share.

With Ruby 1.9.2, Fastercsv is a standard library so you no longer need to reference ‘fastercsv’ you can simply reference ‘csv’  (this is for older Ruby users)

The code is pretty straight forward:

namespace :db do
desc "load user data from csv"
 task :load_csv_data => :environment do
 require 'csv'
CSV.foreach("test_data.csv") do |row|
 Lead.create(
 :first_name => row[0],
 :last_name => row[1],
 :company => row[2],
 :address_one => row[3],
 :address_two => row[4],
 :address_city => row[5],
 :address_state => row[6],
 :address_zip => row[7],
 :phone => row[8],
 :transaction_date => row[9],
 :transaction_type => row[10],
 :lessor => row[11],
 :manufacturer => row[13],
 :model => row[14],
 :equipment_description => row[15],
 :equipment_serial_number => row[18],
 :transaction_value => row[19],
 :cost => row[20]
 )
 end
 end
end

 

reference the csv file you want to import and run this inside its namespace: rake db:load_csv_data

hope this helps you out!

Site Launch: JusticeForYou

May 24, 2012 |

We are proud to announce that we have been working on a facelift for the Phillips Law Firm website.  Phillips Law Firm is one of the largest Personal Injury Law firms in the country.  They needed to modernize and simplify the site to make it easier to use and stronger at converting users.

We are exited about the growth that PLF has seen in their Organic Search Engine traffic.  We have seen a 100% growth since working with them. In fact this is what they had to say about our services.

“Working with Ravenna Interactive improved our bottom line.  In addition to quick turnaround times, their understanding of ROI made for a profitable relationship.  Ravenna improved our web leads by than 100% in 6 months, a vast improvement in our web presence, and the ability to implement new marketing actions with ease. Ravenna managed all aspects of our web presence.”
Glenn Phillips – Phillips Law Firm

 

HTML5 and input placeholders with a fallback

April 2, 2012 |

HTML5 is making coding easier.  No other way to say it.  In the past to create default text in an <input> field you had to do a bunch of different hacks or background image swapping… Now you can do this following:

<input type="text" />

“My Placeholder Text” is the text presented to the end user.  Different web browsers handle the attribute differently but when the end user begins typing, the text disappears and is replaced with whatever text they are typing.

This solution is great except we still have to account for IE7/8/9 (seriously how is IE’s unreleased browsers the only one that may support html5.  How behind the times is Redmon), Older FF, Safari and Chrome.   To make this work with those browsers I employ a Modernizr.  Simple go to Modernizr, click to build your own Production code.  In this case we only need Input Attributes.  Finally to bring it all together I used a cool little bit of code from This Guy, to make it all work.

/**
 * HTML5 Placeholder Text jQuery Fallback with Modernizr
 *
 * @url http://uniquemethod.com/
 * @author Unique Method
 */
jQuery(function()
{
 // check placeholder browser support
 if (!Modernizr.input.placeholder)
 {

 // set placeholder values
 jQuery(this).find('[placeholder]').each(function()
 {
 if (jQuery(this).val() == '') // if field is empty
 {
 jQuery(this).val( jQuery(this).attr('placeholder') );
 }
 });

 // focus and blur of placeholders
 jQuery('[placeholder]').focus(function()
 {
 if (jQuery(this).val() == jQuery(this).attr('placeholder'))
 {
 jQuery(this).val('');
 jQuery(this).removeClass('placeholder');
 }
 }).blur(function()
 {
 if (jQuery(this).val() == '' || jQuery(this).val() == jQuery(this).attr('placeholder'))
 {
 jQuery(this).val(jQuery(this).attr('placeholder'));
 jQuery(this).addClass('placeholder');
 }
 });

 // remove placeholders on submit
 jQuery('[placeholder]').closest('form').submit(function()
 {
 jQuery(this).find('[placeholder]').each(function()
 {
 if (jQuery(this).val() == jQuery(this).attr('placeholder'))
 {
 jQuery(this).val('');
 }
 })
 });

 }
});

Graphic Design… This is how it is!

February 16, 2012 |

After working in the industry for a while this is pretty self explanatory.

How To: Jquery UI linkable tabs

January 22, 2012 |

I pulled this together with help from the amazing community that exists around web.dev. The solution is from: a comment at a blog.  After digging for awhile I finally found this and it worked like a charm.

So here is how we do this:

 

First you need Jquery, and Jquery UI with tabs.  I also included “fade” support but you can customize your own build.  From there, simply implement the tabs as is clearly outlined in the docs.

Next is the magic:

$('#tabs-set').tabs({
 'select': function(){$(this).index($(document.location.hash));},
 'load': function(event, ui){document.location.hash = ui.panel.id;},
 selected: -1
 });

This in its simplest form allows you to link to a given tab from outside the page.  A good use case is a homepage slider that needs to link to different areas of a sub page.  The url for this is: http://domain.com/page#tabid.

I built this into a WP install and it works great.

NOTE: selected: -1 simply hides all tabs on page load.  For my specific instance this was important. Many others won’t need this.

Site Launch – Phillips Webster

October 25, 2011 |

We are proud to announce that we have been working on a facelift for the Phillips Webster website.  Phillips Webster is one of the largest Personal Injury Law firms in the country.  They needed to modernize and simplify the site to make it easier to use and stronger at converting users.

We are exited about the growth that PW has seen in their Organic Search Engine traffic.  We have seen a 20% growth since working with them

Site Launch – Squint Showcase

August 25, 2011 |

“A curated exhibition gallery for creative talent wanting access to leading UK and US advertising agencies.”

Squint Showcase is the creation of Christine Saunders and Janet Saville, who run Squint from two sides of the world, Seattle, WA, and London UK. The goal with the site is to simply create a place for high quality work to be showcased.

WordPress 3 custom post type date based archive

August 17, 2011 |

We needed to implement this for our great client Seattleite.com.  We built a Events system for them using custom post types (CPT) but needed to create a date based archive so that someone could click on a calendar day and be taken to that day and see all events for that day.  This solution is geared around an events custom post type but could work with many other types, using the post-date instead of a custom field. Continue reading “WordPress 3 custom post type date based archive” »

Site Launch – Obsess Marketing

August 5, 2011 |

“Obsess is a Flash Marketing Team dedicated to helping create, manage and maximize the energy surrounding THE MOMENT when consumers meet your new product, experience your brand, and fall in love.”

Obsess Marketing was a great project for a great client, and in conjunction with 4th Avenue Media.  The site is simple and effective at promoting Obsess.

Site Launch – IMPACT Players

July 20, 2011 |

Impact Players is a great group that does great work challenging fathers to be leaders in their families, and in their communities.  “IMPACT provides a forum for men to ask deeper questions about life. We believe that there are concrete answers to the questions above, and we’d love for you to join us for our monthly meeting where we tackle these types of questions and issues.”

This was a great site for a great cause, and in conjunction with 4th Avenue Media!