Controller code - what are the benefits of one over another?

1 view
Skip to first unread message

Brian Dunbar

unread,
Oct 11, 2009, 4:41:47 PM10/11/09
to acl9-d...@googlegroups.com
Beginning coder, here.

On September 9 Catón posted a link to to a tutorial.

http://groups.google.com/group/acl9-discuss/browse_thread/thread/d13dfb38c0b6955e

Which I found very helpful. Thank you, Lucas.


His tutorial has Example A in a controller, wheras Example B is more
like the canonical example from the rdoc.

Based on my sandbox, both work. Is there a benefit to one approach
over another?


Example A

class StaticContentController < ApplicationController
access_control do
allow all, :to => [:index]
allow anonymous, :to => [:index2]
allow logged_in, :to => [:index2, :index3]
allow :admin, :to => [:index4]
User.find(2).has_role! :admin
end

def index
end


Example B

class StaticContentController < ApplicationController
access_control do
action :index do
allow all
end
action :index2 do
allow anonymous, logged_in
end
action :index3 do
allow logged_in
end
action :index4 do
allow :admin
end
User.find(2).has_role! :admin
end

def index
end


--
Brian Dunbar
Geidus

"Display some adaptability"

oleg dashevskii

unread,
Oct 12, 2009, 3:22:49 AM10/12/09
to acl9-d...@googlegroups.com
Hi Brian,

there's no particular advantage in any approach, they get translated
into roughly the same code.
So use what you like.

12.10.2009, в 3:41, Brian Dunbar написал(а):

Brian Dunbar

unread,
Oct 15, 2009, 11:59:42 AM10/15/09
to acl9-d...@googlegroups.com
Thank you very much, Oleg.

~brian

Reply all
Reply to author
Forward
0 new messages