Rails, or Ruby on Rails, is a server side web app framework written in Ruby. It is designed to make programming web applications easier by making assumptions about what every developer needs to get started. Like Ruby, Rails is designed with ‘programmer happiness’ in mind and prioritises readability, ease and enjoyment of use.
Rails is an MVC (Model-view-controller) framework and famously favours Convention over configuration in an attempt to aid productivity and lower the barrier to entry. An example of this is the way in which a model in Rails maps to a table in a database and to a Ruby file, it is only if one deviates from this convention, that the developer needs to write code regarding these names.
Rails is sometimes criticised for issues with scalability due to being written in the relatively slow performing Ruby. It should be noted, however, that many high profile, high traffic web apps are currently running on Ruby on Rails including Airbnb, Github and GOV.UK!
When working with an existing rails project, the rails version will be specified
in the gemfile and all you will need to do is navigate to the application in your
terminal and run
bundle install and voila, all dependencies will be installed.
If you are starting a project afresh then rails offers wonderful documentation to help you begin
Working with Rails Projects
As noted above, the dependencies are listed in a 'Gemfile’.
A Rails application can be run with
bundle exec rails --server. It is common
practice to define how to get started with a Rails application through a README
file in the root of the project.
Tasks in a Rails project will typically be run using [Rake][rake] which, by convention, will usually run the tests of an application if it is not provided any arguments.
Rails Test Frameworks
You can find the GDS programming language style guides here
- Pry-byebug A step by step debugging tool
- Factory bot A library for setting up Ruby objects as test data
- GOVUK-lint A linter which complies with GOV.UK ruby styleguide.
- GOVUK_app_config A library which includes the basics of a GOV.UK application including error reporting, a Unicorn web server, logging and a stasd client.
- GDS-api-adapters A set of API adapters to make working with GDS APIs easier.
- Michael Hartl’s RoR Tutorial Arguably the most famous beginners guide to Rails available.
- Railscasts Ryan Bates’ YouTube channel which contains webcasts on just about everything Rails, an excellent resource for the visual learner, although some of the videos are a little dated.
- Thoughtbot blog Thoughtbot, the people behind factory bot and many other high profile ruby gems, have a great, regularly updated blog often covering rails or ruby specific issues as well as general thoughts on software development.