:-[] :-|| Vivek Khokhar rambles here :-O :-[]

December 6, 2007

/bin/rm: Argument list too long tmp/sessions/ruby_sess.*

Filed under: Linux, Ruby, Rails — Vivek Khokhar @ 5:25 pm
Well this happens when there are too many files to process:
Best way in this case is to do batch processing:
Sample command:
find . -name 'ruby_sess.*' -print0 | xargs -0 rm

July 26, 2007

RAILS_ROOT

Filed under: Ruby, Rails — Vivek Khokhar @ 1:38 am

RAILS_ROOT gives you relative path within the applications it works fine as far as you need the path within rails application.

How about getting absolute path to rails folder?

I found one way, and thats from the ENV hash.

You can use ENV[’PWD’] to find absolute path to the rails folder.
Any other ways ??

*Update 4th Oct 2007*

Dir.pwd is a better way

June 11, 2007

Ruby: Can’t modify frozen string

Filed under: Ruby — Vivek Khokhar @ 1:14 am

Workaround:

_use_me = frozen_string.dup

Rails RJS redirect

Filed under: Ruby, Rails — Vivek Khokhar @ 1:12 am

page.redirect_to :action => ‘thanks’, :p1 => @g_resp.params[”_code”], :p2 => @r_id

April 19, 2007

textbox image alignment problem

Filed under: Ruby, css — Vivek Khokhar @ 12:40 am

Problem:

text_field(:member, :dob,:size=>”20″, :maxlength => “50″,:tabindex=>”22″) img_tag

Fix:

text_field(:member, :dob,:size=>”20″, :maxlength => “50″,:tabindex=>”22″) img_tag {:style=”position:absolute”}

January 2, 2007

fastcgi lighttpd rubyonrails Error: getcwd no such file or directory

Filed under: Ruby — Vivek Khokhar @ 4:25 am

I got this error today while deploying rails application on running lighttpd server.
Errno::ENOENT (No such file or directory - getcwd)
I replaced application directory without stopping lighty and got error while trying accessing app via browser.
I went off by merely restarting lighthttpd :)

Seems like server creates/uses some file “within” rails app folder which got erased while replacing the folder.

October 8, 2006

Ruby HEREDOC Syntax

Filed under: Ruby — Vivek Khokhar @ 6:11 pm
html = <<-EOT

all  html goes here

EOT

April 6, 2006

Rails: Cross Database development

Filed under: Ruby — Vivek Khokhar @ 2:34 pm

Its a piece of cake developing applications that run on multitude of Database management solutions.
All you need to keep Database schema scripts handy. Here is how you do it using rails scripts:

> ruby script\generate migration Contact

This will create an empty file in db/migrate folder for contact table. You need to fill it now with the fields you want
for eg:

class Contact < ActiveRecord::Migration
def self.up
create_table :contacts do |table|
table.column :first_name, :string
table.column :last_name, :string
table.column :email, :string
table.column :phone, :string
table.column :address, :string
end
end
def self.down
end
end

Ok.. just found what I was looking for. Pretty detailed document for this: http://rubyonrails.org/api/classes/ActiveRecord/Migration.html

Now, apply the migration

> rake migrate

Now, generate model and controller for Contact

>  ruby script\generate scaffold Contact

March 15, 2006

Mysql Rails Windows

Filed under: Ruby — Vivek Khokhar @ 10:16 am

Ok Lets try ruby on rails, lots of hype around.

First of all followed the link, and did as said here
http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html

Hour 2

Ruby installed, rails installed. But not working with mysql. I am getting lost connection problem everytime I try to run the application.
Hour 3

Mysql Lost connection problem is solved by copying mysql.so from the rar file I got from following link
http://wiki.rubyonrails.org/rails/pages/HowToUseMySQLRubyBindingsOnWin32/versions/28

OR try this one: I havent tried it though
http://seagecko.org/thoughts/in-the-past/2004/09/09/ruby-mysql-and-windows/

Just copied mysql.so in #path-to-ruby#\lib\ruby\site_ruby\1.8\i386-msvcrt, restarted webserver, and it worked. Didnt Used other dlls in rar, dont think i need in my case. I am using 4.1.9-nt version of mysql

Powered by WordPress