create custom html helpers in ruby on rails

To create a new helper:

  1. choose a name for the helper file, for instance tags_helper.rb
  2. create the file in the /app/helpers directory
  3. create a module according to the file name. In this case

    module TagsHelper
    end
    
  4. define your helper as method

    module TagsHelper
      def hello_world(name)
        "hello #{name}"
      end
    end
    

Now you can use the hello_world helper method in your view.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)