With jquery grid plugin along with 2dcJqgrid Rails plugin are awesome for creating datagrids in rails applications which allows users to navigate, search, add/ edit / delete operation in one place.
See the sample screenshot above.
Wednesday, November 25, 2009
Posted by venkat at 9:37 PM
Application must be under version control. Use SVN
Never put log files or database.yml file into subversion.
Use either Postrgres, Oracle or Mysql for your db.
Session data should be stored in the database
Migrations should NOT contain any db specific SQL.
Use Rspec for testing. Rspec is available as plugin
Application must have Unit and Functional tests.
All application gems should be installed in RAILS_ROOT/vendor/gems folder
Always freeze rails, ( Fix For rails freeze gems )
If your application uses CAS authentication, use the ucb_rails_security plugin
Controller Methods should be no longer than 5-8 lines of code. If you find your self with really large controller methods you are probably violating the following standard.
Application domain logic should go into the model, NOT in the controller or view.
Try to limit each controller's actions to: index, new, create, edit, update, destroy. This is not always possible. However, if you notice that a given controller has more than 10 methods, it probably time to refactor.
1. Double-click on the "Computer" icon on your desktop.
2. Go to the "Edit" menu and choose "Preferences."
3. Click on the "Behavior" tab.
4. Put a check in the box marked "Always open in browser windows
A correct way to send tons of massive emails from your website is queuing the emails and send them one by one. If you send all at once directly from your site some hosting servers may allows only some amount of emails per hour. Shared hosting servers allow you send only 25 emails from your site per hour. Fortunately there is one plugin available for Rails which can store the outgoing emails in database as a queue and send them eventually. That plugin is called ar_mailer you can install it and send tons of emails happlily. See the process of how to install and more at http://www.ameravant.com/posts/sending-tons-of-emails-in-ruby-on-rails-with-ar_mailer
Posted by venkat at 8:08 PM
Easy roles is a plugin for Ruby on Rails which is very usefull for your site if it has lot of roles. So by using this plugin you can restrict the access to controllers based on the roles. Follow the below process to install it for your application.
ruby script/plugin install git://github.com/platform45/easy_roles.git
Now the plugin is installed in your vendor/plugins folder
Below is the Basic Setup process you need to do after plugin installed successfully
Add the following to your enviroment.rb in the rails initializer block
config.gem 'easy_roles', :source => 'http://gemcutter.org'
Add a "roles" column to your users model, and set the default value to "--- ". Please note you can call this column anything you like, I like to use the name "roles" for meaning full.
For users table migration table add below
t.string :roles, :default => "--- "
Then you need to add "easy_roles :column_name" and some logic to your model.
class User < ActiveRecord::Base
# Serialize roles as an array
serialize :roles, Array
# Create an empty roles array on create
# Convenience method, is user an admin?
# Checks to see if a user has requested role
# Add a role to a user
self.roles << role
# Remove a role from a user
# Clear all users roles
self.roles = 
clear_roles if roles.nil?
And thats it.
The above model gives you the options like below in controllers
@user = User.first
Easy roles extends your model, and adds a few methods needed for basic role authorization.
adding a role to a user
removing a role from a user
check to see if a user has a certain role
is_role? # role being anything you like, for example 'is_admin?' or 'is_awesome?'
@user = User.first
== Protecting controllers
There are many ways to implement views for specific roles, so I did not specifically supply one. Here's an example on what you could do:
class ApplicationController < ActionController::Base
unless current_user && current_user.is_admin?
flash[:error] = "Sorry, you don't have access to that."
redirect_to root_url and return false
Then in your AdminsController or any controller that you only want admins to view:
class AdminsController < ApplicationController
class MarksController < ApplicationController
before_filter :admin_required, :only => :create, :update
check out more information at
http://blog.platform45.com/2009/10/05/howto-basic-roles-for-users for implementation
If you already installed eclipse in your system then you have to update it for php support. To do so follow the below steps
1. Open the eclipse IDE
2. Then goto menu Help -> Software updates
There you see Two main tabs Installed softwares and Available softwares. If phpeclipse is not there in installed softwares list then check in Available softwares list. If not avaliable there also Then click on Add site and enter below url.
Then that eclipse's update url is added to available softwares list. Check that module and click install. It will take few minutes and install phpeclipse and PDT (PHP Development Tools) to your existing eclipse IDE.
After installed successfully Goto menu Window -> open perspective
and select PHP to start working on PHP Projects.
The process is same to enable any other technologies support in eclipse for developing applications.
If you are not installed eclipse IDE in your system then you can directly install it from the official website http://www.eclipse.org/