ruby #check for column ActiveRecord::Base.connection.tables.include?(name) #check for table Model.columns_hash.has_key("column_name")? Category: Code SnippetsBy Chirag PatelFebruary 20, 2009Tags: migrationsrailstable Share this post TweetShare on Twitter Share on FacebookShare on Facebook Share on LinkedInShare on LinkedIn Author: Chirag Patel Post navigationPreviousPrevious post:Permission denied (publickey). fatal: The remote end hung up unexpectedlyNextNext post:pg_restore: [custom archiver] out of memoryRelated postsOCS Version 0.2 Release – Cisco Router Default Password ScannerJanuary 11, 2013Add New Item To Backtrack Linux Backtrack MenuJanuary 8, 2013Backtrack cisco-auditing-tool Additional Enable Password Confirmation AddedJanuary 4, 2013Backup KeepNote Script For Backtrack LinuxDecember 22, 2012
#check for table ActiveRecord::Base.connection.tables.include?(‘name’) #check for column Model.columns_hash.has_key?(‘column_name’) Reply
Hello Jayraymy, I dig how you corrected that! :) Also thanks for adding the above… the note Chirag write is super old so functionality has likely drastically improved and could use updated info like you provided… again thanks! Thanks. Alex Reply
#check for table
ActiveRecord::Base.connection.tables.include?(‘name’)
#check for column
Model.columns_hash.has_key?(‘column_name’)
Simple to check if table exist in rails migration :
self.table_exists?(“table_name”)
“Simpler” not “simple”
Hello Jayraymy,
I dig how you corrected that! :) Also thanks for adding the above… the note Chirag write is super old so functionality has likely drastically improved and could use updated info like you provided… again thanks!
Thanks.
Alex