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 8995675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:39:05+00:00 2026-06-15T23:39:05+00:00

I am trying to use the CLient Side Validation Gem in Rails. My forms

  • 0

I am trying to use the CLient Side Validation Gem in Rails. My forms work find until add the `:validate => true” to my form_for. Then I get an error telling me the way I have it written is wrong. I have tried reformatting it like the example and it just throws errors.

error

Using form_for(:name, @resource) is not supported with ClientSideValidations. Please use form_for(@resource, :as => :name) instead.

hashtag_controller

def home    
        @leaderboard = Hashtag.leaderboard_history
        @trends_display = Trend.trends_display
        @hash_create = ""
    end
    def create 
        @hash_create = Hashtag.create_hashtag(params[:hashtag])
        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

hashtag.rb

class Hashtag < ActiveRecord::Base

  attr_accessible :text, :profile_image_url, :from_user, :created_at, :tweet_id, :hashtag, :from_user_name, :view_count, :wins

  hashtag_regex = /^[A-Za-z\d=#...-]+$/i

  validates :hashtag, :format => { :with => hashtag_regex }, :length => { :within => 2..20 }                    


 class << self

def create_hashtag(hashtag)                #creates new tweetvstweet for inputed hashtag with # for guests
    dash = "#"
    @hashtag_scrubbed = [dash, hashtag].join.downcase
    (User.current_user ? User.current_user.twitter : Twitter).search("%#{@hashtag_scrubbed}", :lang => "en", :count => 100, :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



  def random_hashtags_pull                         #pulls 4 random hashtags for a vote first display
    Hashtag.where{ |hashtag| hashtag.hashtag =~ @hashtag_scrubbed}.order{"RANDOM()"}.limit(4).each(&:update_view_count)
  end

  def cast_vote_hashtag(hashtag)                    #pulls 4 random hashtags for a vote continued votes
    Hashtag.where{ |hashtag| hashtag.hashtag =~ @hashtag_scrubbed}.order{"RANDOM()"}.limit(4).each(&:update_view_count)
  end

  def leaderboard_history_current                  #displaying 5 highscore hashtags on the right
    Hashtag.where{ |hashtag| hashtag.hashtag =~ @hashtag_scrubbed}.order{"wins DESC"}.limit(5)  
  end

  def cast_vote(cast_vote)                           #counts number of wins
    Hashtag.increment_counter(:wins, cast_vote)
  end

  def leaderboard_history                            #right side leaderboard history
    Hashtag.order('wins DESC').limit(5)
  end
end

  def update_view_count                                  #updates the number of views
    Hashtag.increment_counter(:view_count, self.id)
    self.view_count += 1 
  end

home.html.erb

<div class="span6 votes-middle">
    <%= render 'shared/twitter_search' %>
    </div>

**search form**
<%= form_for(@hash_create, :url => hashtags_path, :validate => true, remote: true)  do |f| %>

                <div class="input-prepend input-append">
                <span class="add-on swag">#</span>
                <%= f.text_field :hashtag,class: "span4 swag_text_field", id:"appendedPrependedInput",  :validate => true, data: {autocomplete_source: autocomplete_index_path} %>

                <%= f.submit "VS!", class: "btn add-on-right swag_button" %>
                <% end %>
  • 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-15T23:39:06+00:00Added an answer on June 15, 2026 at 11:39 pm

    I think you should create a new object for the form

    Add @hash_create = HashTag.new in new action and change your form as

    form_for(@hash_create, :url => hashtags_path, :validate => true, remote: true)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use the jQuery validation plugin to add client side validation.
I'm trying to use MVC2 client-side validation in a partial view that is rendered
I am trying to use jquery to do a client side validation to do
I'm trying out ASP.NET MVC 2 Preview and when I use client side validation
I am trying to use client-side validation on a select element, but it's not
I'm trying to use the built in ASP.NET MVC 2 client side validation on
I am trying to use the Client-side Validation with jQuery in ASP.NET MVC (2).
Original Post: I am trying to use the Client-side Authentication with the Javascript SDK
I'm trying to use __doPostBack to pass some data from client to server side.
I'm trying to use asp.net mvc's 2 client validation ( <% Html.EnableClientValidation(); %>) with

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.