{"id":256,"date":"2011-09-26T10:40:38","date_gmt":"2011-09-26T10:40:38","guid":{"rendered":"http:\/\/nicholshayes.co.uk\/blog\/?p=256"},"modified":"2014-01-06T17:00:04","modified_gmt":"2014-01-06T17:00:04","slug":"do-not-put-hyphens-in-engine-names","status":"publish","type":"post","link":"http:\/\/nicholshayes.co.uk\/blog\/?p=256","title":{"rendered":"Do not put hyphens in engine names"},"content":{"rendered":"<p>I&#8217;m currently working on my first rails 3.1 engine and have just wasted a day or so because I put a hyphen in the engine name. The reason I did this was to be consistent with some other plug-ins I am using (e.g. <a href=\"https:\/\/github.com\/reggieb\/noodall-core\">noodall-core<\/a>). The new plugin should provide polls for noodall sites. So noodall-poll would be consistent with other noodall plugins.<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">rails plugin new NoodallPoll --mountable<\/div><\/div>\n<p>Created noodall_poll.<\/p>\n<p>So instead I used:<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">rails plugin new noodall-poll --mountable<\/div><\/div>\n<p>The result was lots of paths using noodall-poll, such as \/app\/helpers\/noodall-poll\/application_helper.rb. When I tried to run test, I got application_helper.rb not found errors. The system was looking for \/app\/helpers\/noodall_poll\/application_helper.rb.<\/p>\n<p>Lesson learn: don&#8217;t play around with engine names. Use camelcase or underscored engine names.<\/p>\n<p><strong>An update:<\/strong><br \/>\nThis issue has raised its head again and following a google search and I came up with what I think should be <a href=\"http:\/\/guides.rubygems.org\/name-your-gem\/\">the definitive answer<\/a>:<\/p>\n<p>If your gem lives in a parent name space, the name spaces should be separated with hyphens in the gem name. So <em>Net::HTTP<\/em> has a parent namespace of <em>Net <\/em>and a main namespace of <em>HTTP<\/em>, and so the gem name is <strong>net-http<\/strong>.<\/p>\n<p>If your project name comprises multiple words, the words should be separated by underscores in the gem name. So a project with a namespace <em>FooBar<\/em> have the gem name <strong>foo_bar<\/strong>.<\/p>\n<p>And to combine the two <em>Net::FooBar<\/em> should have the project name &#8216;<strong>net-foo_bar<\/strong>&#8216;.<\/p>\n<p>As for the folder structure in my original example: Noodall should have been the parent namespace, so the gem name would be noodall-poll, and the path to the helper should have been: \/app\/helpers\/noodall\/poll\/application_helper.rb<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m currently working on my first rails 3.1 engine and have just wasted a day or so because I put a hyphen in the engine name. The reason I did this was to be consistent with some other plug-ins I &hellip; <a href=\"http:\/\/nicholshayes.co.uk\/blog\/?p=256\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"http:\/\/nicholshayes.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/256"}],"collection":[{"href":"http:\/\/nicholshayes.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/nicholshayes.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/nicholshayes.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/nicholshayes.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=256"}],"version-history":[{"count":6,"href":"http:\/\/nicholshayes.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/256\/revisions"}],"predecessor-version":[{"id":482,"href":"http:\/\/nicholshayes.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/256\/revisions\/482"}],"wp:attachment":[{"href":"http:\/\/nicholshayes.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/nicholshayes.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=256"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/nicholshayes.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}