Saturday, December 4, 2010

3 Effective Reasons for the Popularity of Ruby on Rails Development

Ruby on Rails (RoR) is a full-fledged web application framework written in Ruby programming language. It is an open source technology.  Rails help the web developers in building websites and applications providing structure for codes written during the development process. Ruby is an object-driven programming language which is easy to understand. It helps in providing powerful features and meta-programming capabilities.  A key feature of Ruby on Rails (RoR) is that developers have to write codes for only those areas where the application deviates from the standard.

Some of the reasons for the popularity of Ruby on Rails Development include:

1. Leader amongst programming languages on the web: There are many programming languages available in the market for web development. Some of them are: Python, Java and PHP but Rails leads these programming languages. Rails give the developers a real productivity boost for developing web applications and Ruby offers domain specific languages.  Hence, Ruby on Rails is considered to be leader amongst programming languages on the web.

2. Designed to make programming work easier: Ruby on Rails helps the developers in simplifying the process of writing codes. It helps in checking the code quality. If there are any errors in the codes it is directly reported to the developers and they can make adequate changes instantly. This simplifies the process of the developer and they are able to complete their task quickly.  The process of programming is much faster as compared to other frameworks because of Ruby and CoC (Convention over Configuration).  Ruby code is very readable and can be self- documented. This reduces the work of the developers.

3. Opportunity for developers to create better codes: As the task gets simplified with the help of Ruby on Rails, developers have the opportunity to make the programming codes into something better. They can re-work on the program and can come up with new ideas for the development process.

Ruby on Rails helps the organization in improving the overall productivity of delivering tools by eliminating the repetitive tasks. It is useful to opt for Ruby on Rails framework when there is limited time duration and the organization wants to build a powerful web application which eliminates the initial cost of IT project.  Ruby on Rails development is getting much deserved mileage from people. It is lowering the entry barriers for other programming languages. If you would like to learn more about Ruby on Rails development contact an expert Ruby on Rails (RoR) developer now at: info@softwebsolutions.com.
Read more...

Wednesday, July 21, 2010

Interesting Facts on Ruby on Rails

Ruby on Rails (RoR) is a programming language used to build interactive and engaging web applications. Rails is an open source web application framework written in Ruby language. It slashes development time and increases the simplicity of coding for dynamic web sites. RoR is a widely used programming language capable of providing rich user experience. We’ve listed down some interesting facts about RoR that you may want to know:

• David Heinemeier Hansson, a Danish programmer, developed Ruby on Rails in 2003. According to Wikipedia data, Google and O’ Reilly awarded him with the Hacker of the Year award in 2005.

• He has over 1400 contributors in the rails core team responsible for extending features in the platform

• RoR is an agile framework used in majority of the web solutions. Website development is faster using the RoR solution.

• Important websites that use Ruby on Rails are Crunchbase, BaseCamp, Hulu, SpiceWorks, Penny Arcade, Twitter, Xing, and Yellowpages.com.

• The language has thousands of plugins that can be used to create unique functionality within applications.

Ruby on Rails has grown tremendously as it follows the Agile development cycle.  It provides scaffolding, which can automatically construct some of the models needed for a basic website. In addition, it includes advanced application development principles such as Convention over Configuration (CoC) and Don't Repeat Yourself (DRY).

At Softweb Solutions, we have a team of Ruby on Rails developers’ proficient in providing Ruby on Rails Development Services. A broad spectrum of SEO services can be used along with RoR to improve website visibility in major search engines.
Read more...

Tuesday, June 22, 2010

Ruby on Rails 3 All Set for Launch

Ruby on Rails united with Merb Ruby frameworks to jointly participate in the development of Ruby on Rails 3 (RoR 3.0). After 18 months of collaboration which began since 2008, the open source development framework is finally close to the release. RoR 3.0 involves better modularity and robust features compared to its earlier version.

Yehuda Katz, a member of the Ruby on Rails core team and Rails framework architect, stated that they spent almost a year and a half refactoring so there is massive internal improvement. By refactoring, he clarifies that changes are made to the code with altering the functionality. Furthermore, he explains the new framework features better dependency management and API improvements.

New Features Introduced in Rails 3.0
• Dependency Management – Earlier when Rails faced issues related to dependency management, it elbowed them aside by reducing the number of dependencies. Now, as a result of coalition with Merb, dependency management is well aligned.
• Modularity – According to Katz, in the earlier version of Rails, “Rails would own a given application process on a global settings basis.” In Rails 3, the modularity and scalability of the framework is improved as the team has tried to reduce global states inside Rails.
• Improved Router – The Rails 3 router will allow developers control where inbound request go with a higher precision level compared to Rails 2.

For more details on Ruby on Rails 3.0, here’s the link.

At Softweb Solutions we offer innovative Ruby on Rails Web Application Development Services with a group of dedicated RoR developers. In addition, we provide a spectrum of SEO techniques to improve your website's visibility in all the major search engines.
Read more...

Wednesday, May 19, 2010

Generate CSV File in Rails

If You want to generate generalize function to generate csv file then keep export _to_csv function in application.rb file

def export_to_csv(data)

records = data

cls = records[0].class

data = ""

data << cls.csv_header << "\r\n"

records.each do |inst|

data << inst.to_csv << "\r\n"

end

send_data data, :type => 'text/csv', :filename => cls.name.pluralize + '.csv'

end


Controller

def export_csv

data = Model.find(:all)

export_to_csv(data)

end


Model.rb

def self.csv_header

#Column Header

"ID,Name,Controller Action ,Action Label,Is controller"

end



def to_csv

#Field_name

id.to_s << "," << name << "," << controller_action << "," << action_label <<

"," << is_controller.to_s

End


View

<% form_tag({:action => :export_csv }) do -%>

<%= submit_tag "Export To CSV",:class =>'button-1' -%>

<% end -%>


Read more...

Monday, May 17, 2010

JRuby Community Unveils JRuby 1.5

The JRuby Community has unwrapped JRuby 1.5, the latest upgrade of its Java implementation of the Ruby language, on 12th May, 2010. The release comes after one of the longest development cycles in the Open Source community.

The JRuby Community stated in their blog that it took them 5 months to make the changes and implement the bug fixes in the latest release. The bug fixes mainly comprised of small alterations that address compatibility issues for individual Ruby methods. According to the community, JRuby 1.5 includes 1,300 revisions and 432 bug fixes. It comes with a new native access framework which leads to improved performance and better FFI (Foreign Function Interface) support. Users will also be happy to find better support for Windows and multiple performance improvements such as improved accuracy, memory and speed in Ruby-to-Java calling.

Additionally, the latest release sees improvements in the Ruby 1.8.7 standard library and the ruby-debug tool is added by default. Rails 3 has seen the addition of multiple bug fixes, which includes reduced memory usage for Java class metadata, faster loading of Java classes, improved start-up times, and jar-in-jar support in the classloader.

According to research firm Gartner, ‘JRuby has the fastest Ruby interpreter on the market’. The reasons are that it runs the complete Ruby test suite, it runs on JVMs (Java Virtual Machines), and provides access to Java libraries. The analyst also mentions that JRuby is beneficial for enterprises that are planning to move to some dynamic languages.

For developers and project managers within non IT companies, the technology upgrade will translate into higher productivity, faster application development, and that too comes along with saving on existing Java investments. This makes the latest JRuby release an important event for the enterprises and their improved performance.  

If you are looking for more information on JRuby or Ruby on Rails, contact us at info@softwebsolutions.com.                  
Read more...

Monday, April 5, 2010

a3 Reasons to Select Ruby on Rails 2.0 to Achieve your Business Goals

Ruby on Rails 2.0 (ROR 2.0), a programming language combined with a web application framework, was unveiled recently. It is an open source web project that supports Agile development methods and takes programming to the next level. In this blog we will talk about three reasons why Ruby on Rails 2.0 translates into business benefits.

Time to market is faster 
Time to market is a key factor when it comes to gaining competitive edge. Compared to .NET or J2EE, the development of rich internet applications in ROR 2.0 takes lesser time. The quicker time to market combined with improved web applications and enhanced user experience makes ROR 2.0 a perfect fit.

Lowers costs 
Development costs not only include application development time but also expense comprising software, support, testing, installation, customization, and many more. ROR 2.0 has a robust framework that addresses these concerns. It significantly lowers the time and efforts required to create, maintain or update web applications thereby saving operational costs. Being an open source framework, organizations save on licensing costs as well as upgradation fees.

Improved Quality 
ROR 2.0 offers superior software quality as it is grounded on test driven development and automation. Developers can easily prevent errors because of continuous testing and iterations. In addition, extensive unit testing support makes it possible for developers to test changes instantaneously. These characteristics lower complexity of developing web applications and allow developers to focus on application logic improving the quality of software applications.

Thus, ROR 2.0 gives organizations ample reasons to select it for achieving their business goals. It allows radical productivity improvements and enables developers to provide enhanced performance. Please share your own opinions on ROR 2.0 in the comments section below.  

Read more...

Thursday, December 3, 2009

Delegation with Rails

Why delegation?

Before going to detail let me start with an example , we have a two models named User and profile having has-one association.

class User < ActiveRecord::Base
  has_one :profile
end

class Profile < ActiveRecord::Base
  belongs_to :user
end

Suppose Profile have attributes like first_name, last_name, phone etc and @user is the instance of User class.now to find name or phone of an user we have two ways -

1. Using dot-magic

FirstName = @user.profile.first_name

This is simple but becomes bulky for long chain associated object.For example @user.sth.sth.sth.sth…some_attribute

2. Using delegation

Instead we can delegate desired attributes in User model. Here is the code to add

class User < ActiveRecord::Base
  has_one :profile
  [:first_name, :last_name, :phone, ...etc.].each {|attr| delegate attr, :to => :profile}
end

Lets see usage of delegation in depth

Delegatation in Rails

In ruby on rails Delegation provide us a fine way over dot-magic. Using delegation it is easy to access associated object’s attributes. Delegation is a feature Rails introduced in it’s 2.2 version.The concept of delegation is to take some methods and send them off to another object to be processed.Delegate simply delegates a method to another class.This is useful if you have a lot of cases where you are referring to fields in associated classes.

Let me explain this with a brief example:

Suppose you have a User class for anyone registered on your site, and a Consumer class for those who have actually placed orders:


class User < ActiveRecord::Base
   belongs_to :consumer
end


class Consumer < ActiveRecord::Base
  has_one :user
end


As for now, if you are in a Consumer instance, you can get their User information doing @consumer.user.name, or @consumer.user.email. Delegation allows you to simplify this:

class User < ActiveRecord::Base
   belongs_to :consumer
end


class Consumer < ActiveRecord::Base
  has_one :user
  delegate :name,:email,:to => :user
end


Now you can refer to @consumer.name and @consumer.email to retrieve and set values for those attributes directly.

This is all well and good if you can be sure that there will always be a user for any given consumer. If consumer’s user is nil and name is called, however, an exception will be raised (because nil.name is undefined). There’s a new feature in Rails 2.2 that relate to delegation and using a prefix for delegated methods also you can set default value by extending delegate method

Delegate with default

class Consumer < ActiveRecord::Base
  has_one :user
  delegate :name,:to => :user, :default => "Sapna Prajapati"
end


Delegate with prefixes

Delegate prefixes just appeared in edge Rails and will work in Rails 2.2. If you delegate behavior from one class to another, you can now specify a prefix that will be used to identify the delegated methods. For example:

class User < ActiveRecord::Base
   belongs_to :consumer
end

class Consumer < ActiveRecord::Base
   has_one :user
   delegate :name,:email,:to => :user ,prefix => true
end

This will produce delegated methods @consumer.user_name and @consumer.user_email.

The problem is if you refactor user or consumer , you’ll have to go back and fix all the places you did this access chaining as well. Means if you rename the user class, you’re almost always going to want to rename that prefix too.But delegates provide custom prefixes so you will end up to change.

Delegate with custom prefixes

class User < ActiveRecord::Base
   belongs_to :consumer
end

class Consumer < ActiveRecord::Base
   has_one :user
   delegate :name,:email,:to => :user ,prefix => :owner
end

This will produce delegated methods @consumer.owner_name and consumer.owner_email.

Read more...