Collecting Contacts Using Cardmagic-Contacts Pplug-in in Rails 2.3.8

Rails3

Cardmagic-Contacts is a rails plug-in which provides an interface to fetch contact list information from various email providers including Hotmail, AOL, Gmail, Plaxo, Yahoo and many more.

This example narrates how to extract contact list using Rails 2.3.8 and cardmagic-contacts plug-in

Step#1

  • Download the plug-in by running the command below to store the plug-in in the folder “vendor/plug-ins”

Windows

ruby script/plugin install git://github.com/cardmagic/contacts

Linux

ruby script/plugin http://github.com/cardmagic/contacts

Step#2

  • Write down the following code on the top of the controller class
require 'contacts'

Step#3

  • Pass the required gmail/yahoo/hotmail/AOL login & password from view
<div>
 
<div style="margin-left:25px;" >Invite <img src="../images/yahoo.JPG">Yahoo
 
Friends </div>
 
<div style="margin-left:25px;">Yahoo Email: <input type="text" name="email"
 
id="yahoo_email_id"></div>
<div style="margin-left:25px;">Password:   <input type="password"
 
name="email"  id="yahoo_pwd_id"></div>
 
<div style="margin-left:122px;margin-top:20px;"><input type="button"
 
value="Login" name="btn_submit" id="btn_submit" ></div>
 
</div>

Step#4

  • Create an action to fetch the list of contacts for a specific email id

def grab_contacts #Grab gmail contacts @gmail_contacts=Contacts::Gmail.new(login, password).contacts #or @gmail_contacts=Contacts.new(:gmail, login, password).contacts #Grab yahoo contacts @yahoo_contacts = Contacts::Yahoo.new(login, password).contacts #or @yahoo_contacts = Contacts.new(:yahoo, login, password).contacts #Grab hotmail contacts @hotmail_contacts =Contacts::Hotmail.new(login, password).contacts #or @hotmail_contacts = Contacts.new(:hotmail, login, password).contacts end

Step#5

  • Here is also alternate method to get the contacts by providing  email_id and password
any_mail = Contacts.guess(login, password).contacts

The “Contacts.guess” method will automatically concatenate the entire
address book from each of the successful logins. If the login and password is
working with multiple email accounts then it will grab the contacts from all accounts.

Step#6

  • Display the friends list in your view page
<table>
<th>
<td >Friends Name</td>
<td >Friends Email</td>
</th>
<tr>
<% @gmail_contacts.each do |contact| %>
<td><%=contact[0]%></td>
<td><%=contact[1]%></td>
<% end %>
</tr>
</table>

The Largest Selling Smartphone in USA Irrespective of Some Flaws

iphoneSince the release of the iPhone 5 and iOS 6, Apple has received mixed reviews for its new operating system as well as the iPhone 5 design.

But it has turned out to be the most popular smartphone in US, Apple has managed to gain around 48% of US market share from the iPhone5. Despite of some faulty applications, iPhone is still popular in US.

New features like a faster processor, taller screen, and slimmer design have definitely played a crucial part in driving the iPhone’s success to nearly half the share in the United States.

Surveys reveal that customer loyalty is also the reason behind Apple’s profound hold on the US market.

Besides the hardware updates, there are other features like Siri, cloud integration with the safari, and Facebook photo-sharing integrations, which works seamlessly with the device.

As expected, the Retina Display is pretty staggering and the A6 chip has improved the performance and speed to a great deal.

With the introduction of iOS6,iPhone application developers have found a better opportunity to explore more features and customization of their codes.

Since its first release, developers around the world are trying to develop applications for iOS6. The Retina display, taller screen, and faster A6 processor allow developers to create stunning applications with high-resolution images and complex functionalities.

Even though Apple’s Map App is filled with flaws and still remains unfixed, it seems to have no effect on iPhone lovers in the US. They solved the problem by using Google Maps instead of Apple’s native navigation app.

itunes-logo

 

 

 

We at Andolasoft develop exquisite iPhone and iPad apps for iOS6 devices. Our experienced iPhone developers use the latest resources to create apps that are engaging and fun. Our apps are rigorously tested to ensure no flaw exists.

Along with development we also release updates for our applications with each improvement in UI and functionalities.  Some of our apps are showcased in App Store which can be downloaded for FREE.

KurrentJobs The Awesome iPhone App To Manage Your Job Search

In this era of Industrialization, everyone is planning to build a company of their own and run a successful business.  But they’re going to need skilled employees to get their jobs done.

Job posting websites could really make their search easy, but with all the available job board options, both recruiters and job seekers are getting frustrated in looking for right choices.

Because job seekers can’t find the right choice of companies as per their skills and experience. As well as the recruiters are getting misled by recruiting consultants and end up with the wrong candidates.

Never miss an update from us. Join 10,000+ marketers and leaders.

As a solution to above problem, iPhone developers at Andolasoft have designed a simple and secure iPhone app named “kurrentJobs”. It acts as a social media job portal for both recruiters and job seekers. It allows individuals, startups and established companies to post jobs as per their requirements.

Jobs are categorized on the basis of skills, experience and on type of jobs like Full-time, Part-time and Freelance.

With this app recruiters can post or manage their job posts from anywhere and anytime. The app is secure with the integration of social plug-ins like Facebook and Twitter.

The app has provided links to recruiter sites and also integrated LinkedIn to help job seekers to apply for jobs. This app can access network communications and storage content on your mobile devices for easier use.

The app is FREE to download and install on your iPhone, from the Apple App store.

iTune

Within a short span of time, Andolasoft has now become one of the major mobile app development companies in USA

We’ve achieved success in developing iPhone apps as we use agile methodologies, innovative work environment supported by creative iPhone developers. For more information about our iPhone and iPad apps please visit iPhone application development page.

Whats are the Differences in Community and Enterprise Editions

Since Magentoits mid-quarter release in 2008, Magento has been the first choice for E-commerce development and it still prevails the same effect.

Magento development is the most secure, flexible and customizable solution for business who are new to e-commerce or switching to this niche.

Upon its popularity and evolution, Magento Inc. has released two editions for Magento, the Community edition and the Enterprise edition. There is still some confusion among developers or users about these editions and their usability.

Let’s have a look at some differences between these two:

Advantages of Advanced Features and Functionality

Since its launch, Magento is open source and both editions are targeted to different audiences.

The community edition is meant for small startup e-commerce business with basic yet powerful solutions. At the same time, the Enterprise edition is meant for those retailers who require more advanced features, customization, and functionality to their e-commerce business.

Magento Team Support

With the Enterprise edition, the retailer signs a Service Level Aggrievement(SLA) with Magento support and will be having the advantage agents development team support for tiniest issues.

Neither the agreement nor the service is available to Community users. They can take care of support issues with their own development team or through Community discussion forums.

Efficient Bug Tracking

The bug Fixing service is provided to both of editions users which comes to act when you report a bug in your Magento platform to the Magento team.

Although the bug resolution service is available to both user types, however sometimes the Magento development team gives much priority to Enterprise edition users as compared to Community edition users due to SLAs.

If you’re a small startup you can manage with the Community edition, but if you’re a large retailer and switching for Magento then you got to choose the Enterprise or Enterprise Premium Edition.

With much more competition on retailing and so many new functionalities to count in for your business, you need to choose the right Magento edition.

Recently Magento also launched the Magento Go feature, where a non-techno buff can also create an e-commerce web app.

At Andolasoft, we always try to build a high quality e-commerce web app with a much higher quality interface, scalability, and customization. Magento development is one of our major expertise and we’ve developed many custom Magento based e-commerce applications, modules, and other extensions.

Whether you’re a startup e-commerce business or a large retailer switching to e-commerce, we can help you by building search friendly and secure websites as per your requirements. We’ve expert Magento developers who can provide top-notch year-round service for your e-commerce solution.

Web Site and Server Monitoring with Nagios

Nagios since it’s inception in 1999 has become one of the most popular and open source monitoring system (under the free license GNU General Public License) to monitor IT infrastructure problems.

It alerts you about any critical problem that might occur in your infrastructure through e-mail, SMS and pager.

Installation and configuration of Nagios is comparatively simpler than other infrastructure monitoring tools.

Although numerous plugins are available in the internet to monitor different services and for graphing of the data, plugin can also be customized as per your requirement by using tools like shell scripts, C++, Perl, Ruby, Python, PHP, C#, etc. DuringNagios configuration you have to keep the following in mind.

  • Lines starting with ‘#’ character are considered as comments and are ignored while processing.
  • Inconfiguration lines the characters that appear after a semicolon (;) arealso treated as comments hence are not processed.
  • Directive names are case-sensitive.

To get data from the monitoring host’s you will need aNagios agent. Below are some popular Nagios Agents:

  • NRPE
  • NRDP
  • NSClient++

Below are some protocols used for monitoring:

  • SMTP
  • POP3
  • HTTP
  • NNTP
  • ICMP
  • SNMP
  • FTP
  • SSH

Below are some Host resources which can be monitored:

  • Processor load
  • Disk usage
  • System logs

Customizing Error Messages In RAILS

In every application regardless of its complexity we require to customize error messages to make more sense. There are several ways to achieve it in Rails 3 and in Rails 2.3.x which are mentioned specifically and that can be handled either in models or controllers or helpers.

Solution# 1:

If it is needed to be handled in model and message need to be have customized instead of the attribute name. Like if the attribute name is “name” but you want to display messages “Employee name cannot be blank” then we have to install “custom-err-msg” plug-in.

This plugin gives you the option to not have your custom validation error message prefixed with the attribute name. Ordinarily, if you have, say:

validates_acceptance_of : terms, :message => 'Please accept the terms of service'

You’ll get the following error message: Terms Please accept the terms of service

This plugin allows you to omit the attribute name for specific messages. All you have to do is begin the message with a ‘^’ character. Example:

validates_acceptance_of :accepted_terms, :message => '^Please accept the terms of service'

