Skip to content

Instantly share code, notes, and snippets.

@benshimmin
Last active August 29, 2015 14:25
Show Gist options
  • Save benshimmin/d5413ae27fa21fc18d32 to your computer and use it in GitHub Desktop.
Save benshimmin/d5413ae27fa21fc18d32 to your computer and use it in GitHub Desktop.
Code reuse in the Rails Admin DSL
class Foo < ActiveRecord::Base
def self.fields(something = false)
-> (model) {
field :bar
field :baz
field :woof
if something
field :something_else
end
}
end
rails_admin do
create &Foo.fields
edit &Foo.fields(something = true)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment