>> Date::MONTHNAMES[1]
=> "January"
some other date methods:
Date::ABBR_DAYNAMES
Date::ABBR_MONTHNAMES
Date::DAYNAMES
Thanks,
sri..
my blog is abt wht i have learnt technically, mostly in Ruby on Rails, Javascript, node.js hope this share a little bit of info & adds a bit stuff., Thanks.
Friday, June 19, 2009
Thursday, June 18, 2009
Adding data in add column
Adding data in add column
class AddPeopleSalary < ActiveRecord::Migration
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
Tuesday, June 9, 2009
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
ENDFORM
return signed_form
end
end
include PayNowWidgetUtils
ACCESS_KEY = 'your amazon aws access key'
SECRET_KEY = 'your amazon aws secret key'
print generate_signed_form(ACCESS_KEY, SECRET_KEY,
'amount' => 'USD 100',
'description' => 'Test Button',
'referenceId' => 'txn1102',
'returnUrl' => 'http://localhost:3000/success',
'abandonUrl' => 'http://localhost:3000/fail')
amazon aws signup..
http://aws.amazon.com/
use a sandbox account for doing test case.
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
ENDFORM
return signed_form
end
end
include PayNowWidgetUtils
ACCESS_KEY = 'your amazon aws access key'
SECRET_KEY = 'your amazon aws secret key'
print generate_signed_form(ACCESS_KEY, SECRET_KEY,
'amount' => 'USD 100',
'description' => 'Test Button',
'referenceId' => 'txn1102',
'returnUrl' => 'http://localhost:3000/success',
'abandonUrl' => 'http://localhost:3000/fail')
amazon aws signup..
http://aws.amazon.com/
use a sandbox account for doing test case.
Subscribe to:
Posts (Atom)