Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cancan
Manage
Activity
Members
Plan
External wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Github Mirror
coopdevs
cancan
Commits
d5baed62
Commit
d5baed62
authored
13 years ago
by
Mark Sim
Committed by
Anuj Dutta
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fixes Nested Resource Loading
parent
7bf683d8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/cancan/controller_resource.rb
+5
-1
5 additions, 1 deletion
lib/cancan/controller_resource.rb
spec/cancan/controller_resource_spec.rb
+8
-0
8 additions, 0 deletions
spec/cancan/controller_resource_spec.rb
with
13 additions
and
1 deletion
lib/cancan/controller_resource.rb
+
5
−
1
View file @
d5baed62
...
...
@@ -215,8 +215,12 @@ module CanCan
end
end
def
namespace
@params
[
:controller
].
split
(
"::"
)[
0
..-
2
]
end
def
namespaced_name
@
name
||
@params
[
:controller
].
sub
(
"Controller"
,
""
).
singularize
.
camelize
.
constantize
[
name
space
,
name
.
camelize
].
join
(
'::'
).
singularize
.
camelize
.
constantize
rescue
NameError
name
end
...
...
This diff is collapsed.
Click to expand it.
spec/cancan/controller_resource_spec.rb
+
8
−
0
View file @
d5baed62
...
...
@@ -215,6 +215,14 @@ describe CanCan::ControllerResource do
resource
.
should_not
be_parent
end
it
"should have the specified resource_class if 'name' is passed to load_resource"
do
class
Section
end
resource
=
CanCan
::
ControllerResource
.
new
(
@controller
,
:section
)
resource
.
send
(
:resource_class
).
should
==
Section
end
it
"should load parent resource through proper id parameter"
do
project
=
Project
.
create!
@params
.
merge!
(
:controller
=>
"categories"
,
:action
=>
"index"
,
:project_id
=>
project
.
id
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment