How to set up ( Fedora php ruby on rails )

Thursday, December 30, 2010

CodeRay with Ruby On Rails 3

Code highlight in Ruby On Rails 3 Using CodeRay

First open your Gemfile and add

gem 'coderay'

and run bundle install

bundle install

Next you need to add a method any where you want best place would be ApplicationController

def coderay(text)
text.gsub(/<code( lang="(.+?)")?>(.+?)<\/code>/m) do
CodeRay.scan($3, $2).div(:css => :class)

Suppose you have controller Post and it's action show

def show
@post = Post.find(params[:id])
@post.body = coderay(@post.body)

now in view file change following

<%= @post.body %>


<%= sanitize @post.body %>

Now you need a stylesheet that define color scheme for your code{/* attribute name fat */}{/* attribute name */}
span.av{/* attribute value */}{/* attribute value fat */}{/* bin */}
span.c{/* comment */}{/* char */}{/* class*/}{/* colour */}{/* constant */}{/* class variable */}
span.df{/* definition */}
span.di{/* directive */}
span.dl{/* delimeter */}{/* doc */}
span.ds{/* doc string */}
span.e{/* escape */}{/* error */}
span.ex{/* exception */}
span.fl{/* float */}
span.fu{/* function */}
span.gv{/* global variable */}
span.hx{/* hex */}
span.i{/* integer */}
span.ic{/* include */}{/* ident */}{/* inline */}{/* interpreted */}
span.iv{/* instance variable */}
span.k{/* content */}{/* css attribute */}{/* css selector */}{/* label */}{/* local variable */}
span.mod{/* modifier */}
span.oc{/* oct */}
span.on{/* operator name */}
span.op{/* operator */}
span.pc{/* pre constant */}{/* pre type */}
span.pd{/* predefined */}
span.pp{/* preprocessor */}
span.rx{/* reg exp */}
span.r{/* reserved */}
span.s{/* string */}{/* shell */}
span.sp{/* space */}{/* symbol */}
span.ta{/* tag */}{/* tag fat */}
span.ts{/* tag special */}
span.ty{/* type */}
span.v{/* variable */}
span.vl{/* css value */}
span.xt{/* xml text */}

Wednesday, December 29, 2010

How to update rails site hosted on Heroku

So how to update changes made locally to remote server

Very simple to do that, make amendments in your project and than follow these steps

Note: Be sure you are in root of application directory

[rubyonrails@localhost rails_sandbox]$ git add .

[rubyonrails@localhost rails_sandbox]$ git commit -m "some message here"

[rubyonrails@localhost rails_sandbox]$ git push heroku master

Ruby on Rails Free Hosting

Hosting Ruby On Rails Free

Host rails 2 or rails 3 apps for free and easily

Once you set up a site, you can set up as many sites as you want

If you are a Rails developer and want to host for free for testing purpose check-out

For this you need to sign-up for two sites first is Heroku and other is github..
After sign-up go to quick start page of and follow instructions and in the end you would have a hosted rails application

Need Help:

Do comment

Saturday, October 2, 2010

Ruby On Rails 3 on Fedora 14

Fedora 14(Laughlin) and Rails 3

This post will just let you install only on version of rails on your Fedora 14 that is rails 3 but first we will install rails 2.3.8 from fedora repository. Keep in mind you will able to run only one version of Rails with this method and if you want to run multiple version or installtion than you need to follow on of my old post in which i have used RVM for manging different version of Ruby and also Rails.
Installing and setting up Rails 3 on Fedora 13 (Ruby on Rails 3 RC)

First Installing Ruby 1.8.7 with Rails 2.3.8

[ismail@localhost ~]$ sudo yum install rubygem-rails ruby-devel mysql-devel-y

Now you have running version rails 2.3.8 without mysql database support for rails

Adding mysql rails and ruby support

[ismail@localhost ~]$ sudo yum install ruby-mysql -y

Note: Now you can stop following if you don't want to install rails 3 on fedora 14

upgrading to Rails 3

[ismail@localhost ~]$ sudo gem install rails

If all went cool than you have running version of rails 3 on fedora 14 now create an application and run bundle install to test your installation

[ismail@localhost ~]$ rails new my_app -d mysql
[ismail@localhost ~]$ cd my_app
[ismail@localhost ~]$ bundle install

Have fun with Rails 3 on Fedora 14

Monday, September 6, 2010

ruby 1.9.2 installation on fedora 13 ( also on fedora 14)

Waiting for ruby 1.9.2 or 1.9.1 for fedora?

Your wait have both ended and not. ended in sense now you can install latest release on fedora 13 or fedora 14 using RVM. but bad news is for ruby 1.9.x native install won't come early. Sooner we will have ruby1.8.7 but no chance for ruby 1.9.x so start using ruby1.9.x on rvm if you are curious to that actually really a cool application that can handle multiple ruby version at the same time. if you want to install ruby 1.9.x than you can follow by old post which is about installing ruby on rails 3 on fedora 13.