step# 1

To install the ”custom-err-msg” plug-in you have to use the command.

“ruby script/plugin install https://github.com/gumayunov/custom-err-msg.git”

If you are facing problem by installing the plugin then clone it and just copy the folder (”gumayunov-custom-err-msg-640db42”) inside “Vendor/plugin/” folder

step# 2

In view file just display it as mentioned below:

Similarly, it can use in other places like,

validates_presence_of :claim_no, :message => "^Work Order/Claim number cannot be blank!"

The plugin also lets you use procs instead of strings.

Example:

validates_acceptance_of :accepted_terms, :message => Proc.new {|service| "You must accept the terms of the service #{service.name}" }

The above plug-in usage can be avoided by declaring alias for each attribute as mentioned below.
You should have a file named config/locales/en.yml, if not simply create one. There you can add your own custom names.

en:
activerecord:
models:
order: "Order"
attributes:
order:
b_name: "Business Name"

This will replace your attribute “b_name” with “Business Name”

Your Order model in app/models/order.rb should look like:

class Order < ActiveRecord::Base
validates :b_name, :presence => true

The error message will be displayed like

Business Name cannot be blank

Solution# 3:

Another way is to define a method and an error message inside the method in the model.

Class Employee < ActiveRecord::Base
validate :zip_must_be_valid
def zip_must_be_valid
unless zip.map(&:valid?).all?
errors.add_to_base " zip code is invalid"
end
end
end

We can also customize the error messages in Controllers.
Suppose “First Name” cannot be blank to be checked. Then use below code to check for it and show customized messages

if(params[:employee][:first_name].nil?)
flash[:error] = "First name should not be blank.n"
end

Subsequently, if it is required to add other messages to the above for other attributes then it can be written as,

if(params[:employee][:address].nil?)
flash[:error] += Address should not be blank.n"
end

Solution# 5

Customization of error messages can be done in controllers by adding messages to the existing error object’s method “add_to_base”.

if email_data[:"email_no_#{i}"] != "" && email_data[:"email_no_#{i}"] !~ /^([^@s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})$/i
valid_params = false
@company_info_new.errors.add_to_base( "Invalid Email Id!" )
End

In views it can be displayed by writing below code:

0 %>
nil, :message => nil >

Solution# 6

The customization that can be handled in views using

“error_message_on” helpers (Rails 2.3.8)”

In case you wish to show one error message in a specific location that relates to a specific validation then use “error_message_on” helper. You might have used “error_message_on” to display field-specific error messages. Here is an example that would display an error message on a name field:

Solution# 7

You can also use “error_message_on”(Rails 2.3.8) to display non-field-specific error messages.

class User < ActiveRecord:Base
validate :user_is_active
private
def user_is_active
if self.is_active != true
errors.add : user_is_active, 'User must be active to continue'
end
end
end

Now, to display this custom validation error message with “error_message_on”, we simply need to reference “:user_is_active” when we call the helper. Consider this implementation:

Solutions# 8

class User < ActiveRecord::Base validates_presence_of :email validates_uniqueness_of :email validates_format_of :email, :with => /^[wd]+$/ :on => :create, :message => "is invalid"
end

In Rails 3 it’s possible to call a validate method and pass it a hash of attributes to define the validations instead of defining each validation separately as mentioned above.
/app/models/user.rb

class User < ActiveRecord::Base validates :email, :presence => true,
:uniqueness => true,
:format => { :with => /^([^@s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})$/i }
end

In the User model we’re still validating that the field has a value and that the value is unique. For validating the format there are a number of options we can pass so we use a secondary hash to define those.

We can supply any number of validations for an attribute with a single command. While this is useful it can become cumbersome if there are a large number of validations but for most situations, it works nicely.

We can make the “:format” option more concise and clean it up a little. We often want to validate email addresses and having the same long regular expression in each validator is a little ugly and introduces repetition into the code. We can extract this out into a separate validation by creating a new class in our application’s /lib directory. We’ll call the file email_format_validator.rb.

class EmailFormatValidator < ActiveModel::EachValidator
def validate_each(object, attribute, value)
unless value =~ /^([^@s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})$/i object.errors[attribute] << (options[:message] || "is not formatted properly")
end
end
end

The EmailFormatValidator class inherits from ActiveModel:: EachValidator. We have to define one method in the class “validate_each”, that takes three parameters called object, attribute and value. The method then checks that the value matches the regular expression we’re using to validate an email address and if not it will add the attribute to the objects errors.

We can use this technique to define any kind of validation we like. Now that we have our custom validator we can update the validator in the “User” model to use it.
/app/models/user.rb

class User < ActiveRecord::Base
validates :email,
:presence => true,
:uniqueness => true,
:format => { :with => /^([^@s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})$/i }
end

Having an email_format key in the “validates” hash means that the validator will look for a class called email_format_validator and passes the validation behavior into the custom class that we just wrote.
If we try to create a new user now and enter an invalid email address we’ll see the expected error message.

If you have some trick to share, do it in the comments.