Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class UsersController < ApplicationController
- def index
- @user_table = get_html_table "aim", "name"
- end
- def show
- @user = User.find(params[:id])
- end
- private
- def build_link(action,content,id)
- '<a href="' +
- url_for(:controller => 'users', :action => action, :id => id) +
- %{">#{content}</a>}
- end
- def get_html_table(*columns)
- columns = User.column_names if columns.empty?
- User.formatted_table(:html, :columns => columns) do |e|
- e.rewrite_column("name") { |r|
- build_link(:show,r["name"],r["id"])
- }
- e.rewrite_column("email") { |r|
- r["email"].gsub("@","at").gsub(".","dot")
- }
- end
- end
- end
Add Comment
Please, Sign In to add comment