开发者

Problems with gem

开发者 https://www.devze.com 2023-03-25 15:08 出处:网络
I have a gem I would like to make.It is suppose to make it easier to make a dynamic form in a controller by allowing you to do this:

I have a gem I would like to make. It is suppose to make it easier to make a dynamic form in a controller by allowing you to do this:

@actionMenuItems = ActionMenuItem.new("Link Name", url_path)

and I have this in my gem in lib/dynamic_form.rb:

 module dynamicMenu

 class ActionMenuItem
   attr_accessor :name, :link

   def initialize(name, link)
     @name = name
     @link = link
  end

 end

end

However when I try to add this gem into my application I get:

开发者_如何转开发

uninitialized constant UsersController::ActionMenuItem

this is the first gem I have ever made so help would be appreciated.


I believe the problem is with namespacing. The ActionMenuItem is contained within dynamicMenu module, so the proper way to refer to it would be dynamicMenu::ActionMenuItem.

0

精彩评论

暂无评论...
验证码 换一张
取 消