---
title: 'Lucky is Getting Bigger and Better: Announcing v0.6'
teaser: 'Over 130 commits and 20 new features have been added to Lucky since the first
  announcement a month ago. Check out all that’s new in Lucky v0.6!

  '
tags: lucky,crystal,web
author: Paul Smith
published_on: 2017-11-30
---

[Lucky](https://github.com/luckyframework/lucky) is a web framework written in
Crystal that helps you build apps quickly, catches bugs for you, and runs
incredibly fast.

I’ve been blown away by all the progress that has been made in the last month
thanks to many new contributors. 👊

We’ve added over [130 commits](#all-changes-in-this-release) and
[20+ new features](#highlights-in-this-release) across the Lucky libraries since
[the initial announcement](https://thoughtbot.com/blog/lucky-an-experimental-new-web-framework-by-thoughtbot).
The website has also been improved with a new
[Why Lucky?](http://luckyframework.org/why-lucky/) page, and some
[fresh new guides](https://luckyframework.org/guides). All these changes bring
us closer to production ready version of Lucky.

> 👋 Hey! If you’re interested in helping out with Lucky, or just want to see
> what’s new, check out
> [Lucky’s GitHub repo](https://github.com/luckyframework/lucky).

## Highlights in this release

Negate queries with `not`:

```ruby
# Get users who don't work at Facebook
UserQuery.new.company.not(“Facebook”)

# Can be chained
UserQuery.new.last_name.not.ilike("Mc%")
```

[Virtual fields](https://luckyframework.org/guides/saving-with-forms/#virtual-fields)
for when you want users to fill something out, but not save to the database:

```ruby
class SignUpForm < User::BaseForm
  # This is a field users should fill in, but is not saved to the database
  allow_virtual password_confirmation : String
end
```

[Virtual forms](https://github.com/luckyframework/lucky_record/pull/115) were
added so you can process data that isn’t ever saved to a database:

```ruby
class SignInForm < LuckyRecord::VirtualForm
  allow_virtual email : String
  allow_virtual password : String

  def self.submit
    # authenticate the user
  end
end
```

Tons of new migration helpers

```ruby
# An example of a few of the new methods
def migrate
  create users do
    # Add indices at the same time as adding a field
    add company_id : Int32, index: true
    # Add unique indexes
    add email : String, unique: true
    # Set default values
    add admin : Bool, default: false
  end

  # Create foreign keys with cascading deletes
  create_foreign_key :users, :companies, on_delete: :cascade
end
```

Improved logger in development

![](https://images.thoughtbot.com/blog-vellum-image-uploads/hKCN2rGSiWf5UTV3QWoO_logger.png)

New [JSON serializers](https://github.com/luckyframework/lucky/pull/200)

```ruby
class Api::Users::Show < ApiAction
  action do
    user = UserQuery.new.find(id)
    json User::ShowJSON.new(user)
  end
end

class Users::ShowJSON < LuckyWeb::Serializer
  # This is a shortcut for setting instance vars in Crystal
  # https://crystal-lang.org/docs/syntax_and_semantics/methods_and_instance_variables.html
  def initialize(@user : User); end

  def render
    { name: @user.name, email: @user.email }
  end
end
```

## Other additions

* [Typed HTTP status codes](https://github.com/luckyframework/lucky/pull/232)
* [Allow outputting more types in HTML](https://github.com/luckyframework/lucky/commit/e75a6f8da12bb4f7df3c195c7f74f1e0a9b3c566)
* [10x performance boost in LuckyRecord](https://github.com/luckyframework/lucky_record/commit/9407060bc039fb2b11073ddd26b4995be2be7d42)
* [Massively simplified pages and layouts](https://luckyframework.org/guides/rendering-html/#layouts)
* [Nested serializers](https://github.com/luckyframework/lucky/commit/f986af1c28e9960af4d92ffb4a9083b9f51c5841)
* [Raise RecordNotFound error](https://github.com/luckyframework/lucky_record/pull/75)
  if `Queryable#find` fails
* [`Form.create!/update!`](https://github.com/luckyframework/lucky_record/pull/82)for
  raising if a form fails to save
* [Checkbox helper](https://github.com/luckyframework/lucky/pull/201)
* [Add `on` option to form needs](https://github.com/luckyframework/lucky_record/commit/abdc967fd68b0de31eba63fd3ad2ae9378b3e012)
* [Custom validation messages](https://github.com/luckyframework/lucky_record/pull/109)
* [Generate bin/setup script](https://github.com/luckyframework/lucky_cli/commit/6ca870fece2fde05da58f1709336b2fd1853b70d)
  for easy setup
* [Add lucky gen.secret_key](https://github.com/luckyframework/lucky/commit/32f54d91a9519814481c23b64be069988e86580c)

And more! See the comparison view below if you want to see a comprehensive list
of changes.

## All changes in this release

* [Lucky](https://github.com/luckyframework/lucky/compare/v0.5.0...v0.6.2)
* [LuckyRecord](https://github.com/luckyframework/lucky_record/compare/v0.2.0...v0.3.0)
* [LuckyMigrator](https://github.com/luckyframework/lucky_migrator/compare/v0.2.3...v0.3.0)
* [Lucky CLI](https://github.com/luckyframework/lucky_cli/compare/v0.6.0...v0.7.0)
* A brand new library,
  [LuckyInflector](https://github.com/luckyframework/lucky_inflector)
* [Lucky's website](https://github.com/luckyframework/website/compare/e74880efaaa49ff38b6169a922aeb549a5e60685...https://github.com/luckyframework/website/compare/e74880efaaa49ff38b6169a922aeb549a5e60685...d6868e79c14469500c46eb147840cc0e57782189)
