Guest User

Untitled

a guest
Feb 19th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. class UsersController < ApplicationController
  2.  
  3. def index
  4. @user_table = get_html_table "aim", "name"
  5. end
  6.  
  7. def show
  8. @user = User.find(params[:id])
  9. end
  10.  
  11. private
  12.  
  13. def build_link(action,content,id)
  14. '<a href="' +
  15. url_for(:controller => 'users', :action => action, :id => id) +
  16. %{">#{content}</a>}
  17. end
  18.  
  19. def get_html_table(*columns)
  20. columns = User.column_names if columns.empty?
  21. User.formatted_table(:html, :columns => columns) do |e|
  22. e.rewrite_column("name") { |r|
  23. build_link(:show,r["name"],r["id"])
  24. }
  25. e.rewrite_column("email") { |r|
  26. r["email"].gsub("@","at").gsub(".","dot")
  27. }
  28. end
  29. end
  30.  
  31. end
Add Comment
Please, Sign In to add comment