Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Type of Rails.application should be YourApp::Application #98

Open
bradleybuda opened this issue Jul 25, 2019 · 1 comment
Open

Type of Rails.application should be YourApp::Application #98

bradleybuda opened this issue Jul 25, 2019 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@bradleybuda
Copy link

Moved from: sorbet/sorbet-typed#83

Describe the bug:
In a Rails application the type of Rails.application is actually a subclass of Rails::Application that is generated when you type rails new. For example, rails new blog, Rails.application will create a class called Blog::Application defined in config/application.rb.

I am willing to make an attempt at fixing this if you think it's a valid change - let me know then I'll send a PR.

Steps to reproduce:

The impact of this is that any custom methods you define in application.rb on Blog::Application will not be visible to the type checker. If I have config/application.rb that looks like this:

# typed: true
require_relative 'boot'
require 'rails'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module Blog
  class Application < Rails::Application
    # Initialize configuration defaults for originally generated Rails version.
    config.load_defaults 5.2

    def name
      "Brad's awesome blog"
    end
  end
end

then I can't call Rails.application.name in a type-safe way.

Versions:

$ ruby --version
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]

$ rails --version
Rails 5.2.1

$ srb --version
Sorbet typechecker 0.4.4429 git 51504253c985d0a967d3df6a39ac44b25db2c481 built on 2019-07-12 00:02:11 GMT with debug symbols
@bradleybuda bradleybuda added the bug Something isn't working label Jul 25, 2019
@hdoan741
Copy link
Contributor

hdoan741 commented Jul 25, 2019 via email

@hdoan741 hdoan741 added enhancement New feature or request and removed bug Something isn't working labels Jul 26, 2019
@hdoan741 hdoan741 added the good first issue Good for newcomers label Jan 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants