כיצד להריץ קוד בצד השרת בלחיצה על כפתור?

Use the language features and do as @pfaffman suggests. Writing a bespoke front end hook to achieve this is seriously OTT.

See: ActiveRecord::Batches