Last active
August 29, 2015 14:25
-
-
Save benshimmin/d5413ae27fa21fc18d32 to your computer and use it in GitHub Desktop.
Code reuse in the Rails Admin DSL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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