Posted by firstruby on May 9, 2010
We can restrict the routes listing to particular CONTROLLER by passing CONTROLLER variable as,
rake routes CONTROLLER=profiles
Above command will display routes of profiles controller.
Posted in Useful Links | Tagged: rails, rake, RoR, routes | Leave a Comment »
Posted by firstruby on November 29, 2009
For users list, I wanted to have AJAX pagination.
For Ruby on Rails version 2.3.x,
1) Install will_paginate gem “config.gem “will_paginate”" or include will_paginate plugin in vendor/plugins.
2) Create helper file at /app/helpers/remote_link_renderer.rb with following content,
Here I’m attaching remote_link_renderer.rb.pdf file , copy contents from remote_link_renderer.rb.pdf and create file remote_link_renderer.rb
3) In controller action, write as following,
render :update do |page|
page.replace_html "users_list", :partial => "users", : object => @users
4) On “_users_list.html.erb” view page, write as,
= will_paginate @users, :renderer => 'RemoteLinkRenderer'
Posted in Useful Links | Tagged: ajax, pagination, rails, RoR, ruby on rails | Leave a Comment »
Posted by firstruby on June 26, 2009
To configure the Oracle with Ruby on Rails (RoR) applications, we need to do following setting,
Download Oracle 10g from http://download.oracle.com/otn/nt/oracle10g/xe/10201/OracleXEUniv.exe (to download Oracle setup, you need to create an account)
Install following gems,
gem install activerecord-oracle_enhanced-adapter
gem install ruby-oci8
Then modify the /config/database.yml as following for the current environment,
Posted in firstruby, Useful Links | Tagged: database, Oracle, RoR | Leave a Comment »
Posted by firstruby on November 2, 2008
Create new branch “demo” as,
git branch demo
This will create local branch “demo”
git checkout demo
This will switched to that branch
3) make some changes in that code, then,
git add <files>
git commit -m "<your message>"
git push origin demo
This will create new remote branch “demo” on github.
5) If you want someone to checkout the code from “demo” branch, then do following,
git clone <git-path>
git checkout --track -b demo origin/demo
Now, you are in “demo” branch.
Posted in Blogroll, firstruby, Useful Links | Tagged: git, rails, RoR | 1 Comment »
Posted by firstruby on May 29, 2008
RESTful interface means clean URLs, less code, CRUD interface.
CRUD means Create-READ-UPDATE-DESTROY.
You might heard about HTTP verbs, GET, POST. In REST, they add 2 new verbs, i.e, PUT, DELETE.
There are 7 default actions, those are – index, show, new, create, edit, update, destroy
GET is used when you retrieve data from database. POST is used when you create new record in database. PUT is used when you are updating any existing record in database, and DELETE is used when you are destroying any record in database. Following table may clear the concept.
Posted in firstruby, Forum, Useful Links | Tagged: REST, RESTful, RoR | 1 Comment »
Posted by firstruby on May 29, 2008
To display datetimes in different formats in Ruby On Rails application,
following may help,
%a – The abbreviated weekday name (“Sun”)
%A – The full weekday name (“Sunday”)
%b – The abbreviated month name (“Jan”)
%B – The full month name (“January”)
%c – The preferred local date and time representation
%d – Day of the month (01..31)
%H – Hour of the day, 24-hour clock (00..23)
%I – Hour of the day, 12-hour clock (01..12)
%j – Day of the year (001..366)
%m – Month of the year (01..12)
%M – Minute of the hour (00..59)
%p – Meridian indicator (“AM” or “PM”)
%S – Second of the minute (00..60)
%U – Week number of the current year, starting with the first Sunday as the first day of the first week (00..53)
%W – Week number of the current year, starting with the first Monday as the first day of the first week (00..53)
%w – Day of the week (Sunday is 0, 0..6)
%x – Preferred representation for the date alone, no time
%X – Preferred representation for the time alone, no date
%y – Year without a century (00..99)
%Y – Year with century
%Z – Time zone name
%% – Literal “%” character
t = Time.now
t.strftime(“Printed on %m/%d/%Y”) #=> “Printed on 04/09/2003″
t.strftime(“at %I:%M%p”) #=> “at 08:56AM”
Posted in firstruby, Forum, Useful Links | Tagged: Date, DateTime, RoR, Time | 2 Comments »
Posted by firstruby on December 10, 2007
To publish iCal through Rails, install iCalendar gem
gem install icalendar
then in Controller, code to export event ( export to *.ics file ) should look like,
class EventController < ApplicationController
@event = Event.find(params[:id])
@calendar = Icalendar::Calendar.new
event = Icalendar::Event.new
event.start = @event.dt_time.strftime("%Y%m%dT%H%M%S")
event.end = @event.dt_time.strftime("%Y%m%dT%H%M%S")
event.summary = @event.summary
event.description = @event.description
event.location = @event.location
headers['Content-Type'] = "text/calendar; charset=UTF-8"
render_without_layout :text => @calendar.to_ical
Posted in Useful Links | Tagged: iCal, RoR | 3 Comments »