Archive for June, 2006

Configuring Multiple Rails Application with Lighttpd

I was using lighttpd web server for my Rails applications.
In development mode I was starting lighttpd server from the rails application directory by

lighttpd -D -f config/lighttpd.conf
But I was facing problem when I tried to run multiple rails applications in production mode. After some trials I succeded.

I inserted the following lines of code in my /etc/lighttpd/lighttpd.conf file

$HTTP[“host”]== “domain.com” {

server.error-handler-404 = “/dispatch.fcgi”

server.document-root = “/home/railsapp/public/”

server.errorlog = “/home/railsapp/log/lighttpd.error.log”

accesslog.filename = “/home/railsapp/log/lighttpd.access.log”

url.rewrite = ( “^/$” => “index.html”, “^([^.]+)$” => “$1.html” )

fastcgi.server = ( “.fcgi” => ( “localhost” => (

“min-procs” => 1,

“max-procs” => 1,

“socket” => “/home/railsapp/tmp/sockets/fcgi.socket”,

“bin-path” => “/home/railsapp/public/dispatch.fcgi”,

“bin-environment” => ( “RAILS_ENV” => “production” )

) ) )

}

$HTTP[“host”]== “another.domain.com” {

server.error-handler-404=”/dispatch.fcgi”

server.document-root = “/home/anotherrailsapp/sparitual/public/”

server.errorlog = “/home/anotherrailsapp/log/lighttpd.error.log”

accesslog.filename = “/home/anotherrailsapp/log/lighttpd.access.log”

url.rewrite = ( “^/$” => “index.html”, “^([^.]+)$” => “$1.html” )

compress.filetype = ( “text/plain”, “text/html”, “text/css”, “text/javascript” )

compress.cache-dir = “/home/anotherrailsapp/tmp/cache”

fastcgi.server = ( “.fcgi” => ( “localhost” => (

“min-procs” => 1,

“max-procs” => 1,

“socket” => “/home/anotherrailsapp/tmp/sockets/fcgi.socket”,

“bin-path” => “/home/anotherrailsapp/public/dispatch.fcgi”,

“bin-environment” => ( “RAILS_ENV” => “production” )

) ) )

}

Then started the lighttpd server by

lighttpd -D -f /etc/lighttpd/lighttpd.conf

And it worked…

June 28, 2006 at 10:06 pm Leave a comment

Cartographer: A Google maps API in Rails

If you want to insert google maps in your rails application, then you can use cartographer.
This is still in development.

June 27, 2006 at 9:37 pm Leave a comment

Plugin: cssForm

AD.D SoftWare have developed a new plugin for Rails called cssForm that lets you create forms without tables, entirely using CSS.

The interesting thing about this plugin is the way it lets you wrap certain behavior around standard elements. This technique could be very useful to pick about and redevelop for your own preferences.

June 23, 2006 at 5:35 am Leave a comment

How to search for a string on multiple fields across multiple joined tables in Rails

In my project I have to write a search controller, in which I have to search for a string on multiple fields across join tables.

There are two controllers Project, Publication and two models project and publication.
Project has many publication and publication belongs to project.

I wanted to search for a string on all fields of project and publications. For that I wrote a query in which I have to mention all the fields on which I wanted to search.
This was fine, but after some days I found a plugin: TextSearch. This changed the whole stuff.

This is a very useful plugin for search and you should try this.
For more detail please visit http://wiki.rubyonrails.org/rails/pages/TextSearch

June 23, 2006 at 12:27 am 8 comments

Plugin: file_column

This is straight from the “file_column website”:http://www.kanthak.net/opensource/file_column/:

Just make the “image” column ready for handling uploaded files…

class Entry < ActiveRecord::Base
file_column :image
end

… generate file fields *that keep uploaded images during form redisplays to your view…

<%= file_column_field “entry”, “image” %>

… and display uploaded images in your view:

<%= image_tag url_for_file_column(“entry”, “image”) %>

However, you may want to protect against the model object having no uploaded image:

<%= image_tag url_for_file_column(“entry”, “image”) if @entry.image %>

To resize every uploaded image to a maximum size of 640×480, you just have to declare an additional option.

class Entry < ActiveRecord::Base
file_column :image, :magick => { :geometry => “640×480>” }
end

You can even automatically create versions in different sizes that have nice filenames…

class Entry < ActiveRecord::Base
file_column :image, :magick => {
:versions => { “thumb” => “50×50”, “medium” => “640×480>” }
}
end

… and display them in your view:

<%= image_tag url_for_file_column(“image”, “entry”) %>

June 22, 2006 at 11:42 pm 8 comments

Rails: Issuing direct query to database

You can issue direct query to database by:

result = ActiveRecord::Base.connection.execute("SELECT * from tablename")

and fetch hash:

a=result.fetch_hash

June 19, 2006 at 2:25 am Leave a comment

Plugin: NumbersToWords

In my RAILS application I need to convert numbers to words. I started writing own function but before I finish that I got an amazing Plugin.

This Plugin is capable to convert number to words.
Following are some examples

>> 5.to_english
=> “five”
>> 123456.to_english
=> “one hundred twenty-three thousand four hundred and fifty-six”
>> 2.5.to_english
=> “two”
>> (2.5).to_english
=> “two”
>> (2.5).to_dollars
=> “two dollars and fifty cents”
>> 5.to_japanese
=> “go”
>> (2.5).to_japanese
=> “ni”

install this plugin by :
script/plugin install http://svn.recentrambles.com/plugins/numbersToWords

June 16, 2006 at 6:27 am 2 comments

Older Posts


Important Notice…

I have moved this blog to http://webonrails.com . I will continue posting at http://webonrails.com, not on https://webonrails.wordpress.com.

Kindly update your book marks to http://webonrails.com

and http://webonrails.com/feed .

I am really very sorry for inconvenience.

Comming Soon….

Domain for Sale

TheRailsHosting.com


(Contact me)

Recent Posts

Calender

June 2006
M T W T F S S
« Apr   Jul »
 1234
567891011
12131415161718
19202122232425
2627282930  

Subscribe

  • Add to Google
  • Subscribe in NewsGator Online
  • Subscribe with Bloglines
  • WebOnRails on feedburner
  • technorati

del.icio.us

Feeds

Flickr Photos

Visitor’s Location

Blog Stats

  • 18,077 hits