Friday, July 3, 2009

Get Start/Switch your projects with Ruby On Rails


For this past few years i missed to read an wonderful article about the succession of Ruby on Rails. This article explains us "How Ruby on Rails succeeded and intention to Create this?" Dont ever miss any one to read this article. Just click the below link and start to work with Ruby on Rails.

http://tinyurl.com/kopbwe

For each and every programmers or technicians or business development managers, this article should read and need to get know about Ruby On Rails(ROR).

Especially in India, so much of them didnt even know about this framework and language. Some bigger companies are not yet started to accomodate this simple framework( rails ) with the base powerful language (ruby). They should come over and start to work on this technology. Its the only language now the direct competitor for Java in the whole world. In Denmark, it almost 90% of programmers using this framework.


It Benefits a lot. In Brief,

-> Reduce the number of hours to develop a application.
-> Reduce the number of developers involved to create a application.
-> Reduce the stress, energy to create the applications by the developers.
-> Easy to learn the framework.
-> More compatible with all platforms.
-> Easy to implement the Agile methods.

Finally, Last but not Least, its everthing "OPEN SOURCE". Get think over the above advantages and start / switch your projects with Ruby On Rails.

Happy coding and will see you in another information.

Saturday, June 13, 2009

Searching String(s) in file(s) using Ruby

Searching String(s) in file(s) using Ruby is very simiple. Here is the sample code to manipulate it.

# searching a string in a file
def print_line_containing(file, str)
File.open(file).grep(/#{str}/).each do |line| puts "#{line}" end
end

# searching multiple strings in a file
def print_line_containing(file, str1, str2)
File.open(file).grep(/#{str1}\s+#{str2}/).each do |line| puts "#{line}" end
end


# searching multiple strings in multiple files
def print_line_containing(file_array, str)
file_array.each do |file|
File.open(file).grep(/#{str1}\s+#{str2}/).each do |line| puts "#{line}" end
end
end

I hope this will help you all!

Wednesday, June 10, 2009

Building Shopping Cart with Ruby on Rails in few minutes

we can easily build a shopping cart application in a fraction of few minutes.

http://code.google.com/p/substruct/

Use the above link and download the substruct application. Follow the instructions like installation, svn updating the substruct engine, and etc., from the left nav bar on that page.

Then you will get the shopping cart application with payment integration with the Active Merchant plugin.

Get use of open source and explore your thoughts with your application.

Friday, May 22, 2009

Array Mapping in Ruby

Hi to All,

Here is the sample code to know the usage of array mapping in Ruby.

>> User.find_all_by_office_id(20)
=> [#, #]

If you want to map only the User id's from the above result set. then you should use like this:

>> User.find_all_by_office_id(20).map(&:id)
=> [1032, 3646]

If you want to use these User id's in an another query with "IN" predicate. Then you should use like this:

>> User.find_all_by_office_id(20).map(&:id).compact.join(",")
=> "1032,3646"

the compact will you delete the blank array element from the result set.

then it joins with "," (comma). So finally you will get the string with concatenated id's with comma. You can use this string in the another query with "IN" predicate, like this

>>user_ids = User.find_all_by_office_id(20).map(&:id).compact.join(",")

>>y Website.find(:all, :conditions => "user_id in(#{user_ids})")

you will the websites list for these users.

Friday, April 17, 2009

Rails 2.3.2 bugs with solutions

For the rails thinkers this link may helpful a lot to solve their basic issues with recent rails released version 2.3.2


http://tiny.cc/67kLX

Gem Capistrano issue on Ruby on Rails

If you are going to use capistrano gem for deployment.

you should install two gems for this:

sudo gem install capistrano
sudo gem install capistrano-ext

If you missed out "capistrano-ext" gem to install,

it wont you to execute capistrano operations like deploy, log, etc., i.e tasks which are using your deploy.rb

/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- capistrano/ext/multistage (LoadError)

and it returns the above error.

Wednesday, April 15, 2009

Rmagick and ImageMagick Installation steps in Ubuntu

Hi to all,

After 1 to 2 hours struggling with the Rmagick and ImageMagick Installation in Ubuntu 8.10, i have found a simpler steps to do:

1) Install "imagemagick" through apt-get or synaptic manager.
2) Again Install "libmagick9-dev" through apt-get or synaptic manager.
3) Then, sudo gem install rmagick ( recent version will get install )

If you want a specific version of rmagick, then use this
sudo gem install rmagick -v 1.15.12

Note: rmagick 1.15.12 version is a stable gem.