Thursday, January 27, 2011

Using hoptoad notifier as gem in rails 2.3

by sandipransing 0 comments
# in config/environment.rb config.gem 'hoptoad_notifier' # from your Rails root: $ rake gems:install $ rake gems:unpack GEM=hoptoad_notifier $ script/generate hoptoad --api-key your_key_here
Read More…

Thursday, January 20, 2011

Installing and running cronjob (crontab basics)

by sandipransing 0 comments
Basic commands to open/Edit crontab file Editing crontab file
crontab -e Displaying crontab file
crontab -l Remove crontab
crontab -r crontab syntax cron command basically takes 6 input parameters of which each input can take multiple arguments for that one can make use of comma or pipe separator
# min hour dom mon dow command * * * * * (command) Here * means for every. Above command will get executed for every minute
Detailed syntax * * * * * command to be executed - - - - - | | | | | | | | | +----- day of week (0 - 6) (Sunday=0) | | | +------- month (1 - 12) | | +--------- day of month (1 - 31) | +---------- hour (0 - 23) +------- min (0 - 59) Example commands
# Generate progressive report for every active user at 11:45 p.m. 45 23 * * * (cd /home/sandip/current/; rake ace:daily_progressive_report RAILS_ENV=production) # Take database backup every night 59 2 * * * (cd /home/sandip/current/; rake db:backup RAILS_ENV=production) # Initialize grouping on database every sunday 29 3 * * 0 (cd /home/sandip/current/; rake ace:initializeCarGrouping RAILS_ENV=production) # Generate daily stats on 4:30 AM & 12:30 PM and 4:30 PM 30 4,12,16 * * * (cd /home/sandip/current/; rake ace:daily_call_statistics RAILS_ENV=production) # Rotate sphinx indexes updated evry hour if missed out somehow 0 * * * * (cd /user/local/bin/; indexer --rotate --config /home/sandip/current/config/production.sphinx.conf)
Read More…

Wednesday, January 19, 2011

Testing restful & polymorphic resource routes on rails console

by sandipransing 0 comments
Testing restful & polymorphic resource routes on rails console
Open rails console
rails c # In rails 3 OR ruby script/console
app object of URL >> app
=> #<ActionController::Integration::Session:0xc164fac @result=nil, @status=nil, @accept="text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5", @path=nil, @request_count=0, @application=#<ActionController::Dispatcher:0xc1644f8 @output=#<IO:0x85e34ec>>, @remote_addr="127.0.0.1", @host="www.example.com", @controller=nil, @https=false, @request=nil, @headers=nil, @cookies={}, @status_message=nil, @named_routes_configured=true, @response=nil>
Root URL
>> app.root_url
=> "http://www.example.com/"
Plural paths
>> app.calls_path
=> "/calls"
Singular routes
>> app.audio_call_path
ActionController::RoutingError: audio_call_url failed 
>> app.audio_call_path(1)
=> "/calls/1/audio"

>> app.audio_call_path(13)
=> "/calls/13/audio"

>> app.audio_call_path(13, :name => 'san')
=> "/calls/13/audio?name=san"
Polymorphic URLS
 app.polymorphic_path(Call.first, :action => 'audio')
=> "/calls/253/audio"

>> app.polymorphic_path(Call.new)
=> "/calls"

Read More…

Saturday, January 15, 2011

About The Author

Sandip is a ruby on rails developer based in pune and also a blogger at funonrails. Opensource contributor and working with Josh software Private Limited. for more info read Follow Sandip on Twitter for updates.

Connect With Me...

Github Projects

@sandipransing Twitter