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

  • Home
  • SEARCH
  • 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 8999683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:12:45+00:00 2026-06-16T00:12:45+00:00

So I am trying to validate my passed through param before creating a record.

  • 0

So I am trying to validate my passed through param before creating a record. I am attempting this in the model.

Model

 def self.create_hashtag_signed_in(hashtag)
  hashtag _regex = /[A-Za-z][A-Za-z0-9]*(?:_[A-Za-z0-9]+)*$/i

  validates hashtag :presence   => true,
                    :format     => { :with => hashtag_regex },
                    :uniqueness => { :case_sensitive => false }    

  dash = "#"
  # @view_count_init = "0"
  @hashtag_scrubbed = [dash, hashtag].join
  User.current_user.twitter.search("%#{@hashtag_scrubbed}", :lang => "en", :count => 20, :result_type => "mixed").results.map do |tweet|
    unless exists?(tweet_id: tweet.id)
        create!(
            tweet_id: tweet.id,
            text: tweet.text,
            profile_image_url: tweet.user.profile_image_url,
            from_user: tweet.from_user,
        from_user_name: tweet.user.name, 
            created_at: tweet.created_at,
        hashtag: @hashtag_scrubbed,
        view_count: "0",
        wins: "0"
          ) 
        end     
    end
  end

controller

def create 
            @stats_total = Hashtag.count 
    @stats_wins = Hashtag.sum(:wins)
    @stats_views = Hashtag.sum(:view_count)

    @stats_losers = (@stats_views - @stats_wins) 
        @vote_history = Hashlog.vote_history
        if signed_in?
            Hashtag.create_hashtag_signed_in(params[:hashtag])
        else
            Hashtag.create_hashtag_guest(params[:hashtag])
        end
        Hashlog.create_hashlog(params[:hashtag])
        @random_hashtag_pull = Hashtag.random_hashtags_pull
        @leaderboard = Hashtag.leaderboard_history_current
        respond_to do |format|
        format.html { redirect_to root_path }
        format.js
    end
     end

It is throwing the error

Started GET "/" for 127.0.0.1 at 2012-12-11 23:52:57 -0800

NoMethodError (undefined method `key?' for nil:NilClass):

Then if it throws the no presence I want to be able to return it to the via jQuery how the submission works.

Changing to :hashtag error

/Users/user/Development/tweetvstweet/app/models/hashtag.rb:34: syntax error, unexpected ':', expecting keyword_end
validates :hashtag :presence => true, 
                    ^
/Users/user/Development/tweetvstweet/app/models/hashtag.rb:34: Can't assign to true
validates :hashtag :presence => true, 
                                     ^
/Users/user/Development/tweetvstweet/app/models/hashtag.rb:35: syntax error, unexpected tASSOC, expecting tCOLON2 or '[' or '.'
          :format => { :with => hashtag_regex }, 
                    ^
/Users/user/Development/tweetvstweet/app/models/hashtag.rb:35: syntax error, unexpected ',', expecting keyword_end
          :format => { :with => hashtag_regex }, 
                                                ^
  • 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-16T00:12:45+00:00Added an answer on June 16, 2026 at 12:12 am

    In your model add like this and then try may be it will works

      def self.create_hashtag_signed_in(hashtag_value)
         hashtag _regex = /[A-Za-z][A-Za-z0-9]*(?:_[A-Za-z0-9]+)*$/i
    
         validates :hashtag , :presence   => true,
                      :format     => { :with => hashtag_regex },
                      :uniqueness => { :case_sensitive => false }    
    
    dash = "#"
    # @view_count_init = "0"
    @hashtag_scrubbed = [dash, hashtag_value].join
    User.current_user.twitter.search("%#{@hashtag_scrubbed}", :lang => "en", :count => 20, :result_type => "mixed").results.map do |tweet|
      unless exists?(tweet_id: tweet.id)
          self.create!(
              tweet_id: tweet.id,
              text: tweet.text,
              profile_image_url: tweet.user.profile_image_url,
              from_user: tweet.from_user,
          from_user_name: tweet.user.name, 
              created_at: tweet.created_at,
          hashtag: @hashtag_scrubbed,
          view_count: "0",
          wins: "0"
            ) 
       end     
     end
    

    end

    Try may be…..

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

Sidebar

Related Questions

I'm trying to validate an ID. I have this class called ManejadorTickets in which
I'm trying to parse instructions passed in. I want to use regex to validate
I have a form within a modal that i am trying to validate before
I'm trying to create a method that will custom validate any TextBox control passed
I've been trying to validate my passed options with boost::program_options. My command has several
I'm trying to validate a number by it's length. This number has to have
When trying to validate my site, I get the following error: Line 188, column
While trying to validate my forms i get the following error: Expected a {
While trying to validate form data on my page i get the following error:
I am trying to validate the entry in a cell based on the contents

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.