Adding decl auth to project ignores custom path separators in routing

38 views
Skip to first unread message

MattS

unread,
Jan 13, 2012, 8:02:35 PM1/13/12
to declarative_authorization
Hi all,
I'm using Rails 2.3.8 and declarative authorization gem 0.5.3 and ruby
1.9.2

I've been using declarative authorization for a year now and just have
jumped into an existing rails project. I've integrated declarative
authorization into it but it seems to insert itself into the routing
such that it ignores our custom path separators. We have a javascript
heavy UI that makes server calls to a controller with a date range
separated by semicolons, like this:

GET http://localhost:3000//schedule/2012-01-03;2012-01-26

To accommodate this change we simply added this line to the very
beginning of config/routes.rb before the map block

ActionController::Routing::SEPARATORS << ";" unless
ActionController::Routing::SEPARATORS.include?(";")

Obviously this adds the semicolon as a path separator.

However as soon as I add the decl auth gem to the project the routing
to the above URL no longer works. Somehow declarative authorization
appears to be expecting slashes instead of using the routing path
separators. Does anyone have any pointers on how to address this. I
didn't see anything like this in the group archives. I'm going to dig
into the gem code to see what is happening.

Any help is greatly appreciated. Thank you.
Matt

MattS

unread,
Jan 13, 2012, 9:38:40 PM1/13/12
to declarative_authorization
P.S. We're using this routing directive in the config.rb file, which
uses the semicolon separators

map.connect 'schedule/:start;:end', :controller =>
'Schedule', :action => 'view'

On Jan 13, 5:02 pm, MattS <matt.h...@gmail.com> wrote:
> Hi all,
> I'm using Rails 2.3.8 and declarative authorization gem 0.5.3 and ruby
> 1.9.2
>
> I've been using declarative authorization for a year now and just have
> jumped into an existing rails project. I've integrated declarative
> authorization into it but it seems to insert itself into the routing
> such that it ignores our custom path separators. We have a javascript
> heavy UI that makes server calls to a controller with a date range
> separated by semicolons, like this:
>
> GEThttp://localhost:3000//schedule/2012-01-03;2012-01-26

MattS

unread,
Jan 14, 2012, 7:06:42 PM1/14/12
to declarative_...@googlegroups.com
Ok, sort of figured it out. Or at least I have a workaround. I saw that gem adds its own routes for the rules browser. For some reason drawing those extra routes in there made the semicolon separated routes not be valid. I have no idea why. Once I commented out the rules browser paths in that file everything was ok. Since that's not a sustainable solution, the next thing I did was to create an initializer file that added the semicolon path separator like this:

ActionController::Routing::SEPARATORS <<  ";" unless ActionController::Routing::SEPARATORS.include?(";")

Once I put that code in there in addition to our config/routes.rb then it worked. I'm still not sure why the decl auth gem adding its own routes messed up our routing. What's even weirder is that "rake routes" still showed the routes in there but they weren't being used in the app. Any insight into this problem would be helpful since I'd like to get to the root cause of it. 

Thank you.
Matt
Reply all
Reply to author
Forward
0 new messages