lib/venomi/rails_admin.rb in venomi-0.0.2 vs lib/venomi/rails_admin.rb in venomi-0.0.3

- old
+ new

@@ -17,11 +17,12 @@ end class << self include Venomi::Generators::Utils::InstanceMethods - def configure + def configure(table = "Translation") + init_parts_for(table) if file?(@rails_admin_root) unless file_include?(@rails_admin_root, "config.model Translation do") replace(@rails_admin_root, "RailsAdmin.config do |config|", ("RailsAdmin.config do |config|\n" + @translation)) end @@ -33,45 +34,49 @@ replace(@rails_admin_root, " delete", @delete) end end end - def rollback + def rollback(table = "Translation") + init_parts_for(table) if file? @rails_admin_root text = File.read(@rails_admin_root) text.gsub!(@delete, " delete\n") text.gsub!(@new, " new\n") text.gsub!(@translation, "") File.open(@rails_admin_root, "w") {|file| file.puts text } end end - end - @new = <<-MSG + def init_parts_for(table_name) + @table = table_name + @new = <<-MSG new do - except [:Translation] + except [:#{@table}] end MSG - @delete = <<-MSG + @delete = <<-MSG delete do - except [:Translation] + except [:#{@table}] end MSG - @translation = <<-MSG - config.model Translation do - list do - field :key - field :value - end - edit do - field :key do - read_only true + @translation = <<-MSG + config.model #{@table} do + list do + field :key + field :value end - field :value + edit do + field :key do + read_only true + end + field :value + end end - end - MSG + MSG + end + end end end