MCA

How to generate an SSH key in Linux?

You can generate a key in Linux using the ssh-keygen command.
You can run it in command line. You will be asked for a file in which the key should be saved to and for a passphrase (password) for the key:
This command will generate id_rsa public and private keys.

If you need to generate id_dsa keys then you need to run ssh-keygen -t dsa

cannot open shared object file: No such file or directory

I got below error while i tried to run my application in fedora

libMagickCore.so.2: cannot open shared object file: No such file or directory – /usr/lib/ruby/gems/1.8/gems/rmagick-2.8.0/lib/RMagick2.so

To get solved of this error i executed

ldconfig /usr/local/lib

Use of Dirty Objects

Uses of Dirty Objects

Developer have some confusion that how they can get the previous value of the field after update.
So here the rails has a way called Dirty objects.

You can found Module Dirty in rails/activerecord/lib/active_record/dirty.rb
This is just for track unsaved attribute changes.
There are few methods in dirty module as below
* Changed
* Changed?
* Changes
* Included
And it has some constants

Remove .svn files / folders

I have found from some where to use the below syntax for remove .svn folders. And it works for me so i thought it might be useful. So i shared this

find ./ -name ".svn" | xargs rm -Rf

or

find ./ -name “.svn” -exec rm -rf {} \;

Source: http://www.rickhurst.co.uk/category/linux/

blogofchirag

I am working with Ruby on Rails since july 2007. I have finished my MCA with 67%.
I do RoR web application development along with other technologies like LAMP.
The reason to love programming with RoR is, it helps keep code simple, clean and nice…
I had also worked with PHP (LAMP Technology). for 7-8 months.
Email: Chirag_shah84_007@yahoo.co.in

Receive Mail with attachment using TMail - Ruby on Rails

Receive Mails using TMail. I like to use TMail for receive mail because TMail is best to handle the header of the email object. There are only a few methods that deal directly with the body of the email. So i just thought to share it. I have used pop3 for receive mail and use TMail for parse it.
For use TMail you need to do install gem.

gem install TMail

def popmail
     require 'net/pop'

Merb gets merged into Rails 3.0 !!

Ruby on Rails team broke the news: the alternative Ruby web application framework, Merb, will be merged into Ruby on Rails 3.0.

Inline file upload - iframe - ajax - Ruby on Rails

In View

<% form_for(@images, :url => formatted_images_path(:format => 'js'), :html => { :multipart => true,:target => 'upload_frame' }) do |f| %>
Image
<%= f.file_field :uploaded_data, :size => "50" %>
<%= f.submit :Submit %>
<% end %>
< id="'upload_frame'," name="upload_frame" style="width:1px;height:1px;border:0px" src = "about:blank">

in controller
def create
@image = Image.new
if @image.save
respond_to do |format|

Watermarking an image in Rails - Rmagick

class Image < ActiveRecord::Base

require 'RMagick'
has_attachment :content_type => :image,
:storage => :file_system,
:max_size => 4.megabytes,
:resize_to => '640x400>',
:thumbnails => { :thumb => '100x100>',:medium => '250x150' }

validates_as_attachment

def watermark_image
dst = Magick::Image.read("#{RAILS_ROOT}/public/#{self.public_filename}").first

Improving Rails Applications performance

I have done some research about improving Rails Applications performance. I would feel the the following few points need to be considered when we optimize rails applications for performance:

1) Avoid the use of dynamic URL generation (link_to, url_for) since rails needs to look up the routes table and that may take time. Just hard code the controller name and the action.

2) Try to avoid the excess use of helpers since it adds overhead.

Syndicate content