rubyservices/restful_json — pull request #3 by mattrw89 (2013-04-24 02:13:14+00:00)
Title: Allow controllers to be at a folder depth greater than 1

Gary,

I found my problem with getting nil back from 'permitted_params'...

It turned out that the old code:
```ruby
permitter_class_arr = ["#{self.class.to_s.match(/(.+)Controller/)[1].singularize}Permitter"]
if self.class.to_s['::']
permitter_class_arr << "#{self.class.to_s.match(/(.*?::)?(?.+)Controller/)[:controller_name].singularize}Permitter"
```

Would only work for controllers at this folder depth: Api::TestController
For the example above you get: permitter_class_arr = ['Api::TestPermitter','TestPermitter']

So, what would happen with my actual class definition is this:
Class name: Api::V1::TestController
permitter_class_arr = ['Api::V1::TestPermitter','V1::TestPermitter']

Which is why, even though the permitters auto-loaded into my rails environment, the TestPermitter class could not be found.

My added couple lines of code somewhat recursively checks for '::', which should allow for controller classes even like this: 'Api::V1::Something::SomethingElse::ControllerName.

```ruby
while true do
permitter_class_arr << "#{permitter_class_arr.last.match(/(.*?::)?(?.+)Permitter/)[:controller_name].singularize}Permitter"
break if !permitter_class_arr[-1].include? '::'
end
```