@routes = [
base.get("/#{plural}(.:format)")
.to("#{controller}.index")
.as(
if base.collection || base.member
nomenclate base.route_name, plural
else
nomenclate plural
)
base.post("/#{plural}(.:format)")
.to("#{controller}.create")
base.get("/#{plural}/add(.:format)")
.to("#{controller}.add")
.as(
if base.collection || base.member
nomenclate 'add', base.route_name, singular
else
nomenclate 'add', singular
)
base.get("/#{plural}/:id(.:format)")
.to("#{controller}.show")
.as(
if base.collection || base.member
nomenclate base.route_name, singular
else
nomenclate singular
)
base.get("/#{plural}/:id/edit(.:format)")
.to("#{controller}.edit")
.as(
if base.collection || base.member
nomenclate 'edit', base.route_name, singular
else
nomenclate 'edit', singular
)
base.put("/#{plural}/:id(.:format)")
.to("#{controller}.update")
base.del("/#{plural}/:id(.:format)")
.to("#{controller}.destroy")
]
@collection_route = @routes[0]
@member_route = @routes[3]
@collection_route.collection = true
@member_route.member = true
this
where: ( conditions )->
if kindof(conditions) != 'object'
throw new Error 'conditions must be an object'