Archives for January 2008

Installing SVN with ra_dav support for http and https protocols

I was not able to setup the SVN on the suse linux as easy as on Ubuntu. In Ubuntu I think its simply by apt-get install subversion, but here even after compiling the source I was not able to enable the support of ra_dav module for http and https protocol. Later on after all the research I finally did by properly installing neon with required configuration options needed by SVN for ra_dav and thought to consolidate them all as a blog post. So here it is…

Pre-requisites

  • tzdata
  • expat
  • apr
  • apr-util
  • neon

First, install all the tzdata and expat with legacy commands 1) ./configure 2) make and 3) make install. without any specific conguration.

Install the apr(Apache Portable Runtime) like above as well.
Now install the apr-util by specifying your apr
[source:ruby]
./configure –with-apr=/usr/local/apr
make
make install
[/source]

The apr usually resides at /usr/local/apr if its not there in your machine, first find the directory using
find / -type d -name apr
then mention the apr in the apr-util configuration.

Now, its better and more configurable to install neon as a separate library and then to configure subversion accordingly.
Configure and install neon from the neon source

[source:ruby]
./configure –with-ssl –with-pic –enable-shared
make
make installl
[/source]

after installing neon check the configuration of neon from the executable file neon-config(which usually goes in /usr/local/bin/neon-config) by issuing the command neon-config. This will show the configuration options for neon. The configuration for –prefix shows the default(/usr/local) include path of installed neon library. For configuring the subversion we need to use this default include path or the path(–prefix) if you have mentioned while installing neon.

Now configure and install the subversion as
[source:ruby]
./configure –with-ssl –with-apr=/usr/local/apr –with-apr-uitl=/usr/local/apr –with-neon=/usr/local
make
make install
[/source]

Now check the ra_dav support by issuing
svn –version
it will show the supported modules.

Filed in: ra_dav, svn

by: sur

No Comments

Rails-Tip : Use Capture to wrap a part of View in a variable

The view helper method capture provides this functionality to wrap a section of the view template in a variable and can be used multiple times in the view.

Usage :

<% @message = capture do %>
  You can earn a lot, if you use your brain!
  <%= link_to "Click here", earning_url %> to know more!
<% end %>

Advantage:

If its needed to render a section of template code, we usually go with partials. Capture is specifically useful when partial is only going to be used in just one view template. As there will be this variable available throughout the template, we can use it as many times as needed instead of partial.

Filed in: rails, rails-tip, rubyonrails

by: sur

3 Comments

Defining function inside a function using def

The function(s) defined within a function works fine with any hierarchy only within the main object but gives NoMethodError inside a class.

Lets exemplify it!

Here are the example of both main object and inside a class…

[source:ruby]
def person
def author
p “I am author”
end
def reader
p “I am reader”
end
def publisher
def authorized
p “I am a authorized publisher”
end
end
end

person.author # => I am author
person.reader # => I am reader
person.publisher.authorized # => I am authorized publisher

class Person
def publisher
def authorized
p “I am a authorized publisher”
end
end
end

Person.new.publisher.authorized # => NoMethodError
[/source]

Its an unexpected behavior in the main object. I don’t know whether its a bug or the feature. But as Matz says it will be removed in the future version of ruby, might be in 2.0

Filed in: ruby

by: sur

1 Comment

Simple Captcha : Update

After getting loads of emails, I’ve put the RMagick back in the plugin simple_captcha to provide various image styles and different level of distortions. The main reason for including it back is that people found it was hard for to apply their own styles.
Still the filesystem is not used in the plugin, neither for the secret code nor for the images. The generated image is directly rendered on the web page instead of storing on the server so that there won’t be any trouble for the distributed environment with clustered servers.

Filed in: simple_captcha

by: sur

Comments Off

Seriously Hurt!!

If all that happened to one of the greatest living programmer, its really hurting and I am seriously hurt!! Zed is an exceptionally great techei. The Author of the Mongrel Web Server who deserves to be honored with the salutes of all we guys who are running their business on the top of Rails by deploying the web applications on Mongrel with a pride.

Zed Shaw - The Man ranked #1 on WorkingWithRails. God!! Still hard to believe that the guys have treated him like this… For me(and I think for every human being) its quite natural to have respect for a person/company if I am benefiting out of his work. Moreover, the work is free to use!!
I respect Matz, Nobuyoshi, DHH, Zed, Jamis, Rick and all the great guys who writes/contributes plugins/snippets/libs for ruby/rails/mongrel as I am using Ruby/Rails/Mongrel for my benefits.

ZED, my hearty thanks to you for providing the Mongrel web server.

Filed in: zed

by: sur

2 Comments