W/ the help of someone in IRC (<tbuehlmann>), i did it like this...
I put this in my main Gem
module DevapeMemberNavigation
mattr_accessor :items
self.items = []
module Hooks
def register_navigation_item(item)
DevapeMemberNavigation.items << item
end
end
end
module DevapeCms
extend DevapeMemberNavigation::Hooks
end
DevapeCms.register_navigation_item(''/member/posts'')
In another Gem, I wrote
require "devape_cms"
module DevapeSurvey
extend DevapeMemberNavigation::Hooks
end
DevapeSurvey.register_navigation_item(''/member/surveys'')
Then, in my main app, this will return the desired array
<%DevapeMemberNavigation.items %>
On Aug 7, 4:51 pm, jdkealy
<jdke...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi,
>
> I''m looking to do something though I''m not quite sure how
to phrase
> it. What I''m looking to do is, essentially, make custom hooks
using
> plugins/engines/gems.
>
> My use case is a member dashboard:
>
> I have a view partial for my site and a number of gems that I wrote
> installed. Each gem correlates to something a member can manage, like
> a photo gallery, their profile, their friends, etc.
>
> Now, I know I could open up my view partial and code links to each one
> of these things, eg:
>
> <a href="/members/manage/photos">Manage Photos</a>
>
> But, I was hoping for something slightly more modular, and was hoping
> I could figure out some way to hook these links in dynamically when I
> install my gem and or run my generators.
>
> In other CMS'' I have used, this was possible. Wordpress for
example
> had a hook, and Magento had an XML based admin navigation when the
> links to manage your account were dynamically populated.
>
> What would be a way to go about this in Rails? I''ve thought of
making
> a db table and writing to it with seeds when I run each gem''s
> generators. But I was hoping something simpler. Is there some way I
> could essentially get a collection from my gems'' lib files?
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.