profile
viewpoint
Rafael Mendonça França rafaelfranca Shopify Ottawa, ON

heartcombo/devise 22072

Flexible authentication solution for Rails with Warden.

heartcombo/simple_form 7872

Forms made easy for Rails! It's tied to a simple DSL, with no opinion on markup.

rack/rack 4255

A modular Ruby web server interface.

heartcombo/responders 1919

A set of Rails responders to dry up your application

heartcombo/has_scope 1525

Map incoming controller parameters to named scopes in your resources

heartcombo/mail_form 847

Send e-mail straight from forms in Rails with I18n, validations, attachments and request information.

heartcombo/simple_form-bootstrap 771

Example application with SimpleForm and Twitter Bootstrap

gel-rb/gel 612

A modern gem manager

brianmario/escape_utils 522

Faster string escaping routines for your ruby apps

create barnchrails/spring

branch : rm-new-format-binstub

created branch time in 10 hours

Pull request review commentrails/rails

ActiveStorage: support empty attachments submits

+*   Support transforming empty-ish `has_many_attached` value into `[]` (e.g. `[""]`)

I'll move it to 7-0-stable. I should have included this feature in 7.0.0.rc1

seanpdoyle

comment created time in 11 hours

PullRequestReviewEvent

Pull request review commentrails/rails

