From c783d434d1eb019c4629aa4d5c0db5d2a3a2b22d Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 8 May 2014 15:07:39 -0400 Subject: write about customizations I've made to Rails --- public/rails-improvements.md | 87 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 public/rails-improvements.md (limited to 'public') diff --git a/public/rails-improvements.md b/public/rails-improvements.md new file mode 100644 index 0000000..4f728fc --- /dev/null +++ b/public/rails-improvements.md @@ -0,0 +1,87 @@ +Miscellaneous ways to improve your Rails experience +=================================================== +--- +date: "2014-05-08" +--- + +Recently, I've been working on [a Rails web application][leaguer], +that's really the baby of a friend of mine. Anyway, through its +development, I've come up with a couple things that should make your +interactions with Rails more pleasant. + +## Auto-(re)load classes from other directories than `app/` + +The development server automatically loads and reloads files from the +`app/` directory, which is extremely nice. However, most web +applications are going to involve modules that aren't in that +directory; and editing those files requires re-starting the server for +the changes to take effect. + +Adding the following lines to your +[`config/application.rb`][application.rb] will allow it to +automatically load and reload files from the `lib/` directory. You +can of course change this to whichever directory/ies you like. + + module YourApp + class Application < Rails::Application + … + config.autoload_paths += ["#{Rails.root}/lib"] + config.watchable_dirs["#{Rails.root}/lib"] = [:rb] + … + end + end + +## Have `submit_tag` generate a button instead of an input + +In HTML, the `` tag styles slightly differently +than other inputs or buttons. It is impossible to precisely controll +the hight via CSS, which makes designing forms a pain. This is +particularly noticable if you use Bootstrap 3, and put it next to +another button; the submit button will be slightly shorter +vertically. + +The obvious fix here is to use `