Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using irwi as a nested resource #9

Closed
ninadpachpute opened this issue Aug 14, 2010 · 2 comments
Closed

Using irwi as a nested resource #9

ninadpachpute opened this issue Aug 14, 2010 · 2 comments

Comments

@ninadpachpute
Copy link

Hi,

I have a project-management app build and would like to have a wiki for every project. In other words, I would like to have wiki resource nested inside project resource.

Can I use irwi and how?

Thanks in advance.

@alno
Copy link
Owner

alno commented Aug 29, 2010

Hi! There is no built-in support for now, but there are three steps which should be sufficient:

  • When defining routes you should use appropriate wiki root parameter, for example /projects/:project_id/wiki if you want per-project wiki.

  • In your wiki page model define class method, which find or create page by resource and path, for example:

    def find_by_project_id_and_path_or_new( project_id, path )
    self.find_by_project_id_and_path( project_id, path ) || self.new( :project_id => project_id, :path => path, :title => path )
    end

  • In your wiki controller define method @setup_page@, which select page by upper method:

    def setup_page
    @page = page_class.find_by_project_id_and_path_or_new( params[:path].join('/') ) # Find existing page by path or create new
    end

And that should be all you need to get per-resource wiki.

@ninadpachpute
Copy link
Author

Thanks!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants