Hacker News new | past | comments | ask | show | jobs | submit login
Rails 4 startup template (github.com/dennybritz)
88 points by dennybritz on Aug 11, 2013 | hide | past | favorite | 42 comments



Rather than Haml, at this point, I'd use Slim. Slim is cleaner (I'd say nicer) and faster than haml.

http://slim-lang.com/


Do you have any side-by-side benchmark comparisons of haml and slim? Not saying you're mistaken, but I'd be interested in those metrics.


There are a bunch out there, but here's one:

https://github.com/klaustopher/hamlerbslim

Also on a different note, Slim supports http streaming while Haml does not.


Nice, thanks.


Great! Also see Thoughtbot Suspenders, https://github.com/thoughtbot/suspenders

It also uses Bourbon, HAML, RSpec, etc. as well as many more gems. Overall I like and recommend what Thoughtbot creates.


Cool, thanks. I hadn't heard of suspenders. I'll check it out (and maybe steal some of their stuff... ;))


I've added this to the list of application templates I track at http://railsapps.github.io/rails-application-templates.html.

There's also a list of starter apps at http://railsapps.github.io/rails-examples-tutorials.html.

Most starter app projects end up as abandonware as Rails changes so it's good to see a new app template offered for Rails 4.0. Starter apps always produce a great discussion about must-have gems.


For development I have become cracked out on these for all of my apps

    group :development do
      gem 'better_errors' #literally what it says
      gem 'binding_of_caller' #adds REPL to better_errors
      gem 'quiet_assets' #prevent asset pipeline log doesnt go to console
      gem 'guard-livereload' #adds live reload
      gem 'rack-livereload'
      gem 'meta_request' #chrome rails panel extension 
    end


Ah, I like better_errors as well. I will probably add that! I think quiet_assets is no longer necessary, you can just change that in the config file.

I don't know the other, but will take a look at them! Thanks!


I wrote a gem, exception_details, that captures variable values at exception time. It gets you some pry-ish type detail, but you can use it on background jobs, etc. Might be useful for your toolbox...

https://github.com/ericbeland/exception_details


Oh cool thanks! Been in such a habit i never noticed:

    config.assets.logger = false


I have a starter app based on Ruby 2.0, Rails 4.0, PostgreSQL, Bootstrap and OmniAuth. Deployable on Heroku.

Here is what it looks like running live: http://frozen-savannah-6000.herokuapp.com/


Care to link back to the github repository?



Oops, don't know how I missed that. Thanks :)


> Remove the require_tree directives from the sass and JS files. It's better design to import or require things manually.

I'm sorry, what?


Yeah, personal choice, but I've had a lot of problems with rails "require_tree" in the past. Some gems add files to your code that shouldn't be required. ActiveAdmin is an example of that (though I think they've fixed that lately). To clarify, this is not about the "require" directives, only the "require_tree"


That sounds like an issue with the gems and not using require_tree


Yeah, but IMHO it's a lot cleaner if you actually know what's included instead of having 30 files in a kind of random order in there.


You can view the files in the html script includes while in development mode. It just feels wrong to me to do this manually. I have written the infrastructure code to handle javascript minification and compression. Not having to manage a script order file is one of the best parts of the asset pipeline.


Yeah, maybe I should give the asset pipeline another try. I started the habit of including files manually when it was first launched and was quite buggy. Ryan Bates from Railscasts also seems to prefer including his assets manually, he mentioned that in some of his screencasts. I kinda stole the habit from him.

I'll give the asset pipeline another try the next time...


Personal taste I guess, I'm always happy to specify my requires manually so I have a better idea and more control over what's going on, makes things more obvious for other developers reading your code too.


You know you can require another file at the top and the asset pipeline will ensure it is loaded first right?


Nice template, looks like an opinionated one . I see you have used ".env" file. I read somewhere when opensourcing apps its better to have all the env variables in .env, instead of using gem like https://github.com/laserlemon/figaro.

Also there is rails_composer https://github.com/RailsApps/rails-composer/ with many options to select css framework, servers, testing tools.


I just love GitHub. Followed the link, noticed that certain links were highlighted as links but not working. Went to the README, edited the broken links, sent a pull request [1], and now it works as expected. Everything done without having to leave "browsing mode", i.e. no cloning, no terminal, no editor.

[1] https://github.com/dennybritz/rails_startup_template/pull/3


Is something similar available for django projects?



So, I did something similar, and I found that one of my least favorite things was going into the browser to create and link the github repo. Using the octokit gem, I automated that part. Feel free to swipe some code from my gist:

https://gist.github.com/BrainScraps/5952463

Rock on.


That's great, thanks! I hate creating the github repo as well (sometimes I skip that part and just use Heroku). If you don't mind I'll copy some of your code and make creating a github repo another optional prompt.


Absolutely!

I noticed that suspenders(thoughtbot) also had that option. They used hub, which I think is a bit more intrusive than just installing the octokit gem. I'm interested to see what you come up with! :)


No guard or similar? Do you run tests and reload pages manually or use something else?


Yeah, I usually use guard. Indeed, I forgot to put that in there. Thanks for noticing!


Why not make a switch gems, in case someone doesn't want them? In other words, something like:

ENV['dont_include']='bourbon,analytics-ruby' rails new [app-name] -m template.rb


Why Haml instead of Slim?


In my opinion Slim is superior to Haml. I used to love Haml, but Slim takes it to the next level. A syntax with less control characters and a higher performance [1] made me switch.

I still haven't heard a single argument for writing pure HTML instead of Haml/Slim. Even for static HTML I use Slim.

[1] https://travis-ci.org/slim-template/slim/jobs/9676072


Slim also supports HTML streaming. Not sure if Haml have fixed this yet.


Why Haml at all? You will be changing all of your html in a browser anyways. Why not write html/erb?


I know this would become a debate, haha. HAML has definitely disadvantages, ERB is indeed nicer if you need to write a lot of nested tags, or stuff like strong, small, etc. Still I've found it's more pleasant to work with... But that's just personal taste and I should probably make it optional.


Coffeescript is really nice, though it can sometimes be a pain to debug. Haml is more succinct than HTML and I like the forced tab alignment. The problem is I almost never write view code that does not need to immediately be debugged in the browser. So I have to pay a mental tax to transform it nearly every time I write it.


You can mix them.

    %p Here is a Haml paragraph with a <strong>bold</strong> word.


Personal preference, but I find haml infinitely more productive and easier to manage.


Allow SECURE_TOKEN to be set via environment variable and it to be rotate-able.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: