Ticket #149 (new enhancement)

Opened 8 months ago

Last modified 7 months ago

[PATCH] Funky Routes

Reported by: judofyr Owned by: somebody
Priority: trivial Milestone:
Component: camping.rb Version:
Keywords: Cc:

Description

Just making routes a little more DRY. Not important, but just a nice little feature. Even though we all have access to commit, I don't feel I have the right to do it. What is most important DRY or bytes?

Before:

class Post < R '/post'
...
class PostNew < R '/post/new'
...
class PostDelete < R '/post/delete'
...
class Testing < R '/post/delete/boh
...

After:

class Post < R '/post'
...
class PostNew < Post '/new'
...
class PostDelete < Post '/delete'
...
# It's recursive:
class Testing < PostDelete '/boh'
...

Attachments

funky.diff (0.7 kB) - added by judofyr 8 months ago.

Change History

Changed 8 months ago by judofyr

Changed 8 months ago by mdaines

AH, that's interesting. But if you call a controller "Post" then won't you have to say "Models::Post" or whatever in order to use the post model in the controller? I have this "solution", but it is not very good:

class Posts < R '/posts'
end

class PostsMember < Posts '/(\d+)'
end

and then maybe "NewPostsMember?"?

Changed 8 months ago by judofyr

Well, that isn't related to this patch, but don't take my example very serious. Just to show what it really does...

Changed 7 months ago by zimbatm

I don't think it brings much for the complexity overhead. Are there some other benefits than not repeating the prefix in the path ?

Note: See TracTickets for help on using tickets.