惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
H
Help Net Security
MongoDB | Blog
MongoDB | Blog
I
InfoQ
N
Netflix TechBlog - Medium
T
Tailwind CSS Blog
量子位
博客园 - 叶小钗
月光博客
月光博客
IT之家
IT之家
G
Google Developers Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
小众软件
小众软件
S
SegmentFault 最新的问题
Engineering at Meta
Engineering at Meta
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
aimingoo的专栏
aimingoo的专栏
云风的 BLOG
云风的 BLOG
Vercel News
Vercel News
爱范儿
爱范儿
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
宝玉的分享
宝玉的分享

Ruby on Rails: Compress the complexity of modern web apps

Safer to_i coercion, custom to_fs formats, and more! This Week in Rails: May 16, 2026 This Week in Rails: May 8, 2026 This Week in Rails: May 1, 2026 Active Record gets better every week Great big Rails World 2026 update: CFP, Corporate Support tickets, workshops Query command for database queries and more Explicit query: and body: kwargs for integration tests and more! Speedup ActiveRecord::LogSubscriber#sql_color and more! This Week in Rails: March 27, 2026 Rails Versions 8.0.5 and 8.1.3 have been released! Rails Versions 7.2.3.1, 8.0.4.1, and 8.1.2.1 have been released! This Week in Rails: March 20, 2026 Validate URI scheme in Action Text and more This Week in Rails: March 6, 2026 Planning Center is the newest Rails Foundation Contributing member Action Text gets Markdown conversion, editor links in devcontainers, and more! BARRA seeks Rails developer Joe Agliozzo is looking for a Rails developer The rise of lighttpd as the alternative web server When longer is better and more is more Snowdevil: First e-tailer on Rails Natural selection for frameworks in Ruby vs Java Address book tutorial in Portuguese Becoming a better programmer with Rails 10 Things Every Java Programmer Should Know About Ruby Really Getting Started in Rails Off the Treadmill, Onto the Rails Rails 0.9.5: A world of fixes and tweaks Rich clients with Rails and XUL
Add non-null modifier for migrations, default script fold...
David Heinemeier Hansson · 2024-07-19 · via Ruby on Rails: Compress the complexity of modern web apps

Friday, July 19, 2024
Posted by vipulnsward

Hey everyone, Happy Friday! Vipul here with the latest updates for This Week in Rails. Let’s dive in.

Add a basic sessions generator
This change adds a new sessions generator to give a basic start to an authentication system using database-tracked sessions.

# Generate with...
bin/rails generate session

# Generated files
app/models/current.rb
app/models/user.rb
app/models/session.rb
app/controllers/sessions_controller.rb
app/views/sessions/new.html.erb
db/migrate/xxxxxxx_create_users.rb
db/migrate/xxxxxxx_create_sessions.rb

Add script folder and generator
This Pull Request adds a new script default folder to hold one-off or general purpose scripts, such as data migration scripts, cleanup scripts, etc.

The new script generator allows us to create such scripts:

rails generate script my_script

We can also specify a folder, when generating scripts:

rails generate script cleanup/my_script

We can then run the generated scripts using:

ruby script/my_script.rb

Remove channels from default app/ structure
Now that Hotwire is the default in Rails, this change drops the channels folder from default app/ structure. The folder still gets created when using the channel generator if needed.

Drop default permissions policy initializer
This change drops the rarely used default permissions_policy configuration files. The configuration can be added back as needed referring to the documentation of permissions_policy instead.

Add not-null modifier to migrations
This change adds a not-null modifier to migrations, which we can now specify using a ! after column types:

# Generating with...
bin/rails generate migration CreateUsers email_address:string!:uniq password_digest:string!

# Produces:
class CreateUsers < ActiveRecord::Migration[8.0]
  def change
    create_table :users do |t|
      t.string :email_address, null: false
      t.string :password_digest, null: false
      t.timestamps
    end
    add_index :users, :email_address, unique: true
  end
end

Raise specific exception when a connection is not defined
This change makes it easier to provide programmatic access to details about requested shard/role. The new ConnectionNotDefined exception provides connection name, shard and role accessors indicating the details of the connection that was requested.

You can view the whole list of changes here.
We had 20 contributors to the Rails codebase this past week!

Until next time!

Subscribe to get these updates mailed to you.