inossidabile / heimdallr-resource Goto Github PK
View Code? Open in Web Editor NEWDeprecated in favor of Protector::CanCan
Home Page: https://github.com/inossidabile/protector-cancan
License: Other
Deprecated in favor of Protector::CanCan
Home Page: https://github.com/inossidabile/protector-cancan
License: Other
I would like to have a base controller from which other controllers inherit. This base controller would use the Heimdallr::Resource mixin.
The current implementation prevents this as class_name
will be set based on the base controllers name. CanCan gets around this by using params[:controller] instead of the class name. An alternative implementation could use the Class inherited hook to change the resource name in any subclasses.
Hello! I created a new application with a scaffolded controller Users (and model User, of course).
routes.rb:
resources :users
Gemfile:
...
gem 'heimdallr'
gem 'heimdallr-resource'
users_controller.rb:
class UsersController < ApplicationController
include Heimdallr::Resource
load_and_authorize_resource
...
But when I run this and go to http://localhost:3000/users/, I got an error:
Routing Error
uninitialized constant Heimdallr::Resource
Try running rake routes for more information on available routes.
and then, after page refreshing by F5:
NoMethodError in Users#index
Showing D:/Dev/Projects/zzz/app/views/users/index.html.erb where line #10 raised:
undefined method `each' for nil:NilClass
Extracted source (around line #10):
7: <th></th>
8: </tr>
9:
10: <% @users.each do |user| %>
11: <tr>
12: <td><%= link_to 'Show', user %></td>
13: <td><%= link_to 'Edit', edit_user_path(user) %></td>
P.S. Rails version 3.2.7, but also tried 3.2.5, 3.2.3 - same result.
Thanks in advance!
ResourceImplementation#authorize_resource
requires that resource
passed to it has been restricted. ResourceImplementation#load_resource
does that, but only if the resource has not been loaded manually before controller's load_and_authorize_resource
is called, in which case it does nothing and authorize_resource
can fail if it receives nil
or an unrestricted resource.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.