Giter Site home page Giter Site logo

heimdallr-resource's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

heimdallr-resource's Issues

Support controller inheritance

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.

Not working at all

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!

authorize_resource can fail if the resource was loaded manually beforehand

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.