Ruby on Rails guide web sites

1. Gems release, current  version, popularity, bug tracker and for gem wiki link

https://www.ruby-toolbox.com/

(a) https://apidock.com  For all tags and usage

2. Ruby language Fundamentals

http://ruby-doc.org/ under it http://docs.ruby-doc.com/docs/ProgrammingRuby/

3. Rails API doc

http://railsapi.com/

4. Get started with rails installation

http://rubyonrails.org/

5. Subversion Git

http://gitref.org/

6.  Live example

http://railsforzombies.org/

7. Online practice Ruby

codepad.org

Advertisements

How to open mobile view on Desktop browsers?

Actually it is very simple

1. Firstly you will have to install Mozilla Firefox browser on you stytem.
2. Install the User Agent AddOn in Firefox and restart Firefox.
3. From Tool Bar of Firefox: Tools >> Default User Agent >> iPhone

Destop firefox user Agent to open mobile view iphone, android on desktop
Destop firefox user Agent

Then this will open the iPhone view of the websites for you in desktop if it exists.
Now, If you want to view the looks of the website for other devices the go to:
Tools >> Default user Agent >> Edit User Agents >> New >> New User Agent

User Agent Firefox
Edit User Agent

and then in
Description : Example iPhone, Android, Tablet etc
User Agent : Paste the following

For iPhone :
Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16

Tablet ios :
Mozilla/5.0 (iPad; CPU OS 6_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B141 Safari/8536.25

BlackBerry:
BlackBerry8520/5.0.0.681 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/301

Android 4.04:
Mozilla/5.0 (Linux; U; Android 4.0.4; en-gb; GT-S7562 Build/IMM76I) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30

This UserAgent woks fine with Ruby on Rails Project using Mobile_Fu gem for creating different mobile views.

How to freeze my Rails application?, Why I Should freeze my Rails application?

Ruby on Rails allows you to “freeze” the version of Rails used by your application.

1. Following command will freeze your application to the version of Rails that is currently on server:

rake rails:freeze:gems

This command will copy the Rails files to the “vendor/rails” directory of the application. When the Rails application the it will first check for the presence of “vendor/rails” directory. If it exists, Rails will load the Rails components from the directory instead of using the main server copy of Rails.

Unfreezing:

rake rails:unfreeze

Freezing to a different version

This command freezes the application to Rails 2.2.2:

rake rails:freeze:edge RELEASE=2.2.2

Following command freezes Rails to the current development version of your application:

rake rails:freeze:edge

To Find the Rails version of your application using use this command:

script/about

After updating Rails version update your configuration file “config/boot.rb”:

rake rails:update

Ajax call on succes of the previous ajax call?

1st ajax call:


$.ajax({
url:"/your_controller/your_action",
cache:false,
success:function (data) {
check_subs = data; //returned text
if(check=="no"){
alert("This service is not for you.")
}
if(check_subs=="yes"){
var calling_url='http:///subscription/.aspx?entrytype=ACT&entrymode=pack_w&request_attempt=' + random_uuid;
$.ajax({ //2nd ajax call
url:calling_url,
cache:false,
success:function (data) {
alert("Your request for pack is sent ");
console.log(data);
}
});

}
}
});
}
}

Post caling in rails with link_to tag.

Http calling:

