Feeds:
Posts
Comments

Archive for the ‘Ruby on Rails’ Category

Add the following lines of codes in public/.htaccess. Rails won’t handle this folders. RewriteCond %{REQUEST_URI} ^/(folder-name/|images/|stylesheets/|javascripts/).* RewriteRule .* – [L]

Read Full Post »

Add the following lines in your environment.rb and replace the values with your settings. (mail server name, server name, email address, password) config.action_mailer.server_settings= { :address => ‘mail.servername.com’, :port => 25, :domain => ‘servername’, :user_name => ‘email-address-to-authenticate’, :password => ‘password-to-authenticate’, :authentication => :login (or) :authentication => :plain (if you are not providing password to authenticate) }

Read Full Post »

The following is the way to write cron task in the media temple grid-server. /usr/bin/curl [url] [url] – This URL should point to some controller which does the task for you. (eg.) – /usr/bin/curl http://neilsys.com/cron/invoke_function The time to invoke the cron and other settings can be done using the control-manager in the media temple.

Read Full Post »

Undefined method `strftime

Use DateTime.parse() to solve this error. Strftime deals with date objects. You may be trying this with String Value.

Read Full Post »

The following code converts the “time” to new “timezone value”. Paste the following code in the application.rb or wherever you like def convert_zone(to_zone) #notify the current timezone original_zone = ENV[”TZ”] #finds UTC time utc_time = dup.gmtime #change the zone into the requested zone(parameter value) ENV[”TZ”] = to_zone #convert the UTC time to local time in [...]

Read Full Post »

I came across this error when dealing with Date attribute. Rails active record throws this error when you try to assign the “datetime” value to a date attribute. Changing the db field accordingly fixes this error.

Read Full Post »

Connecting to multiple databases in web application is not needed mostly. But for larger application , we have to choose this model. This can be done very easily in ROR. This is acheived through the “before_filter” filter. We specify the database configuration in “database.yml”. Normally this has three parts(development,production and test). Here mention the other [...]

Read Full Post »

You might have noticed that there is no inbuilt-validation for date in Ruby on Rails. I came across this plugin which does date validation. validates_date :dob, :message=> “DOB is an invalid format” Here is the plugin source: http://svn.viney.net.nz/things/rails/plugins/validates_date_time/

Read Full Post »

If we try to access the controller which doesn’t exist. We end up with an error. This can be solved using the following way. If a controller doesn’t exist in the rails application, the request is redirected to some other page. Add this code in ‘public/routes.rb’ map.connect ‘*path’, :controller => ‘account’, :action => ‘redirect_to_default’ Add [...]

Read Full Post »

xml processing

The REXML which is a ruby ‘xml processor’ is useful to parse the XML documents. I have used this processor in my applications. The usage is as follows. you need to include it within your Ruby controller: require “rexml/document” include REXML This includes the REXML library and includes the REXML namespace. Save the following xml [...]

Read Full Post »

« Newer Posts - Older Posts »