Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bumi/nestedutils
Some lovely utils to work with nested resources
https://github.com/bumi/nestedutils
Last synced: 4 days ago
JSON representation
Some lovely utils to work with nested resources
- Host: GitHub
- URL: https://github.com/bumi/nestedutils
- Owner: bumi
- Created: 2008-07-31T11:26:45.000Z (over 16 years ago)
- Default Branch: master
- Last Pushed: 2009-12-06T19:24:59.000Z (almost 15 years ago)
- Last Synced: 2023-04-10T23:12:54.796Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 78.1 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.txt
Awesome Lists containing this project
README
NESTED UTILS
===============Easy handling of nested resources with support for custom domains.
requires find_by_param plugin: http://github.com/bumi/find_by_param
[insert README here] ;)If you have questions: [email protected]
EXAMPLE:
===============class ApplicationController < ActionController::Base
include Railslove::Routes::NestedUtils
helper_method :polymorphic_object_url,:polymorphic_object, :endmost_index_url, :current_url, :new_current_url, :edit_current_url, :scoped_url_for, :normalized_request_uri,
before_filter :get_request_uri
endURL: /posts/bumi/comments
> polymorphic_object # => Post.find_by_param("bumi")
> polymorphic_object! # => Post.find_by_param!("bumi") (raises an error if not found)URL: /posts/bumi/comments/1/pictures/3
> polymorphic_object # => Picture.find_by_param(3)
> polymorphic_object(2) # => Comment.find_by_param(1)
> polymorphic_object(3) # => Post.find_by_param("bumi")> current_url # => generated with post_comment_picture_url(...) - /posts/bumi/comments/1/pictures/3
> init_polymorphic_variables # => sets @post, @comment and @picture - you can call this in a before_filter to set all instance variables of nested objects
> endmost_index_url# => /posts/bumi/comments/1/pictures
URL: /posts/bumi
> scoped_url_for(@comment) # => /posts/bumi/comments/25
NOTE if you use custom verbs on your resources add something like this to your application.rb
def verbs_to_ignore
%w{new edit activate}
endMichael Bumann - Railslove.com