what the best rails way to do the following -


i've rails 3 app displays records db table. want same method check if admin controller used , if add edit delete options table items.

example: logged in none admin server/home/list_info

  • some info name address
  • more info name address

logged in admin sever/admin/list_info

  • some info name address edit delete
  • more info name address edit delete

i've got 2 controllers , 2 view methods, admin method copy edit delete links on end. doesn't seem dry me. people in situation ?

many andy

i think best way have 1 set of controllers/views , see if current user admin. if yes, show edit/delete links.

typically, use devise authentication , cancan authorization.

devise provides current_user object, if implement admin? method use like

<%= link_to_if current_user.admin?, 'delete', ... %> 

note: above uses devise, not cancan.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -