lib/active_admin/generators/boilerplate.rb in activeadmin-2.2.0 vs lib/active_admin/generators/boilerplate.rb in activeadmin-2.3.0
- old
+ new
@@ -7,35 +7,43 @@
def attributes
@class_name.constantize.new.attributes.keys
end
+ def assignable_attributes
+ attributes - %w(id created_at updated_at)
+ end
+
+ def permit_params
+ assignable_attributes.map { |a| a.to_sym.inspect }.join(', ')
+ end
+
def rows
- attributes.map { |a| row(a) }.join("\n")
+ attributes.map { |a| row(a) }.join("\n ")
end
def row(name)
"# row :#{name.gsub(/_id$/, '')}"
end
def columns
- attributes.map { |a| column(a) }.join("\n")
+ attributes.map { |a| column(a) }.join("\n ")
end
def column(name)
"# column :#{name.gsub(/_id$/, '')}"
end
def filters
- attributes.map { |a| filter(a) }.join("\n")
+ attributes.map { |a| filter(a) }.join("\n ")
end
def filter(name)
"# filter :#{name.gsub(/_id$/, '')}"
end
def form_inputs
- attributes.reject { |a| %w(id created_at updated_at).include? a }.map { |a| form_input(a) }.join("\n")
+ assignable_attributes.map { |a| form_input(a) }.join("\n ")
end
def form_input(name)
"# f.input :#{name.gsub(/_id$/, '')}"
end