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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:42:53+00:00 2026-05-26T00:42:53+00:00

In my application, any time there is a form, I call two helper methods

  • 0

In my application, any time there is a form, I call two helper methods to inject some javascript into the head of the web page. One method injects code to focus on the first input of the form and the second method hooks up some call backs that I use with the client_side_validation gem.

I will be calling these two methods on any page that has a form_for in the view. Is there a way to automatically invoke these methods any time form_for is called as opposed to adding the calls to my template files?

Using Rails 3.1.

  • 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-05-26T00:42:53+00:00Added an answer on May 26, 2026 at 12:42 am

    You should wrap form_for with your own method that calls your helpers. Fortunately Rails provides an easy way of doing this in the form of alias_method_chain.

    module ActionView::Helpers::FormHelper
      def form_for_with_my_helpers (*args)
        my_helpers
        form_for_without_my_helpers (*args)
      end
      alias_method_chain :form_for :my_helpers
    end
    

    You can now call form_for_without_my_helpers with the normal form_for arguments if you don’t want a form to use your helpers.

    This can go somewhere that’s in the load path. Or you can require the file holding this code.

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

Sidebar

Related Questions

Time ago I created an application which has some buttons in the form. Now
In Delphi 2009 I'm finding that any time I use TThread.CurrentThread in an application,
Do any of you know an API or application which can handle real time
For some time now when I am debugging Visual C++ applications and viewing any
Is there any application that will read a MySQL database table and generate a
There's Quicktime SDK for Windows, but any application that uses it needs quicktime runtime
I'm having a very hard time dealing with multipart/form-data requests with my java application
I have a cakephp application, and in the add.ctp view there is a date-time
If there are hundreds of form and 20-30 projects in the application and during
Imagine a web form with a set of check boxes (any or all of

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.