snipt

Ctrl+h for KB shortcuts

Bash

mysql2 gem with mariadb

$ sudo apt-get install libmariadbd-dev
$ gem install mysql2
https://snipt.net/embed/7714f80e2d8ee14c7c0fd0df6ff3e5a4/
https://snipt.net/raw/7714f80e2d8ee14c7c0fd0df6ff3e5a4/
7714f80e2d8ee14c7c0fd0df6ff3e5a4
bash
Bash
3
2016-08-27T14:37:31
True
False
False
/api/public/snipt/140788/
mysql2-gem-with-mariadb
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="nv">$ </span>sudo apt-get install libmariadbd-dev </span><span id="L-2"><a name="L-2"></a><span class="nv">$ </span>gem install mysql2 </span></pre></div> </td></tr></table>
gem, mariadb, mysql, ruby

Ruby

rails > get database configuration in console

Rails.configuration.database_configuration[Rails.env]
https://snipt.net/embed/90c39f5db690e5e18279fba23522d68b/
https://snipt.net/raw/90c39f5db690e5e18279fba23522d68b/
90c39f5db690e5e18279fba23522d68b
rb
Ruby
1
2016-08-27T16:09:56
True
False
False
/api/public/snipt/138105/
rails-get-database-configuration-in-console-8e5451d2
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="no">Rails</span><span class="o">.</span><span class="n">configuration</span><span class="o">.</span><span class="n">database_configuration</span><span class="o">[</span><span class="no">Rails</span><span class="o">.</span><span class="n">env</span><span class="o">]</span> </span></pre></div> </td></tr></table>
console, database, rails, ruby

Ruby

Rails migration in console

ActiveRecord::Migration.drop_table(:users)
https://snipt.net/embed/7c622ac35646103e349ee5de11a5224c/
https://snipt.net/raw/7c622ac35646103e349ee5de11a5224c/
7c622ac35646103e349ee5de11a5224c
rb
Ruby
1
2016-08-27T16:10:25
True
False
False
/api/public/snipt/135183/
rails-migration-in-console-94b98189
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="no">ActiveRecord</span><span class="o">::</span><span class="no">Migration</span><span class="o">.</span><span class="n">drop_table</span><span class="p">(</span><span class="ss">:users</span><span class="p">)</span> </span></pre></div> </td></tr></table>
database, migration, rails, ruby

Ruby

activerecord > current database and tables

> ActiveRecord::Base.connection.current_database
> ActiveRecord::Base.connection.tables
https://snipt.net/embed/262b148fa0ff82559a980bb10c659a4e/
https://snipt.net/raw/262b148fa0ff82559a980bb10c659a4e/
262b148fa0ff82559a980bb10c659a4e
rb
Ruby
2
2016-08-27T16:10:39
True
False
False
/api/public/snipt/117401/
activerecord-current-database
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="o">&gt;</span> <span class="no">ActiveRecord</span><span class="o">::</span><span class="no">Base</span><span class="o">.</span><span class="n">connection</span><span class="o">.</span><span class="n">current_database</span> </span><span id="L-2"><a name="L-2"></a><span class="o">&gt;</span> <span class="no">ActiveRecord</span><span class="o">::</span><span class="no">Base</span><span class="o">.</span><span class="n">connection</span><span class="o">.</span><span class="n">tables</span> </span></pre></div> </td></tr></table>
console, database, rails, ruby
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.