Efficient yield in batches

 def in_batches(of: 1000, start: nil, finish: nil, load: false, error_on_ignore:         batch_limit = remaining if remaining < batch_limit       end -      relation = relation.reorder(batch_order(order)).limit(batch_limit)-      relation = apply_limits(relation, start, finish, order)-      relation.skip_query_cache! # Retaining the results in the query cache would undermine the point of batching-      batch_relation = relation+      limit_relation = relation.reorder(batch_order(order)).limit(batch_limit)+      limit_relation = apply_finish_limit(limit_relation, finish, order) if finish+      limit_relation.skip_query_cache! # Retaining the results in the query cache would undermine the point of batching +      offset = nil       loop do-        if load-          records = batch_relation.records-          ids = records.map(&:id)-          yielded_relation = where(primary_key => ids)-          yielded_relation.load_records(records)+        batch_relation = limit_relation+        if offset

        if offset
montokapro

comment created time in 11 hours

Pull request review commentrails/rails

Efficient yield in batches

 def in_batches(of: 1000, start: nil, finish: nil, load: false, error_on_ignore:         batch_limit = remaining if remaining < batch_limit       end -      relation = relation.reorder(batch_order(order)).limit(batch_limit)-      relation = apply_limits(relation, start, finish, order)-      relation.skip_query_cache! # Retaining the results in the query cache would undermine the point of batching-      batch_relation = relation+      limit_relation = relation.reorder(batch_order(order)).limit(batch_limit)+      limit_relation = apply_finish_limit(limit_relation, finish, order) if finish+      limit_relation.skip_query_cache! # Retaining the results in the query cache would undermine the point of batching +      offset = nil       loop do-        if load-          records = batch_relation.records-          ids = records.map(&:id)-          yielded_relation = where(primary_key => ids)-          yielded_relation.load_records(records)+        batch_relation = limit_relation+        if offset+          batch_relation = apply_offset_limit(batch_relation, offset, order)+        elsif start+          batch_relation = apply_start_limit(batch_relation, start, order)+        end++        ids = if load+          batch_relation.records.map(&:id)         else-          ids = batch_relation.pluck(primary_key)-          yielded_relation = where(primary_key => ids)+          batch_relation.pluck(primary_key)         end          break if ids.empty? -        primary_key_offset = ids.last-        raise ArgumentError.new("Primary key not included in the custom select clause") unless primary_key_offset+        yielded_relation = relation+        if offset

        if offset
montokapro

comment created time in 11 hours

Pull request review commentrails/rails

Efficient yield in batches

 def in_batches(of: 1000, start: nil, finish: nil, load: false, error_on_ignore:         batch_limit = remaining if remaining < batch_limit       end -      relation = relation.reorder(batch_order(order)).limit(batch_limit)-      relation = apply_limits(relation, start, finish, order)-      relation.skip_query_cache! # Retaining the results in the query cache would undermine the point of batching-      batch_relation = relation+      limit_relation = relation.reorder(batch_order(order)).limit(batch_limit)+      limit_relation = apply_finish_limit(limit_relation, finish, order) if finish+      limit_relation.skip_query_cache! # Retaining the results in the query cache would undermine the point of batching +      offset = nil       loop do-        if load-          records = batch_relation.records-          ids = records.map(&:id)-          yielded_relation = where(primary_key => ids)-          yielded_relation.load_records(records)+        batch_relation = limit_relation+        if offset+          batch_relation = apply_offset_limit(batch_relation, offset, order)+        elsif start+          batch_relation = apply_start_limit(batch_relation, start, order)+        end++        ids = if load+          batch_relation.records.map(&:id)         else-          ids = batch_relation.pluck(primary_key)-          yielded_relation = where(primary_key => ids)+          batch_relation.pluck(primary_key)         end          break if ids.empty? -        primary_key_offset = ids.last-        raise ArgumentError.new("Primary key not included in the custom select clause") unless primary_key_offset+        yielded_relation = relation+        if offset+          yielded_relation = apply_offset_limit(yielded_relation, offset, order)+        elsif start+          yielded_relation = apply_start_limit(yielded_relation, start, order)+        end++        offset = ids.last+        raise ArgumentError.new("Primary key not included in the custom select clause") unless offset +        yielded_relation = apply_finish_limit(yielded_relation, offset, order)+        yielded_relation.load_records(batch_relation.records) if load
        yielded_relation.load_records(batch_relation.records) if load

montokapro

comment created time in 11 hours

Pull request review commentrails/rails

Efficient yield in batches

 def in_batches(of: 1000, start: nil, finish: nil, load: false, error_on_ignore:         batch_limit = remaining if remaining < batch_limit       end -      relation = relation.reorder(batch_order(order)).limit(batch_limit)-      relation = apply_limits(relation, start, finish, order)-      relation.skip_query_cache! # Retaining the results in the query cache would undermine the point of batching-      batch_relation = relation+      limit_relation = relation.reorder(batch_order(order)).limit(batch_limit)+      limit_relation = apply_finish_limit(limit_relation, finish, order) if finish+      limit_relation.skip_query_cache! # Retaining the results in the query cache would undermine the point of batching +      offset = nil       loop do-        if load-          records = batch_relation.records-          ids = records.map(&:id)-          yielded_relation = where(primary_key => ids)-          yielded_relation.load_records(records)+        batch_relation = limit_relation+        if offset+          batch_relation = apply_offset_limit(batch_relation, offset, order)+        elsif start+          batch_relation = apply_start_limit(batch_relation, start, order)+        end++        ids = if load+          batch_relation.records.map(&:id)         else-          ids = batch_relation.pluck(primary_key)-          yielded_relation = where(primary_key => ids)+          batch_relation.pluck(primary_key)         end          break if ids.empty? -        primary_key_offset = ids.last-        raise ArgumentError.new("Primary key not included in the custom select clause") unless primary_key_offset+        yielded_relation = relation+        if offset+          yielded_relation = apply_offset_limit(yielded_relation, offset, order)+        elsif start+          yielded_relation = apply_start_limit(yielded_relation, start, order)+        end++        offset = ids.last+        raise ArgumentError.new("Primary key not included in the custom select clause") unless offset

        raise ArgumentError.new("Primary key not included in the custom select clause") unless offset
montokapro

comment created time in 11 hours

PullRequestReviewEvent
PullRequestReviewEvent
PullRequestEvent

push eventrails/rails

Étienne Barrié

commit sha 51432c62eb03d5405b3ad11085fb0ed066d50776

Make ActiveStorage update migration compatible with install migration If you install active_storage in rails 6.1, then use rails app:update, the service name migration handles that case but not the variant records one, which fails trying to re-create the table. Co-authored-by: Adrianna Chang <adrianna.chang@shopify.com>

view details

Rafael Mendonça França

commit sha 479583a7f2b0e316d5f61c7c8e8303ca5c9abc90

Merge pull request #41193 from etiennebarrie/activestorage-compatible-update-migration Make ActiveStorage update migration compatible with install migration

view details

push time in 11 hours

PR merged rails/rails

Reviewers
Make ActiveStorage update migration compatible with install migration activestorage

If you install ActiveStorage in rails 6.1, then use rails app:update, the service name migration handles that case but not the variant records one, which fails trying to re-create the table.

Summary

I updated an app to Rails 6.1, but forgot to run rails app:update immediately. Then later I installed ActiveStorage, and finally came back to run the update task. When I saw the update migrations being created in the app, I assumed they would fail but was pleasantly surprised that the service name passed by checking for the presence of the column. So I felt maybe we'd want to do the same to the other migration. We can also assume users will understand and just remove the migrations.

Repro steps:

$ rails _6.1.1_ new my_app && cd my_app
$ rails active_storage:install && rails db:migrate
$ rails app:update && rails db:migrate
# fails on CreateActiveStorageVariantRecords

Other Information

It works perfectly in the regular case:

$ rails _6.0.3.4_ new my_app && cd my_app
$ rails active_storage:install && rails db:migrate
$ $EDITOR Gemfile && bundle update # update to 6.1
$ yes | rails app:update && rails db:migrate
+1 -1

3 comments

1 changed file

etiennebarrie

pr closed time in 11 hours

pull request commentrails/rails

Raise an ArgumentError if unsupported options are passed to add_column

How would external adapters support their options that are not listed in the constants you added to this PR? The reason we don't change the options is because some adapter can support omg option and they should be able to implement that without having to change Rails.

npezza93

comment created time in 11 hours

PullRequestReviewEvent

Pull request review commentrails/rails

Human-friendly output when inspecting ActiveModel with attributes

 def respond_to?(method, include_private_methods = false)       end     end +    # Returns an <tt>#inspect</tt>-like string for the value of the+    # attribute +attr_name+. String attributes are truncated up to 50+    # characters. Other attributes return the value of <tt>#inspect</tt>+    # without modification.+    #+    #   person = Person.new(name: 'David Heinemeier Hansson ' * 3)+    #+    #   person.attribute_for_inspect(:name)+    #   # => "\"David Heinemeier Hansson David Heinemeier Hansson ...\""+    #+    #   person.attribute_for_inspect(:created_at)+    #   # => "\"2012-10-22 00:15:07.000000000 +0000\""+    #+    #   person.attribute_for_inspect(:tag_ids)+    #   # => "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]"+    def attribute_for_inspect(attr_name)

Why do we have this method here? It is not used anywhere.

Drenmi

comment created time in 11 hours

Pull request review commentrails/rails

Human-friendly output when inspecting ActiveModel with attributes

 def _read_attribute(attr)         __send__(attr)       end +      def format_for_inspect(name, value)

Why is this method in this module and not in Attribute?

Drenmi

comment created time in 11 hours

PullRequestReviewEvent
PullRequestEvent

pull request commentrails/rails

fix: equivalent negative durations add to the same time

Instead of calling build again, can we doing the same as #43809?

cpb

comment created time in 11 hours

Pull request review commentrails/rails

Tweak form_with without format test

 def test_form_for_with_format   end    def test_new_form_for_without_format+    # if the path is to be overridden in an application, make sure+    # {format:nil} will not be passed in which will break the app+    def post_path(id, car = nil)

This method end up leaking to all the test. It is the same as defining outside of the test. I think we need to find another way to test this.

cryptoque

comment created time in 12 hours

PullRequestReviewEvent
PullRequestReviewEvent

pull request commentrails/rails

Add Marginalia migration guide for Rails 7 upgrade

@keeran do you want to finish this PR?

keeran

comment created time in 12 hours

push eventrails/rails

Rafael Mendonça França

commit sha ed799763051b2704b1746321c9ac59ff6c518eac

Merge pull request #43776 from lifeiscontent/patch-1 Update 20191206030411_create_active_storage_variant_records.rb

view details

push time in 12 hours

push eventrails/rails

Rafael Mendonça França

commit sha 8b6342e3419a2332a425d8a665c0f8d9b5181c1d

Use `if_not_exists` instead of `table_exists?`

view details

push time in 12 hours

push eventrails/rails

Aaron Reisman

commit sha 6ed63abecda3733d0e73aa35412a4675f10fe198

Update 20191206030411_create_active_storage_variant_records.rb In the cast of bootstrapping a project for the first time without active storage, when running `rails app:update` this migration would result in trying to create the table twice.

view details

Rafael Mendonça França

commit sha 6172f541d8236b9b5278c58abb4100a31b84ca92

Merge pull request #43776 from lifeiscontent/patch-1 Update 20191206030411_create_active_storage_variant_records.rb

view details

push time in 12 hours

PR merged rails/rails

Update 20191206030411_create_active_storage_variant_records.rb activestorage

In the case of bootstrapping a project for the first time without active storage, when running rails app:update this migration would result in trying to create the table twice.

Summary

<!-- Provide a general description of the code changes in your pull request... were there any bugs you had fixed? If so, mention them. If these bugs have open GitHub issues, be sure to tag them here as well, to keep the conversation linked together. -->

Other Information

<!-- If there's anything else that's important and relevant to your pull request, mention that information here. This could include benchmarks, or other information.

If you are updating any of the CHANGELOG files or are asked to update the CHANGELOG files by reviewers, please add the CHANGELOG entry at the top of the file.

Finally, if your pull request affects documentation or any non-code changes, guidelines for those changes are available here

Thanks for contributing to Rails! -->

<!-- Note: Please avoid making Draft pull requests, as they still send notifications to everyone watching the Rails repo. Create a pull request when it is ready for review and feedback from the Rails team :). -->

+8 -6

2 comments

1 changed file

lifeiscontent

pr closed time in 12 hours

issue commentrails/rails

Behaviour of ActiveRecord::Relation#one? has changed

This is indeed an issue. Given you can reproduce. Can you take a look on how to fix it?

jpawlyn

comment created time in 12 hours

Pull request review commentrails/rails

Update 20191206030411_create_active_storage_variant_records.rb

 class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0]   def change-    # Use Active Record's configured type for primary key-    create_table :active_storage_variant_records, id: primary_key_type do |t|-      t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type-      t.string :variation_digest, null: false+    unless table_exists?(:active_storage_variant_records)+      # Use Active Record's configured type for primary key+      create_table :active_storage_variant_records, id: primary_key_type do |t|+        t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type+        t.string :variation_digest, null: false -      t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true-      t.foreign_key :active_storage_blobs, column: :blob_id+        t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true+        t.foreign_key :active_storage_blobs, column: :blob_id+      end
      t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true
      t.foreign_key :active_storage_blobs, column: :blob_id
lifeiscontent

comment created time in 12 hours

Pull request review commentrails/rails

Update 20191206030411_create_active_storage_variant_records.rb

 class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0]   def change-    # Use Active Record's configured type for primary key-    create_table :active_storage_variant_records, id: primary_key_type do |t|-      t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type-      t.string :variation_digest, null: false+    unless table_exists?(:active_storage_variant_records)+      # Use Active Record's configured type for primary key+      create_table :active_storage_variant_records, id: primary_key_type do |t|+        t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type+        t.string :variation_digest, null: false
      # Use Active Record's configured type for primary key
      create_table :active_storage_variant_records, id: primary_key_type, if_not_exists: true do |t|
        t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type
        t.string :variation_digest, null: false
lifeiscontent

comment created time in 12 hours

more