Ruby on Rails 3 have been released.

Yes Rails 3 have been released and it requires ruby version 1.8.7 or 1.9.2 actually 1.9.1 have number of bugs so rails community recommends you to use 1.9.2 so nor yet ubuntu have ruby 1.9.2 (the day i am posting this post till than ) so you can install using rvm and for installation of rails 3 on fedora you can follow my old post about installing ruby on rails 3 release candidate as rails is released so now you can you use the released version of rails 3. and my previous post will work fine for that. Well if you are running ruby 1.8.7 or above you can install rails 3 by just with single command

sudo gem install rails

Troubling install MySQL with rails 3?

sudo yum install mysql-devel

Use about command in fedora and than install using gem or through bundle install command in your rails project everything will work cool and that will actually install mysql2 driver

Saturday, September 4, 2010

Creating read more links in ruby on rails 3

Read morelinks in rails 3

this episode describe you how to create read more links in your rails projects

Thursday, July 22, 2010

Installing and setting up Rails 3 on Fedora 13 (Ruby on Rails 3 RC)

How To installing Ruby On Rails 3 (Release Candidate) on Fedora 13

First make sure following packages are installed on you fedora 13 system.(Requires especially if you have installed fedora from live CD instead of DVD)

[ismail@localhost ~]$ sudo yum install git bison svn autoconf sqlite-devel

Do almost every task where possible as normal user instead of super user for this installation

To start installation of Rails 3 on fedora we are using RVM(ruby version manager) so we can use our old stable release as well latest beta on our fedora system

First of all we need to install RVM so lets begin

[ismail@localhost ~]$ bash < <( curl )

Now add the following line to your .bashrc file:

[ismail@localhost ~]$ if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then source "$HOME/.rvm/scripts/rvm" ; fi

Now you need to close termial and start again and run following command:

[ismail@localhost ~]$ rvm notes

Above command will reveal the dependencies for installing ruby using RVM cuz it compile stuff and than you can install ruby without any pain with single command:

[ismail@localhost ~]$ sudo yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel

Now lets install ruby 1.9.2-head cuz rails 3 requires ruby 1.8.7 or greater and 1.9.2 have less bugs than others

[ismail@localhost ~]$ rvm install ruby-1.9.2-head

Now lets make ruby 1.9.2 as default so we can install rails 3 pre and don't worry you can easily come back to previous version with single command without and pain or problem

[ismail@localhost ~]$ rvm ruby-1.9.2-head --default

Now its time to install Rails 3 its simple to do just issue one command and you are done with installation

[ismail@localhost ~]$ gem install rails --pre

Your installation completed but no database support yet so you need to install sqlite3-ruby so you can work with rails 3 beta

[ismail@localhost ~]$ sudo gem install sqlite3-ruby

Now create your applications in Rails 3. Lets start.....

[ismail@localhost ~]$ rails new myApplication

Now go to newly created application folder

[ismail@localhost ~]$ cd myApplication

Now we need to run last command(Hope so) so our system fully working with rails

[ismail@localhost ~]$ bundle install

Now Start your rails server

[ismail@localhost ~]$ rails s

Open your browser and open localhost:3000


You may face error like activesupport requires ruby >= 1.8.7 try closing all terminal and than trying gem install rails --pre again and don't use sudo with this command as it will install in user directory so no need and you can make sure that gem using ruby 1.9.2-head by command gem env

I've been trying for long to install Rails 3 on fedora and atlast i've succeed and if you have errors regarding installing do comment and ya i am missing one thing that is using MySQL instead SQLite and and and ya thats it have fun with rails 3

Sunday, February 21, 2010

Installing Ruby On Rails Fedora 12 and 13

Setting Up Ruby On Rails on Fedora 12 and 13 one step only

Just one command and every thing is done

[ismail@localhost ~]$ sudo yum install rubygem-rails ruby-mysql rubygem-sqlite3-ruby rubygem-mongrel* rubygem-json rubygem-git ruby-devel

[ismail@localhost ~]$ sudo gem update

Why same post again

Following Error i confront so to resolve the problem here is new way

-bash-4.0$ rails my_app -d mysql
/usr/lib/ruby/site_ruby/1.8/rubygems.rb:827:in `report_activate_error': RubyGem version error: rack(1.1.0 not ~> 1.0.0) (Gem::LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:261:in `activate'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:296:in `activate'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:295:in `each'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:295:in `activate'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:296:in `activate'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:295:in `each'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:295:in `activate'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:68:in `gem'
from /usr/bin/rails:18

Updating gem does the work

[ismail@localhost ~]$ sudo gem update

So we are done here and enjoy programming with rails on Fedora 12

Ruby On Rails Rocks