Pages

How to set up ( Fedora php ruby on rails )

Monday, February 14, 2011

Rake Route(How to see routes of specific controller)

How to target specific controller in rake routes command


Most of time i need to look at my routes and as project increases so the list of routes and it's get confusing to find a specific routes using rake routes command so here is the answer


rake routes CONTROLLER=controller_name

For Example


rake routes CONTROLLER=posts

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)
end
end


Suppose you have controller Post and it's action show
app/controllers/posts_controller.rb



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


now in view file change following
app/views/posts/show.html.erb


<%= @post.body %>


To


<%= sanitize @post.body %>


Now you need a stylesheet that define color scheme for your code


span.af{/* attribute name fat */}
span.an{/* attribute name */}
span.av{/* attribute value */}
span.aw{/* attribute value fat */}
span.bi{/* bin */}
span.c{/* comment */}
span.ch{/* char */}
span.cl{/* class*/}
span.cr{/* colour */}
span.co{/* constant */}
span.cv{/* class variable */}
span.df{/* definition */}
span.di{/* directive */}
span.dl{/* delimeter */}
span.do{/* doc */}
span.ds{/* doc string */}
span.e{/* escape */}
span.er{/* error */}
span.ex{/* exception */}
span.fl{/* float */}
span.fu{/* function */}
span.gv{/* global variable */}
span.hx{/* hex */}
span.i{/* integer */}
span.ic{/* include */}
span.id{/* ident */}
span.il{/* inline */}
span.in{/* interpreted */}
span.iv{/* instance variable */}
span.k{/* content */}
span.ke{/* css attribute */}
span.kw{/* css selector */}
span.la{/* label */}
span.lv{/* local variable */}
span.mod{/* modifier */}
span.oc{/* oct */}
span.on{/* operator name */}
span.op{/* operator */}
span.pc{/* pre constant */}
span.pt{/* pre type */}
span.pd{/* predefined */}
span.pp{/* preprocessor */}
span.rx{/* reg exp */}
span.r{/* reserved */}
span.s{/* string */}
span.sh{/* shell */}
span.sp{/* space */}
span.sy{/* symbol */}
span.ta{/* tag */}
span.tf{/* 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 http://www.heroku.com


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 heroku.com 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