Forum: Ruby on Rails Newbie stuff: Adding a New Library Class

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Rajesh GS (Guest)
on 2006-03-27 14:08
(Received via mailing list)
Hi

I have been successful in playing around with model, views and
controllers in Rails. Along the way, I learnt that some of the reusable
stuff could be made library classes. I want to create a lib which will
render a form and form elements.

I created a class Mylib.rb in /lib folder.
The class tructure looks like this

class Mylib
    helper FormTagHelper

    attr_accessor :name, :range, :name, :category, :sort, :page,
:height, :width ...

    def initialize(name, options = {})
        @name = name
        @range = options[:range]
        @category = options[:category]
        ...
        ...
        ...
    end
    ....
    ....




When I run this code, I get two errors:

1. Symbol as array index
This is on the line @range = options[:range]

2. And further, I want to use form tag helpers in my class. I need to
use select_tag, options_for_select in the lib.  I am not sure how to do
this. Please, please  someone help me in the right direction.

Thanks

-R
This topic is locked and can not be replied to.