<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Slash Dot Dash: Getting started with Merb and Datamapper</title>
    <link>http://www.slashdotdash.net/articles/2008/07/05/getting-started-with-merb-and-datamapper</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Rolling on Rails</description>
    <item>
      <title>Getting started with Merb and Datamapper</title>
      <description>&lt;p&gt;Merb is the up-and-coming Ruby web framework, designed to improve upon the ideas in Rails whilst being faster, lighter and less opinionated (or more agnostic). I wanted to discover whether it provides any benefits over Rails and what it does differently. The best way to find out; get it installed it and create a new app.&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: There&amp;#8217;s now a &lt;a href="http://www.slashdotdash.net/articles/2008/09/20/easy-merb-installation-using-thor"&gt;much easier way of getting Merb &amp;#38; DataMapper installed&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;The &lt;a href="http://www.merbivore.com/"&gt;official Merb website&lt;/a&gt; gives the following simple installation instructions.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;sudo gem install merb&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;However, since I wanted to also try DataMapper as the &lt;span class="caps"&gt;ORM&lt;/span&gt; those instructions failed to install a working setup due to a &lt;a href="http://wm.lighthouseapp.com/projects/4819/tickets/440-merb_datamapper-is-out-of-date-version-mismatch-with-dm-more"&gt;conflict between Merb and DataMapper dependencies&lt;/a&gt;. Unperturbed, I finally got them both installed and working happily together by getting the bleeding edge code from each project&amp;#8217;s github repository and following the instructions provided by Mathew Ford&amp;#8217;s &lt;a href="http://4ninjas.org/merb/"&gt;Living life on the edge&lt;/a&gt;. The book is also available on &lt;a href="http://github.com/deimos1986/book_mdar/tree/master"&gt;github&lt;/a&gt;, you can contribute patches there. Hopefully this issue will be resolved soon enough so that you&amp;#8217;ll be able to install the official release gems for both Merb and DataMapper from Rubyforge (instead of running on edge).&lt;/p&gt;


	&lt;h3&gt;Prerequisites&lt;/h3&gt;


	&lt;ul&gt;
	&lt;li&gt;You must have git installed (&lt;code&gt;sudo port install git-core&lt;/code&gt; using MacPorts on &lt;span class="caps"&gt;OS X&lt;/span&gt;).&lt;/li&gt;
		&lt;li&gt;Remove any older versions of merb (and datamapper) that you might have installed. Use &lt;code&gt;gem list&lt;/code&gt; to view local gems and &lt;code&gt;sudo gem uninstall &amp;lt;name&amp;gt;&lt;/code&gt; to remove each individual gem.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;h2&gt;The Easy Way&lt;/h2&gt;


	&lt;p&gt;Matt&amp;#8217;s book outlines an &lt;em&gt;easy way&lt;/em&gt; of installing the latest merb &amp;#38; datamapper source, however it failed to properly install the DataMapper gem for me so I had to resort to the &lt;em&gt;hardcore&lt;/em&gt; approach.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;sudo gem install sake
sake -i 'http://edgy.4ninjas.org/edgy.sake'
sake edgy:install packages="merb-stack"&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;After installing, to keep up-to-date you just need to execute:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;sake edgy:update&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Now, if you&amp;#8217;re hardcore&amp;#8230;&lt;/p&gt;


	&lt;h3&gt;Installing the required dependencies&lt;/h3&gt;


	&lt;p&gt;Start by installing the gem dependancies.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;sudo gem install rack mongrel json erubis mime-types rspec hpricot mocha rubigen haml markaby mailfactory ruby2ruby&lt;/code&gt;&lt;/pre&gt;

	&lt;h2&gt;Installing Merb&lt;/h2&gt;


	&lt;p&gt;Download the merb source:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;git clone git://github.com/wycats/merb-core.git
git clone git://github.com/wycats/merb-plugins.git
git clone git://github.com/wycats/merb-more.git&lt;/pre&gt;&lt;/code&gt;

	&lt;p&gt;Then install the gems via rake:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;cd merb-core ; rake install ; cd ..
cd merb-more ; rake install ; cd ..
cd merb-plugins; rake install ; cd ..&lt;/pre&gt;&lt;/code&gt;

	&lt;h2&gt;Installing DataMapper&lt;/h2&gt;


&lt;pre&gt;&lt;code&gt;git clone git://github.com/sam/extlib.git  
git clone git://github.com/sam/do.git

cd extlib ; rake install ; cd ..
cd do
cd data_objects ; rake install ; cd ..
cd do_mysql ; rake install ; cd ..
cd ..