<%= link_to “Click to call”, url_for(:action => ‘your_action’, :controller => ‘your_controller’), {:class => ‘html_class’, :method => :post %>

Ajax calling:

<%= link_to “Click to call “, url_for(:action => ‘your_action’, :controller => ‘your_controller’), {:class => ‘html_class’, :method => :post, :remote => true} %>

Css elements used to keep your the html elements at their appropriate location.

Actually by profession I am a application developer and deals in developments in web and desktop. More interestingly I spent my time in writing logic’s and db and end user GUI  management. But now in my new company we don’t  have a designer so I am doing a designer job too and sharing my experience in form of a blog. So here is my small blog with few css important points and elements. I will keep on updating this post.

Point 1: Never design a page using table tags always use div.

Actually By using table tags you are just limiting your design scope.Because init you will have to keep every element inside a TD tag and then handling every elements by TDusing colspan & rowspan and giving every TD different width and height or giving TD  an ID or class and then handling thoes TD on css page is a complete mess. Moreover if place a DIV inside TD the whole look of your website will be ruptured in Internet Explorer and Opera. But may work fine with Chrome and Mozilla browser.

CSS:

1. Margin: margin-left , margin-right, margin-top, margin-bottom

2. Padding: margin-left , margin-right, margin-top, margin-bottom

3. z-index

4. Opacity: Range 0.0 to 1.0

5. Filter: Range 0 to 100 Specially for Internet explorer

example: alpha(opacity=40);

6. Float: left, right

7. Position: static, relative, absolute, fixed

8. Vertical-algin: middle, top, bottom, inherit, text-top, text-bottom  http://www.w3schools.com/cssref/playit.asp?filename=playcss_vertical-align&preval=50%25

9. line-height: px and % used to blur or darken text or setting gap between 2 consecutive                      dlines.

10. white-space: nowrap , will remove all enter.

Eclipse stops functioning if we update java version via notification or from else where?

After updating a java version why eclipse stops functioning or the java programs which were executing fine stop executing and on terminal when we ask for java to tell its version by java -version command in prompt it gives us the following error:

C:\Users\Dell>java -version
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object

what is the reason behind all this it means your java version have been changed and latest java updates has been installed and now you must update you system variable to get back every thing normal. Go to : properties of your computer then system properties then in system variable update the PATH by edit option and init preappend the PATH to your new jre which in my case is :

C:\Program Files\Java\jdk1.6.0_22\jre\bin

then every thing get back to normal.

Using MySql Remote database for ruby on rails application ?

Answer: If you want to use common database for a Ruby on Rails application running at more than one front end servers. You can do it by using grant command.

lets go step by step:

1.  Server on which you want to host the database for multiple / single instances

 $ mysql -u root -p

2. Granting permission of access to remote hosts:

  mysql > grant all on database_name.* to root@'ip_address' identified by ' ';

To grant access to multiple front end server repeat above command by changing the ip_address to the ip_address of the front end servers.

3. Now inside your database.yaml

development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: database_name
  port: 3306
  pool: 5
  username: root
  password:
  host: ip_address_hosting_database

Q: How to make your CentOS 5.8 compatibale with Ruby on Rails development environment and resolve libyaml error?

Answer: Exactly 3 months back I was new to Ruby on Rails but thanks to the documentation of ruby on rails and Head First guide which act like a mentor to me in understanding this wonderful framework.

So lets first focus on how to make our server compatible for ruby on rails development.

Follow the simple steps:

Point to remember always $yum update before installation
 If you are admin/root create a new user in your server as: 
1. useradd -m vidur -u 211 -g root -s /bin/bash -d /home/vidur
if Bug / Error :
 bash: adduser: command not found
solution: export PATH=/usr/sbin:PATH

change its password
2. passwd vidur

3. relogin as vidur

4. download Ruby  http://rubyonrails.org/download

Become admin again from vidur terminal
5. su  

6. mv ruby-1.9.3-p0 /opt/

Inside ruby-1.9.3-p0 directory
7. ./configure

8. make

9. make install

check if ruby is successfully installed ?
10. check ruby -v

11. gem update --system

12. gem install rubygems-update

Bug/Error Report:
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.

Solution :
13. Reference: http://collectiveidea.com/blog/archives/2011/10/31/install-ruby-193-with-libyaml-on-centos/
    $ wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
    $ tar xzvf yaml-0.1.4.tar.gz
    $ cd yaml-0.1.4
    $ ./configure --prefix=/usr/local
    $ make
      $ make install
 Now reinstall the ruby
  $ wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz
    $ tar xzvf ruby-1.9.3-p0.tar.gz
    $ cd ruby-1.9.3-p0
    $ ./configure --prefix=/usr/local --enable-shared --disable-install-doc --with-opt-dir=/usr/local/lib
    $ make
    $ make install

14. check gem --version

For IDE RubyMine
15. Donwload JDK 64 tar bit http://www.oracle.com/technetwork/java/javase/downloads/jdk7u7-downloads-1836413.html

16. mv /home/vidur/Desktop/java /opt/

17. vim ~/.bashrc 

18. Both in su and vidur bashrc file
       export PATH=/opt/jdk1.7.0_07/bin:$PATH
       export JAVA_HOME=/opt/jdk1.7.0_07 

19. Download Rubymine from http://www.jetbrains.com/ruby/download/download_thanks.jsp?os=linux

20. mv RubyMine-4.5.4.tar.gz /opt/

21. gunzip RubyMine-4.5.4.tar.gz 

22. tar -xvf RubyMine-4.5.4.tar 

23. In bashrc of su and vidur
     export PATH=/opt/RubyMine-4.5.4/bin:$PATH

24. rubymine.sh   

25. sudo yum install mysql-server mysql mysql-devel

26. gem install passenger

creating new rails application
27. rails new myapp -d mysql

26. cd myapp

28. passenger start 

Now we have RubyMine as the development environment , mysql as database, Server Passenger & rails framework.
Happy coding

******************************************************concluded********************************************************

Create a free website or blog at WordPress.com.

Up ↑