Posts

Showing posts from June, 2009

Get month names for the integer

>> Date::MONTHNAMES[1] => "January" some other date methods: Date::ABBR_DAYNAMES Date::ABBR_MONTHNAMES Date::DAYNAMES Thanks, sri..

Adding data in add column

Adding data in add column class AddPeopleSalary def self.up add_column :people, :salary, :integer Person.reset_column_information Person.find(:all).each do |p| p.update_attribute :salary, SalaryCalculator.compute(p) end end end

Amazon simple Payment in ruby on rails

hi, Amazon is Doing a great job in rails Payments. here is the ruby code for generation of button. require 'base64' require 'openssl' module PayNowWidgetUtils def generate_signed_form(access_key, aws_secret_key, form_params) form_params['accessKey'] = access_key str_to_sign = "" form_params.keys.sort.each { |k| str_to_sign += "#{k}#{form_params[k]}" } digest = OpenSSL::Digest::Digest.new('sha1') hmac = OpenSSL::HMAC.digest(digest, aws_secret_key, str_to_sign) form_params['signature'] = Base64.encode64(hmac).chomp signed_form = STARTFORM form_params.each do |key, value| next unless key and value signed_form += FORMELEM end signed_form += ENDFORM...