Hard work by INTERNET

ベンチャーで働くひとりぼっちWEB開発者が頑張るブログ

railsのissueを読む

activeresourceで脆弱性が見つかった

activeresouceとは Railsアプリケーション間の通信をRESTで行うためのラッパーライブラリのようだ。 自分はactiveresouceを使うようなソフトウェアの開発は経験無し。 https://rubygems.org/gems/activeresource 本文 間違っているかもしれないんだけど、バ…

ActiveRecordのorderメソッドで is null を使いたい

github.com SQLのorder by句にActiveRecord経由で is null を使っていて、バージョンを6に上げたら警告が出てきた。よくわからん。 DEPRECATION WARNING: Dangerous query method (method whose arguments are used as raw SQL) called with non-attribute a…

rails6にしたらTransactionというクラスが見つからなくなったのだが。

github.com rails6にするまでは動いていたんだけど、Transactionクラスのメソッド呼び出しで undefined method がでるようになったんだけど、 Transactionクラスを持つことはrails6からは許可されていませんか?というissueというか完全なる質問。 これにつ…

etagに関するドキュメントの変更

github.com etagに関するドキュメントで誤りがあって、それを修正プルリクエスト。 fresh_when etag: @article # correct fresh_when @article # incorrect 最終的にはマージされたものの、マージした人いわく、このドキュメントを変更したところであまり変…

Rails6でadd_referenceすると `null: false` が追加されるのだが

github.com タイトルの通り、rails g migration AddColumnsToTable name user:references を実行すろと、null: falseオプションが追加される仕様に異議を唱えるissue。 この人が言っていることは2つあって null: falseつくけど、 belongs_toがオプショナルな…

パーシャルのコレクションレンダリングでnilを渡す

github.com パーシャルをレンダリングする時ってeachで回すと、N+1クエリ状態ですごく遅いんだよね。そういう時はパーシャルのレンダリングオプションにcollectionをつけることで、 レンダリングのオーバーヘッドを抑えることができる。 render 'books', as:…

number_to_currencyの出力に半角スペースではなくnbspを使ってくれ

github.com 半角スペースを含む€のような通貨だと意図しない改行が発生してしまう、という文脈みたい。 ちなみに、CSSにはスペースなどの単語の区切りで改行するようになっている。 今までは半角スペースを置換するパッチが活躍していたらしい。 HTMLEntitie…

link_toでXSS

github.com link_to の第2引数に javascript:...を渡すとそのまま発火するよ。というissue。 本文には対策のdiffも添えられている。 dofer to~ 〜に従う familiar with ~に精通

ActiveRecord#valid?はinteger型上限バリデーションを含めるべき rails/rails#37256

ActiveRecord valid? should includes ActiveModel validation for integer type column · Issue #37256 · rails/rails · GitHub validationを設定していないモデルのテーブルにint(11)型で定義したカラムにint(11)を超える値を設定すると、バリデーションエ…

Migrationが2回走る #37225

Migration running twice #37225 Migration running twice · Issue #37225 · rails/rails · GitHub 質問1 railsコマンドを実行すると2回実行してしまう。一体何が起きているんですか? (本文に再現コードあり) 回答1 This file does not have the migration …

Rails migration guide does not mention the removal of render :text #37145

github.com render :text が削除されたことがアップグレード移行ガイドにに書かれていない、という指摘のissueだ。 本文 render :text was removed in 5.1 but it is not mentioned in the upgrading guide for 5.1. render :textが5.1から削除されたが、ア…

ActiveRecord::Base#dup が動的属性を含めてくれない(does not include dynamic attributes) #34823

github.com 本文 rails4.2.xでは、 lib/active_record/core.rb#initialize_dup が正しく複製してくれるけれども、rails5.2ではpullするだけ MyModel._default_attributes によって、すでに複製したものを削除する。 Yes this still occurs on 5-2-stable. I'…

railsのアンダースコアに変換するメソッドの戻り値がおかしいんけど

github.com String inflection method underscore giving wrong output #37163 質問 アンダースコアライズする文字列変換文字列のアウトプットがおかしいんだが? Open up rails console and type - "ActLikeStar".underscore gives you 'act_like_star' whi…

検索条件が空を返す時にどうしてSQLを発行してんの?

Why do it need to execute SQL when ActiveRecord query conditions is empty array? · Issue #35307 · rails/rails · GitHub User.where(id: []) というコードを実行すると SELECT COUNT(*) FROM users WHERE 1=0という空を返却するSQLを発行している。必…

Remove unnecessary check.

github.com issue 本文 railsアプリケーションは、デフォルトでapplictionオブジェクトをセットしている。 だから不要なチェックは削除する。 def root - application && application.config.root + application.config.root end 返信 Not everything that h…

updated_attributeメソッドで 属性が変更されなかったならtrueを返す

github.com issue本文 If the attribute is not changed, then update_attribute does not run SQL query, this effectively means that no change was made to the attribute. 属性が変更されなかったらupdate_attributeメソッドはSQLクエリを実行せず、実…

DateTime#blank? のメソッドをempty?を使うように修正する

github.com issue本文 I think DateTime#blank? should be use Object#blank? method. DateTime#blank? は Object#blank? を使うべきだと思う。 WDYT?(Why do you thihk?) どう思う? 返事 Inheritance is only left to non-whitelisted classes. The method…

ActiveRecord exec_query fail for nonselect requests

github.com 本文 non select クエリーを exec_query#ActiveRecordで実行すると失敗する。 ActiveRecord::Base.connection.exec_query( 'update orders set id=1 where id=1' ) これのようなnon select クエリーを実行。 NoMethodError: undefined method `fi…

restartタスクの中でrailsコマンドを使え

github.com Be consistent in testing outputs from railties test and use /bin/rails by vipulnsward · Pull Request #23212 · rails/rails · GitHub に関連する。

Should AR where support `db_name.table_name.column_name` to key of hash?

issueの本文開始。 ActiveRecordのwhereは ハッシュのキー「 db_name.table_name.column_name」をサポートするべきです。 Now db_name.table_name.column_name is not supported as key of hash 今、db_name.table_name.column_nameはハッシューのキーとして…

Rails Documentation. Getting Started Tutorial not working. 1

RailsドキュメントのGetting Started が動かない。 Rails Documentation. Getting Started Tutorial not working. · Issue #19330 · rails/rails · GitHub 本文 あなたがgetting startedチュートリアルをフォローしているのなら、セクション5.2の終わりに気…

Scope that finds nothing or ends with .first does another lookup

Scope that finds nothing or ends with .first does another lookup · Issue #19249 · rails/rails 結果が見つからなくてfirstメソッドで終わるとscopeが別の結果になる。 本文 Rails4.2とRuby2.2だよ。 class Car < ActiveRecord::Base scope :where_color…

Time select and datetime select not honoring config.time_zone value

Time select and datetime select not honoring config.time_zone value · Issue #19229 · rails/rails issueの本文 time_select, datetime_select のフォームヘルパーがタイムゾーンを無視する。UTCから変換するべきだ。今はUTCで保存される。環境はRuby2.2…