git clone git://github.com/sam/dm-core.git
git clone git://github.com/sam/dm-more.git

cd dm-core ; rake install ; cd ..
cd dm-more ; rake install ; cd ..&lt;/pre&gt;&lt;/code&gt;

	&lt;h3&gt;Keeping updated&lt;/h3&gt;


	&lt;p&gt;To update your local gems with the latest code changes you&amp;#8217;ll need to do a &lt;code&gt;git pull&lt;/code&gt; and then &lt;code&gt;rake install&lt;/code&gt; for each of the git repositories previously downloaded.&lt;/p&gt;


	&lt;h2&gt;Creating your first Merb app&lt;/h2&gt;


	&lt;p&gt;You create a new empty Merb app via the &lt;code&gt;merb-gen&lt;/code&gt; utility.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;merb-gen app demo&lt;/pre&gt;&lt;/code&gt;

(You can also create flattened or single file applications if you wish).
&lt;pre&gt;&lt;code&gt;merb-gen app app_name --flat      (for a flattened application)
merb-gen app app_name --very-flat (for a single file application)&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;As we&amp;#8217;re using DataMapper we need to edit &lt;code&gt;config/init.rb&lt;/code&gt; and uncomment the &lt;code&gt;use_orm :datamapper&lt;/code&gt; line. The next step is to create the database settings file &lt;code&gt;config/database.yml&lt;/code&gt;:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;---
development: &amp;#38;defaults
  adapter:    mysql
  database:   demo_development
  username:   demo
  password:        p@ssword
  host:       localhost

test:
  &amp;lt;&amp;lt;:         *defaults
  database:   demo_test

production:
  &amp;lt;&amp;lt;:         *defaults
  database:   demo_production&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;You can now fire up the Merb server to make sure it runs.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;$ merb
 ~ Loaded DEVELOPMENT Environment...
 ~ Connecting to database...
 ~ loading gem 'merb_datamapper' ...
 ~ Compiling routes...
 ~ Using 'share-nothing' cookie sessions (4kb limit per client)
 ~ Using Mongrel adapter&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Some other useful commands to know:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;merb -i                                                        # Interactive merb console

merb-gen model &amp;lt;name&amp;gt;                            # Creates a Datamapper Model stub
merb-gen resource &amp;lt;name&amp;gt;                    # Creates a full resource (incuding model, controller, views &amp;#38; test spec)

rake dm:db:automigrate            # Perform automigration
rake dm:db:autoupgrade            # Perform non destructive automigration&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Let&amp;#8217;s see how it goes from here with Merb!&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: There&amp;#8217;s now a &lt;a href="http://www.slashdotdash.net/articles/2008/09/20/easy-merb-installation-using-thor"&gt;much easier way of getting Merb &amp;#38; DataMapper installed&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Sat, 05 Jul 2008 23:46:00 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:2d4c7560-2c0c-4594-90fc-a0db36b5edb9</guid>
      <author>ben@slashdotdash.net (Ben)</author>
      <link>http://www.slashdotdash.net/articles/2008/07/05/getting-started-with-merb-and-datamapper</link>
      <category>Merb</category>
    </item>
    <item>
      <title>"Getting started with Merb and Datamapper" by Jason Green</title>
      <description>&lt;p&gt;Sorry somehow the text didn&amp;#8217;t get added there, I wrote a quick article on gems and sake tasks Have a look here: &lt;a href="http://www.nogeek.org/2008/07/25/using-sake-to-keep-merb-and-datamapper-on-edge/" rel="nofollow"&gt;http://www.nogeek.org/2008/07/25/using-sake-to-keep-merb-and-datamapper-on-edge/&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Sat, 26 Jul 2008 14:46:38 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:13ff8e9e-beed-4f3b-b901-59e5aeaf9df6</guid>
      <link>http://www.slashdotdash.net/articles/2008/07/05/getting-started-with-merb-and-datamapper#comment-473</link>
    </item>
    <item>
      <title>"Getting started with Merb and Datamapper" by Jason Green</title>
      <description>&lt;p&gt;&lt;a href="http://www.nogeek.org/2008/07/25/using-sake-to-keep-merb-and-datamapper-on-edge/" rel="nofollow"&gt;http://www.nogeek.org/2008/07/25/using-sake-to-keep-merb-and-datamapper-on-edge/&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Sat, 26 Jul 2008 14:44:50 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:984fda14-9b46-4437-adaf-06d98658b8af</guid>
      <link>http://www.slashdotdash.net/articles/2008/07/05/getting-started-with-merb-and-datamapper#comment-472</link>
    </item>
  </channel>
</rss>
