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

Incomplete guide share code of views #419

Open
ippachi opened this issue Dec 4, 2017 · 0 comments
Open

Incomplete guide share code of views #419

ippachi opened this issue Dec 4, 2017 · 0 comments

Comments

@ippachi
Copy link

ippachi commented Dec 4, 2017

I wrote this code my application and I run the bundle exec hanami s
so I got message uninitialized constant Web .
I think Web is not initialized when accept_json.rb is loaded.

Below codes work well.

# apps/web/views/accept_json.rb
module Web
  module Views
    module AcceptJson
      def self.included(view)
        view.class_eval do
          format :json
        end
      end
    end
  end
end

or

# apps/web/application.rb
module Web
  class Application < Hanami::Application
    configure do
      # ...
      view.prepare do
        require_relative './views/accept_json'
        include Web::Views::AcceptJson
      end
    end
  end
end
@ippachi ippachi changed the title Incomplete guide shared of views Incomplete guide share code of views Dec 4, 2017
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

No branches or pull requests

1 participant