Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8529429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:02:09+00:00 2026-06-11T09:02:09+00:00

I m in a situation where i need to convert an Object to string

  • 0

I m in a situation where i need to convert an Object to string so that i can check for Invalid characters/HTML in any filed of that object.

Here is my function for spam check

def seems_spam?(str)
   flag = str.match(/<.*>/m) || str.match(/http/) || str.match(/href=/)
   Rails.logger.info "** was spam #{flag}"
   flag
end

This method use a string and look for wrong data but i don’t know how to convert an object to string and pass to this method. I tried this

@request = Request
spam = seems_spam?(@request.to_s)

Please guide

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:02:10+00:00Added an answer on June 11, 2026 at 9:02 am

    You could try @request.inspect

    That will show fields that are publicly accessible

    Edit: So are you trying to validate each field on the object?

    If so, you could get a hash of field and value pairs and pass each one to your method.

    @request.instance_values.each do |field, val|
      if seems_spam? val
      # handle spam
    end
    

    If you’re asking about implementing a to_s method, Eugene has answered it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are some situation that I need to convert string to float or some
I am in a situation that needs be solve with this way; need convert
My situation is that I have to convert an HTML form into a Flex
I have an situation where i need to convert Doc file into PDF file.
I have a situation in which I need to convert a text data into
Situation: I need to make an imap client (using java mail api) that if,
There has been times where I need to convert an old HTML structure to
I would like to convert the object to string and Vice Versa process. The
The situation: I need to convert our current development environment from Windows XP 32-bit to
I have a situation where I need to convert a binary value to hex

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.