Ruby on Rails

20
Dec

Jquery and Ruby on Rails


What is Jquery

jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. -- From the Jquery Website.

Jquery is one of the many Javascript frameworks out there. Its competition includes YUI, Prototype, Moo etc.

Jquery UI

In additions to the framework; Jquery also has a powerful UI framework. Jquery and Moo have the most complete and easy to use UI framework now. It has widgets such as sliders, tabs, accordions, calendars, dialog and modal windows. It also has a very nice button framework.

You can find more information on their website http://ui.jquery.com.

7
Dec

Acts as taggable on and Thinking Sphinx Integration


Using thinking sphinx to search objects that are tagged using the acts_as_taggable_on plugin.

class Photo < ActiveRecord::Base
  ...
 
  acts_as_taggable_on :keywords
 
  define_index do
    indexes :caption
    indexes keywords.name, :as => :keywords
  end
 
  ...
end

Now lets assign some tags to our Photo

>> photo = Photo.create :user_id => 1, :caption => 'BMW M7', :keyword_list => 'BMW, Car'
>> photo.keywords
=> [#<Tag id: 1, name: "BMW">, #<Tag id: 3, name: "Car">]

Lets run the indexer

 

7
Dec

Scaling up with Rails and EC2 Workflow


7
Dec

GeoCoding using Ruby


A quick hack to get a location's geo coding

 
 require 'xml-simple'
 require 'net/http'
 
 # Enter the location to get the lat and long
 #
 def yahoo_geo(location)
   host = "api.local.yahoo.com"
   q =  "http://api.local.yahoo.com/MapsService/V1/geocode"
   q << "?appid=wnorrix&location=#{URI.encode(location)}"
   xml = XmlSimple.xml_in(Net::HTTP.get(host, q), {"ForceArray" => false})
   return xml["Result"]
 end
7
Dec

Rodney asking me if I want to go for a smoke?


class Smokers <  ActiveRecord:: Base
 belongs_to      :heart_failure_statistics
 has_many        :cigarettes
 attr_accessor   :mins_since_last_puff
 
 before_validation :check_cigarettes
 
 def smoke?
   if mins_since_last_puff  >= 60
     write_warren("Smoke?") 
   end  
 end
end

This is fucking sweet!

7
Dec

Ruby on Rails 1.0 has finally arrived!


Finally after a long wait its finally here! There have been soo many changes since the early 0.5 days. I still remember the good ol' days where you had to do so many things manually. Thanks to the rapid development of the framework, most of this is taken care of now. I remember times where I had to spend time on apache to get things right and now every thing seems to work out of the box.

The community has grown from 10 to over 400 users (on IRC we lost a good few though). Hope to see Rails establish it self as the next industrial standard.

7
Dec

Multilingual Rails Tutorial


Some of you have already integrated my patch, some of you have already figured out how to use it without any help ( that was the initial plan after all ). As for those who don't, here goes.

I did promise earlier that the support will be modular just like our views, but since the system loads all the languages into memory before serving request, I decided to drop it for now.

Step 1. Locale directory
All the language files are supposed to be stored here.

# mkdir app/locale/

Step 2. Create the lyml file

7
Dec

Multilingual Web Applications


Not everyone speaks the same language, Google and Yahoo have lead the way to multilingual web applications. Rails promotes Web 2.0, and I think accessing your favorite application in your own language is a must for Web 2.0. I spent some time yesterday trying out the different ways of making my application support multiple languages, most of them were too complex for a Rails newbie to install and use. Rails has always been all about “out of the box” features, so I decided to sit and code up support for multilingual Rails.

These are some of the reports and benchmarks:
Run 1:
 

7
Dec

Rails 0.10.0


The new version of Ruby on Rails was release 24 hours back. I have always been on edge rails, from the very beginning so this only did not mean much to me. But since most people are on stable rails. These are the things that you can expect form this release.

Routes

Routes also helps you have really cool URLs. Its far more easy to create custom URLs now with routes in action. Routes also solves the .htaccess issue. Routes was known as Directions earlier.

Components

Syndicate content