{"id":289,"date":"2015-05-11T23:58:24","date_gmt":"2015-05-11T23:58:24","guid":{"rendered":"https:\/\/www.tech.shinynewthings.com\/?p=289"},"modified":"2015-05-12T00:56:04","modified_gmt":"2015-05-12T00:56:04","slug":"rails-cheats","status":"publish","type":"post","link":"https:\/\/www.tech.shinynewthings.com\/?p=289","title":{"rendered":"Rails Cheats"},"content":{"rendered":"<p>Set current version of ruby<\/p>\n<pre>rvm --default use 2.1.1\n<\/pre>\n<p>Use migrate from named origin \/ dest in database.yml<\/p>\n<p>-C Begin the output with a command to create the database itself and reconnect to the created database.<\/p>\n<p>If &#8211;clean is also specified, the script drops and recreates the target database before reconnecting to it.<\/p>\n<p>-h hostname<\/p>\n<p>-U username<\/p>\n<pre>def getEnvironmentConfig(env = Rails.env)\n        return Rails.configuration.database_configuration[env]\n    end\n\n    # Use migrate from named origin \/ dest in database.yml\n    def migrateDbEnv(originStr, destStr)\n        origin = getEnvironmentConfig(originStr)\n        dest = getEnvironmentConfig(destStr)\n        system \"pg_dump -C -h #{origin[\"host\"]} -U #{origin[\"username\"]} #{origin[\"database\"]} | psql #{dest[\"host\"]} -U #{dest[\"username\"]} #{dest[\"database\"]}\"\n    end\n<\/pre>\n<p>http:\/\/blog.bigbinary.com\/2012\/10\/18\/backtick-system-exec-in-ruby.html<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Set current version of ruby rvm &#8211;default use 2.1.1 Use migrate from named origin \/ dest in database.yml -C Begin the output with a command to create the database itself and reconnect to the created database. If &#8211;clean is also specified, the script drops and recreates the target database before reconnecting to it. -h hostname [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-289","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts\/289","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=289"}],"version-history":[{"count":4,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts\/289\/revisions"}],"predecessor-version":[{"id":293,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=\/wp\/v2\/posts\/289\/revisions\/293"}],"wp:attachment":[{"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=289"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=289"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tech.shinynewthings.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=289"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}