Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Super block yield #207

Merged
merged 2 commits into from
Apr 9, 2015
Merged

Conversation

sgwilym
Copy link
Contributor

@sgwilym sgwilym commented Apr 9, 2015

I often find myself wanting to make small additions to the RegistrationsController (such as adding a role to a just-created User), but find overriding the entire controller a little bit overkill when I simply want to add behaviour.

In vanilla Devise you can make a controller that inherits from RegistrationsController, override the method and simply pass a block to super like this:

def create
  super do |resource|
    resource.add_role :cool_user
  end
end

Which I think is ideal for small additions like these. This PR implements block yielding in RegistrationsController (and though it could easily be extended to the other controllers, I thought I'd see what you make of this before going the whole hog on this).

And sorry if the tests are a little gross looking — I'm used to Rspec!

sgwilym added 2 commits April 9, 2015 15:25
Allows you to make super simple additions to the
RegistrationsController without having to reimplement entire pieces of
functionality by passing a block to super.
@lynndylanhurley
Copy link
Owner

Fantastic PR @sgwilym! The tests look great!

| think this is definitely an improvement. Would you be interested in extending this behavior to the other controllers as well?

lynndylanhurley added a commit that referenced this pull request Apr 9, 2015
@lynndylanhurley lynndylanhurley merged commit f296406 into lynndylanhurley:master Apr 9, 2015
@sgwilym
Copy link
Contributor Author

sgwilym commented Apr 9, 2015

Thanks! 😄 And sure thing. I'll scrape a little time together soon to get all the controllers all blocked up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants