def publish_post(post, timeframe: :now) case timeframe when :now post.publish! when :tomorrow post.delay(run_at: 1.day.from_now).publish! else raise ArgumentError, "Invalid timeframe: #{timeframe.inspect}" end end # posts_controller.rb def publish post = Post.find(params[:id]) publish_post(post, params[:timeframe]) redirect_to post, notice: "Done! 🎉 " end # => ArgumentError: Invalid timeframe: "now"