Showing posts with label Rails News. Show all posts
Showing posts with label Rails News. Show all posts

Friday, 29 June 2012

postgres_ext gem native postgres datatypes in rails

Hi,

We are using different datatypes depending on the requirement of data that is being saved in database.

Coming to postgres database, it supports many datatypes and we can't use all those datatypes directly in rails.

To over come this problem, we had a new gem postgres_ext


postgres_ext supports 3.2 and above version of rails.

postgres_ext adds migration and schema.rb support for the following PostgresSQL type:

    INET
    CIDR
    MACADDR
    UUID
    Arrays


example:

create_table :users do |t|
  t.inet :myip


  t.cidr :mysubip


  t.macaddr :ip_address


  t.uuid :member_id

  t.integer :friend_ids, :array => true

end


postgres_ext converts INET and CIDR values to IPAddr instances.

example:

create_table :inet_examples do |t|
  t.inet :ip_address
end

class MyExample < ActiveRecord::Base
end

my_example = MyExample.new
my_example.ip_address = '127.0.0.0/34'
my_example.ip_address
# => #<IPAddr: IPv4:127.0.0.0/255.255.255.0>
my_example.save

my_example_u = MyExample.first
my_example_u.ip_address

# => #<IPAddr: IPv4:127.0.0.0/255.255.255.0>



array type:

example;

create_table :people do |t|
  t.integer :favorite_numbers, :array => true
end

class User < ActiveRecord::Base
end

user = User.new
user.like_numbers = [1,2,3]
user.flike_numbers
# => [1,2,3]
user.save

user_2 = user.first
user_2.like_numbers
# => [1,2,3]
user_2.like_numbers.first.class
# => Fixnum



here is the git url: https://github.com/umamahesh/pg_array_parser

Thank You,
Uma Mahesh.

Thursday, 26 April 2012

BEST RAILS COMMUNITY - WORKING WITH RAILS




WWR (WORKINGWITHRAILS) One of the best and biggest open community for ruby on rails.  

DSC created the site as an open project and called it WorkingWithRails.  

From here the community itself took over and built the most comprehensive database of Rails workers, companies, enthusiasts and contributors. But rather than an entirely passive system it linked in to the blogs, source code contributions, etc. of the various community members.

You can view the dsc development progress towards the WWR at here http://dsc.net/wwr.html

My complete profile at workingwithrails http://workingwithrails.com/person/10406-uma-mahesh-varma

You too join in that community  and share your views about rails..

Thank You,
Uma Mahesh