Android ?
November 22, 2008
Android ………Will post in details soon..
ri and rdoc in Ruby On Rails
November 16, 2008
To install ri and rdoc of any gem,
gem install gemname
This command installs ri and rdoc with installation of gem.
To skip the installation of ri and rdoc of gem,
gem install gemname –no-ri –no-rdoc
This command will skip the installation of ri and rdoc when installing gem.
We can pass the multiple parameters with remote_function or link_to_remote…
<%= link_to_remote "View Data",
:url => :action => "list",
:with => " 'name=' +$('div-id-of-name-text-box').value + '&city=' +$('div-id-of-city-text-box').value + '&country=' +$('div-id-of-country-text-box').value " %>
or
<%= remote_function(:url => :action => "list",
:with => " 'name=' +$('div-id-of-name-text-box').value + '&city=' +$('div-id-of-city-text-box').value + '&country=' +$('div-id-of-country-text-box').value " ) %>
GIT with branches
October 31, 2008
GIT – Fast Version Control System
October 25, 2008
GIT is distributed version control system. Following is a small stuff which may help to use GIT with our applications,
Goto root directory of the application, say my application is ‘demo’.
1. To take the code from GIT server,
bango@bango-desktop:~$ git clone <git-url>
After that, I need to change my directory to ‘/demo’. To update the code from GIT server,
bango@bango-desktop:~/demo$ git pull
2. Once you complete the functionality, and if you want to commit the code to GIT server, then
bango@bango-desktop:~/demo$ git status
‘git status’ will show you the names of all changed files.
3. To add changed files to GIT server,
bango@bango-desktop:~/demo$ git add <path_of_the_1st_changed_file>
bango@bango-desktop:~/demo$ git add <path_of_the_2nd_changed_file>
like this, add all files.. and if you have many files and if you want to add them at a time, then
bango@bango-desktop:~/demo$ git add .
4. To commit the code to GIT server,
bango@bango-desktop:~/demo$ git commit -m “<your-message-regarding-the-functionality>”
5. To push the code to GIT server,
bango@bango-desktop:~/demo$ git push origin master
You may find more commands here… http://www.kernel.org/pub/software/scm/git/docs/
I am using GIT with my RubyOnRails applications.
Import and Export Database to/from MySQL
October 23, 2008
Small stuff about how to import and export data to/from MySQL with the help of mysql and mysqldump commands,
IMPORT database to MySQL,
D:\>mysql -u username -p password database_name < file.sql
database_name should be there in database. Put your username, password and database_name with yours MySQL information. After this command, data from file.sql will be imported to your database.
EXPORT database from MySQL,
D:\>mysqldump -u username -p password database_name > file.sql
Please replace username, password and database_name with yours MySQL information.
After this command, data will be exported to file.sql
Access Remote MySQL database in RubyonRails application
October 23, 2008
To give the remote access to database, on server, we have to give the following command,
mysql> CREATE DATABASE foo_development;
mysql> GRANT ALL ON foo_development.* TO root@'192.168.1.25' IDENTIFIED BY 'PASSWORD';
where 192.168.1.25 – IP Address of the client machine,
Now modify ../config/database.yml file in our RoR application as follows,
development:
adapter: mysql
database: foo_development
username: root
password: PASSWORD
host: 192.168.1.1
where 192.168.1.1 – IP Address of server
RESTful architecture
May 29, 2008
RESTful interface means clean URLs, less code, CRUD interface.
CRUD means Create-READ-UPDATE-DESTROY.
You might heard about HTTP verbs, GET, POST. In REST, they add 2 new verbs, i.e, PUT, DELETE.
There are 7 default actions, those are – index, show, new, create, edit, update, destroy
GET is used when you retrieve data from database. POST is used when you create new record in database. PUT is used when you are updating any existing record in database, and DELETE is used when you are destroying any record in database. Following table may clear the concept.
Action VERB
index GET
show GET
new GET
create POST
edit GET
update PUT
destroy DELETE
DateTime formatting in RubyonRails
May 29, 2008
To display datetimes in different formats in Ruby On Rails application,
following may help,
Format meaning:
%a – The abbreviated weekday name (“Sun”)
%A – The full weekday name (“Sunday”)
%b – The abbreviated month name (“Jan”)
%B – The full month name (“January”)
%c – The preferred local date and time representation
%d – Day of the month (01..31)
%H – Hour of the day, 24-hour clock (00..23)
%I – Hour of the day, 12-hour clock (01..12)
%j – Day of the year (001..366)
%m – Month of the year (01..12)
%M – Minute of the hour (00..59)
%p – Meridian indicator (“AM” or “PM”)
%S – Second of the minute (00..60)
%U – Week number of the current year, starting with the first Sunday as the first day of the first week (00..53)
%W – Week number of the current year, starting with the first Monday as the first day of the first week (00..53)
%w – Day of the week (Sunday is 0, 0..6)
%x – Preferred representation for the date alone, no time
%X – Preferred representation for the time alone, no date
%y – Year without a century (00..99)
%Y – Year with century
%Z – Time zone name
%% – Literal “%” character
For example,
t = Time.now
t.strftime(“Printed on %m/%d/%Y”) #=> “Printed on 04/09/2003″
t.strftime(“at %I:%M%p”) #=> “at 08:56AM”
Ruby on Rails becoming popular due to ….
April 26, 2008
Here are few points why Rails is becoming popular,
1. Scalability: Rails application is more scalable as there are numerous options available, such as mongrel clusters on linux, mongrel win32 service for Windows.
2. Documentation: Rails has better documentation as we can always view the source of everything. Following are few sites for the best documentation for Rails like,
http://api.rubyonrails.org/
http://www.railsbrain.com/ (Documentation for all Rails version’s)
http://www.ruby-doc.org/
3. Community Support: Rails has huge community support as it is Open Source technology. It is excellent, like,
http://www.railsforum.com/
http://www.ruby-forum.com/
http://www.workingwithrails.com/forums
4. Hosting is not a problem: numerous hosting options available in Rails like,
http://www.site5.com/
http://www.joyent.com/
http://railsmachine.com/
http://www.railsplayground.com/
http://www.slicehost.com/
http://www.brightbox.co.uk/
http://www.dreamhost.com/
http://www.hostingrails.com/
http://mediatemple.net/
http://heroku.com/
Also there are many other sites for Rails application hosting with proper documentation.
Due to phusion passenger (mod_rails – http://www.modrails.com/), It seems to be easier these days to find rails application hosting. This is only going to influence more towards rails as time goes by for the simple fact that hosting companies do not have to pay royalties to anyone.
5. Development Methodology: Very good approach of Rails i.e, Transition from development to test and then to production better thought of in RoR
6. Deployment: Capistrano (the most common deployment technique for rails) beats everything.
7. Rails apps can be deployed on any OS.
8. Rails has built in ORM (Object Relational Mapping – ActiveRecord)
9. Rails apps can connect to multiple databases
10. Don’t requires licensing cost for Rails
11. Rails has complete support on all available OS
12. Rails has very good feature like “Don’t Repeat Yourself (DRY)” and “Convention over Configuration (CoC)”