insert data to the databse..

how can i insert data to the database from any controller

Assuming you want to add a user from an arbitrary controller... You would instantiate the new user in an action ('new_user') and save it to the database (and raise validation errors) from a create action (here called 'create_user')

class ArbitraryController < ActionController::Base

  def index     @users = User.find(:all)   end

  def new_user     @user = User.new   end

  def create_user     @user = User.new(params[:user])     @user.save     redirect_to :action => 'index'   end

end

You would have to define the routes in your routes.rb file like:

map.connect '/user/new', :controller => 'arbitrary', :action => 'new_user'

HTH