<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1275770409164494811</id><updated>2024-09-12T23:29:01.267-07:00</updated><title type='text'>Helping the World Change..</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://whizkas.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1275770409164494811/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://whizkas.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Luis Velasco</name><uri>http://www.blogger.com/profile/11801583218039473795</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3Mnl9f5NPRoSA-Q55iGDtU_vLCgxaXW84bQf_QO4OHDbhlWHwx6pKAFPQUust2Gvk7Xyj9M6x3-6BAWE1MzJ5JMUUfBwmIJKdUMXTYAHtBx4TdMfRkfTKbnbvsadggBE/s1600-r/44db71cea383d8a2203162ed1ecbec35.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1275770409164494811.post-8591808104022931852</id><published>2010-09-14T23:28:00.000-07:00</published><updated>2010-09-20T07:48:57.725-07:00</updated><title type='text'>Getting PostgreSQL into Rails3!</title><content type='html'>Now, since Rails3 is released, many projects come to be on their phase of migration, but this time I&#39;ll show you how I got my Rails environment to work with PostgreSQL.&lt;br /&gt;
&lt;br /&gt;
It&#39;s very important to carefully&amp;nbsp;decide&amp;nbsp;which database will be used for your application and what you really care about: Performance, Security, Availability; so in this case we&#39;ll just state that we need Security and Availability regardless of Performance, which better approaches us to PostgreSQL. It&#39;s important to say that I did this in Ubuntu 10.04 - &lt;i&gt;Lucid Lynx&lt;/i&gt; distro.&lt;br /&gt;
&lt;br /&gt;
OK so, let&#39;s begin with our brief trip:&lt;br /&gt;
&lt;br /&gt;
I&#39;d personally recommend using RVM (Ruby Version Manager) to manage Ruby versions since it&#39;s pretty easy to switch, install or remove any version you&#39;d like to test, so let&#39;s run:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;i&gt;$ rvm install 1.8.7&lt;/i&gt;&lt;/blockquote&gt;&lt;br /&gt;
and switch to that ruby version by running:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;i&gt;$ rvm 1.8.7&amp;nbsp;&lt;/i&gt;&lt;/blockquote&gt;&lt;br /&gt;
&amp;nbsp;When we&#39;re ready to use ruby, lets install Rails, if you want, you could install it in any gemset defined in rvm by executing &#39;rvm gemset create &lt;b&gt;&amp;lt;gemset_name&amp;gt;&lt;/b&gt;&#39; and &#39;rvm gemset use &lt;b&gt;&amp;lt;gemset_name&amp;gt;&lt;/b&gt;&#39;, so after this we do:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;i&gt;$ gem install rails --version 3.0.0&lt;/i&gt;&lt;/blockquote&gt;&lt;br /&gt;
Once we have it on the rails, let&#39;s proceed to the main business... Installing PostgreSQL:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;i&gt;$ sudo apt-get install postgresql postgresql-client postgresql-contrib libpq-dev libpgsql-ruby&amp;nbsp;libgda-4.0-postgres&amp;nbsp;libpq-dev&lt;/i&gt;&lt;/blockquote&gt;&lt;br /&gt;
&amp;nbsp;Aditionally you can install &lt;b&gt;&#39;pgadmin&#39;&lt;/b&gt; visual management tool to make queries, add users or manage any other information from your databases with:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;i&gt;$ sudo apt-get install pgadmin3 postgresql-doc&lt;/i&gt;&lt;/blockquote&gt;&lt;br /&gt;
OK, so at this point we have PostgreSQL installed in our system, so... what&#39;s next?? Go to sleep? Don&#39;t despair! we&#39;re near...&lt;br /&gt;
&amp;nbsp;As you can see, we have Rails3 and PostgreSQL installed separately; all we need is an adapter to communicate each other, how do we do it? Easily, just&amp;nbsp;add pg gem to your Gemfile:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;i&gt;gem &#39;pg&#39;&lt;/i&gt;&lt;/blockquote&gt;&lt;br /&gt;
And run the bundler:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;i&gt;$ bundle install&lt;/i&gt;&amp;nbsp;&lt;/blockquote&gt;&lt;br /&gt;
And in your &lt;b&gt;&#39;config/database.yml&#39;&lt;/b&gt; file use &lt;b&gt;&#39;postgresql&#39;&lt;/b&gt; as your adapter for each environment.&lt;br /&gt;
&lt;br /&gt;
You could use &#39;postgres&#39; username but I recommend using a different one. To create it you&#39;ll first have to connect to PostgreSQL server by doing:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;i&gt;$ sudo -u postgres psql template1&lt;/i&gt;&lt;/blockquote&gt;&lt;br /&gt;
This will let you into PostgreSQL command line where you can tell the DBMS what you want to do, lets tell it we didn&#39;t like that name and create our own:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;i&gt;CREATE USER &lt;b&gt;&amp;lt;user_name&amp;gt;&lt;/b&gt; WITH CREATEDB CREATEUSER ENCRYPTED PASSWORD &#39;&lt;b&gt;&amp;lt;password&amp;gt;&lt;/b&gt;&#39;;&lt;/i&gt;&lt;/blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;I put some words in capital so you can identify the reserved words that PostgreSQL uses and in &amp;lt;&amp;gt; tags you can put your own information.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;So this will create a user with database and user creation permissions with a defined password.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;But if you opted to keep using &#39;postgres&#39; user, you can always change the password with:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;i&gt;ALTER USER postgres WITH ENCRYPTED PASSWORD &#39;&lt;b&gt;&amp;lt;new_password&amp;gt;&lt;/b&gt;&#39;;&lt;/i&gt;&lt;/blockquote&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Note: Don&#39;t forget to put&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&#39;;&#39; (semicollon) at the end of&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;each instruction in PostgreSQL console&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;And finally, we have to put that information into our &lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&#39;config/database.yml&#39;&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;development:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&amp;nbsp;adapter: postgresql&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&amp;nbsp;database: &lt;b&gt;&amp;lt;development_database_name&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&amp;nbsp;username: &lt;b&gt;&amp;lt;user_name&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&amp;nbsp;password: &lt;b&gt;&amp;lt;password&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&amp;nbsp;host: 127.0.0.1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;test:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&amp;nbsp;adapter: postgresql&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&amp;nbsp;database:&amp;nbsp;&lt;b&gt;&amp;lt;test_database_name&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&amp;nbsp;username: &lt;b&gt;&amp;lt;user_name&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&amp;nbsp;password: &lt;b&gt;&amp;lt;password&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&amp;nbsp;host: 127.0.0.1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;production:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&amp;nbsp;adapter: postgresql&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&amp;nbsp;database:&amp;nbsp;&lt;b&gt;&amp;lt;production_database_name&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&amp;nbsp;username: &lt;b&gt;&amp;lt;user_name&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&amp;nbsp;password: &lt;b&gt;&amp;lt;password&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&amp;nbsp;host: 127.0.0.1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;And that&#39;s it! We can test our connection by creating a model and putting some data in it, but don&#39;t forget to follow BDD with Cucumber and RSpec cycle! That&#39;s very important!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;This is my first post so I&#39;ll appreciate any feedback, if there is any problem with the steps or additional help I may give you... Thank you in advance!&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://whizkas.blogspot.com/feeds/8591808104022931852/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://whizkas.blogspot.com/2010/09/getting-postgresql-into-rails3.html#comment-form' title='2 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1275770409164494811/posts/default/8591808104022931852'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1275770409164494811/posts/default/8591808104022931852'/><link rel='alternate' type='text/html' href='http://whizkas.blogspot.com/2010/09/getting-postgresql-into-rails3.html' title='Getting PostgreSQL into Rails3!'/><author><name>Luis Velasco</name><uri>http://www.blogger.com/profile/11801583218039473795</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3Mnl9f5NPRoSA-Q55iGDtU_vLCgxaXW84bQf_QO4OHDbhlWHwx6pKAFPQUust2Gvk7Xyj9M6x3-6BAWE1MzJ5JMUUfBwmIJKdUMXTYAHtBx4TdMfRkfTKbnbvsadggBE/s1600-r/44db71cea383d8a2203162ed1ecbec35.png'/></author><thr:total>2</thr:total></entry></feed>