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

Fix rails console invocation inside a Rails app #185

Merged
merged 1 commit into from
Jan 28, 2016

Conversation

gsamokovarov
Copy link
Collaborator

Railties can hook themselves into the rails console with:

class Railtie < ::Rails::Railtie
  console do
    # Do something here.
  end
end

Now, since I introduced the #console method in Kernel, every object
responded to it, so this block was tried to be run on railties that
respond to it.

Marking the #console method explicitly as module_function
solves this problem as it makes it private and the #respond_to?
calls during the railties initialization no longer lie.

Fixes #184.

Railties can hook themselves into the `rails console` with:

```ruby
class Railtie < ::Rails::Railtie
  console do
    # Do something here.
  end
end
```

Now, since I introduced the `#console` method in `Kernel`, every object
responded to it, so this block was tried to be run on railties that
respond to it.

Marking the `#console` method _explicitly_ as `module_function`
solves this problem as it makes it `private` and the `#respond_to?`
calls during the railties initialization no longer lie.

Fixes #184.
@Eric-Guo
Copy link

Thanks so quick fix, confirm works.

@gsamokovarov
Copy link
Collaborator Author

Thank you @Eric-Guo and all the folks over #184 for the investigation!

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