# The lesser-known features in Rails 5.1

DevFeed: [The lesser-known features in Rails 5.1](<https://devfeed.tech/articles/the-lesser-known-features-in-rails-5-1-26277.md>)

Original publisher: [Read original article](<https://www.justinweiss.com/articles/the-lesser-known-features-in-rails-5-dot-1/>)

Author: Justin Weiss

Published: 2017-05-02T05:49:00Z

Content type: tutorial

Language: en

Sources: [Justin Weiss](<https://devfeed.tech/sources/justin-weiss.md>)

Topics: [Rails](<https://devfeed.tech/topics/rails.md>), [Ruby](<https://devfeed.tech/topics/ruby.md>), [JavaScript](<https://devfeed.tech/topics/javascript.md>), [HTML5](<https://devfeed.tech/topics/html5.md>)

Tags: [2017](<https://devfeed.tech/tags/2017.md>), [features](<https://devfeed.tech/tags/features.md>), [html5](<https://devfeed.tech/tags/html5.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [new-features](<https://devfeed.tech/tags/new-features.md>), [rails](<https://devfeed.tech/tags/rails.md>), [ruby](<https://devfeed.tech/tags/ruby.md>)

## AI overview

This article surveys lesser-known Rails 5.1 improvements, including consistent HTML5 tag helpers, the assert_changes test helper, delegation with delegate_missing_to, and the replacement of alias_method_chain with prepend.

## Source excerpt

Last week, during RailsConf 2017, Rails 5.1 shipped. If you followed the announcements, you've seen the big features: better integration with modern JavaScript, encrypted secrets, and system tests. And there's my personal favorite: finally getting rid of the weird combo of form_for and form_tag, and replacing it with form_with. I can't wait to try it. But the reason I love Rails isn't the big new features. It's the little, constant improvements. It's those quality-of-life changes that make me happier when I'm writing Rails apps. And Rails 5.1 is full of them. More consistent tag helpers Have you used Rails' tag helpers, like tag and content_tag? <%= content_tag :p, @user.name, class: "name" %> Rails 5.1 adds a new tag helper syntax. Use calls like tag.div or tag.br, and you can stop worrying about parameter order and juggling two different methods: <%= tag.p @user.name, class: "name" %> <%= tag.br %> These new tag helpers support HTML5 by default, and even let you create your own elements: <%= tag.pea @user.name, class: "name" %> <!-- turns into <pea class="name">Justin Weiss</pea> --> Assert more than just differences I love assert_difference. Before assert_difference, I spent way too much time juggling local variables in tests: old_score = @user.score @user.answer_question!(...) assert_equal old_score + 10, @user.score With assert_difference, it's much clearer what you're trying to do: assert_difference "@user.score", 10 do @user.answer_question!(...) end In Rails 5.1, assert_changes takes this one step further. assert_difference only checks changes in count. But assert_changes can check non-numerical changes, like changes between two strings, or between nil and something else: assert_changes "users(:justin).name", from: "Justin", to: "Bob" do @user.update_attributes(name: "Bob") end Instead of a string, you can give it a lambda: assert_changes -> { users(:justin).name }, from: "Justin", to: "Bob" do @user.update_attributes(name: "Bob") end to: can be anything tha