Feed on
Posts
Comments

Archive for the ‘Ruby on Rails (RoR)’ Category

Ferret Upgrade

These are the steps I have followed for ferret gem upgrade.
Step 1> Upgrade ferret gem  to new version 0.11.6
>>sudo gem update ferret
Step 2> Run setup.rb in ferret-0.11.6
>>ruby /usr/lib/ruby/gems/ferret-0.11.6/setup.rb
Step 3> Update acts_as_ferret plugin in application
>> script/plugin install svn://projects.jkraemer.net/acts_as_ferret/tags/stable/acts_as_ferret –force
Step 4> Add below lines in ferret_server.yml for testing
development:
host: localhost
port: 9010
Step 5> Delete index folder
Step 6> Do changes [...]

Read Full Post »

When i am running my server I got this error
anand-muranals-macbook:Trunk anandmuranal$ ruby script/server
=> Booting Mongrel (use ’script/server webrick’ to force WEBrick)
=> Rails application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
** Ruby version is up-to-date; cgi_multipart_eof_fix was not loaded
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment…
Exiting
/Users/anandmuranal/Projects/Trunk/vendor/rails/railties/lib/commands/servers/mongrel.rb:15: warning: already [...]

Read Full Post »

RoR Upload image in S3

Install gem aws s3
gem install aws-s3
Before you can do anything, you must establish a connection using Base.establish_connection!. A basic connection would look something like this:
AWS::S3::Base.establish_connection!(:access_key_id => ‘abc’,
:secret_access_key => ‘123′
)
Buckets are containers for objects (the files you store on S3). To create a new bucket you just specify its name.
AWS::S3::Bucket.create(’bucket_name’ ;) Picture upload view
<% [...]

Read Full Post »

suppose you want to convert datetime in client side(browser) time zone and display it.
example take events, Events have date so that event date first you have to store it in database as GMT timezone
then write javascript function for onload event like this
function events()
{
var currentDate = new Date();
var offset = currentDate.getTimezoneOffset().toString();
new Ajax.Updater(’events’, ‘/events/load_events?offset=’ + offset, {asynchronous:true, [...]

Read Full Post »

You can format Date field by using strftime function
example :
Time.now()
=> Wed Dec 12 15:48:59 +0530 2007
Time.now().strftime(”%d/%m/%y %H:%M” ;) => “12/12/07 15:50″
Here’s the (shortened) table for strftime.
%a  weekday name.
%A  weekday name (full).
%b  month name.
%B  month name (full).
%c  date and time (locale)
%d  day of month [01,31].
%H  hour [00,23].
%I  hour [01,12].
%j  day of year [001,366].
%m  month [01,12].
%M  minute [00,59].
%p  AM [...]

Read Full Post »

Time zone Conversion

    The most common time zone conversions are the conversion of system local time to UTC, and the conversion of UTC to local time by “Time.gmtime” method and “Time.localtime” method respectively. These conversions are easy for both Time and DateTime objects.
 
def convert_zone(to_zone)
[...]

Read Full Post »

Step1> Open your database.yml file. Under the three standard databases (development, test and production) add the informations needed to connect to you extra dataabse(consider u are running application in production mode and have student_database and second database has mail_database) . Use the standard yml sintax like:
development:
adapter: mysql
database: Login_app_development
username: root
password:
host: localhost
test:
adapter: mysql
database: Login_app_test
username: root
password:
host: localhost
production:
adapter: mysql
database: [...]

Read Full Post »

Rails 0.12 Added script/benchmarker to easily benchmark one or more statement a number of times from within the Rails environment.
Usage:

benchmarker times ‘Person.expensive_way’ ‘Person.another_expensive_way’ …

Examples:

# runs the one statement 10 times
script/performance/benchmarker 10 ‘Person.expensive_method(10)’

# pits the two statements against each other with 50 runs each
script/performance/benchmarker 50 ‘Person.expensive_method(10)’ ‘Person.cheap_method(10)’

$ ruby [...]

Read Full Post »

Ajax in Rails

Create a form that will submit via an XMLHttpRequest instead of a POST request. The parameters are passed exactly the same way (so the controller can use the params method to access the parameters). Fallback for non JavaScript enabled browsers can be specified by using the :action methods in the :html option.
 
form_remote_tag :html => { [...]

Read Full Post »

Mongrel Cluster

Mongrel_cluster is a GemPlugin that wrappers the mongrel HTTP server and simplifies the deployment of webapps using a cluster of mongrel servers. Mongrel_cluster will conveniently configure and control several mongrel servers, or groups of mongrel servers, which are then load balanced using a reverse proxy solution. Typical load balancing reverse [...]

Read Full Post »

Older Posts »