Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ユーザーが<h1>Johnテキストフィールドに入力して保存すると、代わりに保存され>h1<Johnます。
<h1>John
>h1<John
それを可能にするために、モデルにどのようにコーディングできますか?
ユーザーモデルのnameコラムです。
name
コールバックを作成するだけです:
class YourModel before_save :sanitize_name private def sanitize_name self.name = CGI::escapeHTML(name) end end