Thursday, January 20, 2011

Ruby On Rails Active Record data format type :primary_key, :string, :text, :integer, :float, :decimal, :datetime, :timestamp, :time, :date, :binary, :boolean.

The types supported by Active Record are  
:primary_key,
:string,  
:text,  
:integer,  
:float,  
:decimal,  
:datetime,  
:timestamp,
:time,  
:date,  
:binary,  
:boolean

jz another helpful reference for a newbie like me ~.~

Tuesday, January 18, 2011

Installing Papperclip + Rmagick2 + ImageMagick ruby 1.9.2 & Ruby on Rails @ ubuntu.

I've already tried to implement this plugin last month or more, but it was a failure because i did not RTFM. I just get it to work few minutes ago & manage to wrote this down so that i'll not forget.

The key feature of successfully install those plugin, gem & image processor is as below :
1. Delegate libraries
  • FreeType, Version 2.0 or above, to annotate with TrueType and Postscript Type 1 fonts.
  • libjpeg to read and write JPEG v1 format images.
  • The PNG library, to read and write PNG format images.
  • libwmf 0.2.5 or later, to read and write Windows Meta File (WMF) format images.
  • Ghostscript version 8.10, to read and write the PDF and PS document formats.

2. Decide the version of ImageMagick, Rmagick for your Ruby Version.
RMagick Version Feature Table
Feature RMagick 1 RMagick 2
Works with Ruby < 1.8.5* Yes No
Works with ImageMagick 6.0.0-6.2.9 Yes No
Works with GraphicsMagick Yes No
Fully supported Yes Yes
Works with ImageMagick 6.3.5 and later Yes Yes
Available as a Windows RubyGem? No Yes
Gets new features No Yes
Works with Ruby 1.9 No Yes
Supports new ImageMagick features No Yes
* This is de facto that i did not concern during my previous installation which screws me.

3. Library dependencies for ImageMagick
just use the synaptic package manager to install ImageMagick and its dependent libraries. This is really time saving. I just use it and it's work!
* Note : I already do a tarball installation before i tried the synaptic package manager. After download & untar the ImageMagick, I configure it with this option below and make, then make install.
./configure --disable-static --with-modules --without-perl \
     --without-magick-plus-plus --with-quantum-depth=8
I don't know whether this configure do effect my ImageMagick synaptic package manager installation.

4. Install the Rmagick
gem install rmagick
this will automatically install me rmagick (2.13.1). The latest version.

5. Test Rmagick at ruby console
I use
rails c
to enter my ruby console. Enter commands below inside your ruby console. 
require 'RMagick'
Magick::Image.new(110, 30){self.background_color = 'white'}.write('/tmp/test.jpg')
Then check your image at /tmp/test.jpg

6. Install Papperclip
rails plugin install git://github.com/thoughtbot/paperclip.git
I'm not going to tell more about papperclip. Please read the ASCIIcasts

Yeay you are now capable of defeating facebook. haha

edited from the original source : http://rmagick.rubyforge.org/install-linux.html
Please add a comment if i am wrong in any part & we may share all here.

thx in advance
Ya'kob Ubaidullah

Thursday, December 2, 2010

Creating the malaysian facebook ;) [Rails 3 Relational database example]

Scaffolding the structure of the application
first generate the scaffolding.(bloody easy on Ruby on Rails)
rails g scaffold user name:text address:text
rails g scaffold post msg:text user_id:text
rails g scaffold comment msg:text user_id:text post_id:text
 
Creating a relational database
Second is the model configuration

#inside akob/app/models/comment.rb
class Comment < ActiveRecord::Base
belongs_to :post
end

#inside akob/app/models/post.rb
class Post < ActiveRecord::Base
has_many :comments
belongs_to :user
end

#inside akob/app/models/user.rb
class User < ActiveRecord::Base
has_many :posts
has_many :comments, :through => :posts
validates :name, :presence => true
end

this is just an example, we should put many MANY validation to assure this system reliability. inside this example it shows how the data is relate to each other.

this is the screenshot of the console testing which shows the data relationship is working fine. ;)
Actually this is part 1. In the next post, I will move onto the view files & show to you guys how it works with ajax.
Would like to here some respond from you ;)

Wednesday, November 24, 2010

Breeding DNSCELL

Salam & hi readers. Its been a while since the last time I blog. I just moved to shah alam nearly a weeks ago. I stayed at Puncak Perdana in a 'bujang house'. My housemate is the student of filming or some sort of production line at UiTM. Doesn't matter what is their interest, I'm fine with that. The comfortness of my living over here is just fine.

Intro
The purpose i moved here is to work with my comrade on developing a networking device (DNS server). What is DNS server ? U can google it your self here. My job is pretty much on the user interface & at the same time, i have to write codes to it. This user interface is accessible through Web browser (which methods used by most of devices nowadays). To be productive i need to master several language such as :
1. html
2. CSS
3. Ruby on Rails3
4. Yahoo User Interface (YUI sytax)

The toughest challenge is to get along with Ruby on Rails3 since the entire architecture is based on it! What is interesting is, RoR has the capability to develop application in a blistering speed & in a secure framework. You can check out the screencast & start to experienced it yourself ;)

Logo
Lets hold our RoR stories & get back to DNSCell. Firstly is about the logo, the previous logo looks like this :
On my thought, this logo is not ICONIC & doesn't have much meaning. So I keep on fantasizing & I've learned that honey comb is also a structure of cell. I've created the new logo which looks like this :
Why I think this logo is better ?
1. It is more ICONIC
2. It's pointing towards & upwards, which is we want our business heads to.
3. It's like a plasma canon. Weapon for us to step forward.
4. the logo itself was develop by the name cell (honey cell)

Layouts
Lets move to the Layouts. I've been practicing alot with css because its been a while since the last time i do CSS -ing. The 1st layout I've produced looks like this :

I looks a bit clumsy & lousy for me. After observation at google apps, i think it's much more clearer & easy so use. So i've produce this :
DNSCell latest layou
Drop down menu & tabs navigation

Before i've forgotten, the oldest layout that amir propose to me is this :
I can see the tab is overlapping & i don't think this may provide easy navigation. User will caught up 'pening' using this UI.

CSS
Yesterday I caught up lost inside my own CSS file & I've found out the solution for it, which is by documenting my own CSS. I've had rebuild my CSS. Heres how my mapping looks:
DNSCell CSS plan
And here's how the coding will looks like :
a-a a-b a-c and going to b, c, d. Kinda cute huh? ;)
Would like to hear some response from you guys & will write more about this project on later progress.


rgrds
Ya'kob Ubaidullah

Monday, November 15, 2010

My Ruby On Rails life ; Installing & tutorial for Rails3 on Ubuntu 10.10

I was really interested to start my 'ruby on rails' life since amirharis introduce it to me. Ive been watching its screencast & cannot wait to start my first application. Below are the few steps to install RoR development environment on Ubuntu:

I am now installing it on Ubuntu 10.10. Before we start our ruby installation, there are few library to install
before that, we want our packages library to be updated.
$ sudo apt-get update
$ sudo apt-get install gcc g++ build-essential libssl-dev libreadline5-dev zlib1g-dev linux-headers-generic libsqlite3-dev curl git libmysqlclient15-dev
We also need RVM to install Ruby for us & for future ease of arrangement. We also need to set the default ruby version.
$ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

$ [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
insert line below into your home .bashrc  . Insert it at the bottom of the file.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" 
and you may want to restart your terminal for this to take effect
$ rvm install 1.9.2
$ rvm --default use 1.9.2
Now we use Ruby Gem to install rails for us. Gem is Ruby package manager.
$ gem install rails
Here is where our adventure begins! 1 - 2 - 3 Finished creating fully customized database scaffolding with rails!
$ rails new my1stproject
$ cd my1stproject
$ bundle install
$ rails generate scaffold Users name:string address:text phone:string
$ rake db:migrate
$ rails server

Ruby on Rails3 demo



Please visit the ruby on rails official screencast page to watch the video tutorial
http://rubyonrails.org/screencasts
Please do correct or do share with me if you experience something weird or there is a mistake in my method.

Saturday, October 2, 2010

New gen2

How about if proton release its new gen2 looks like this