# Share code for View is not working

**URL:** <https://discourse.hanakai.org/t/share-code-for-view-is-not-working/836>\
**Category:** questions\
**Created:** [May 10, 2023, 4:07am UTC](https://discourse.hanakai.org/t/share-code-for-view-is-not-working/836 "2023-05-10T04:07:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebastjan\_hribar](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/sebastjan_hribar/32/323_2.png) [@sebastjan\_hribar](https://discourse.hanakai.org/u/sebastjan_hribar)\
**Post date:** [May 10, 2023, 4:07am UTC](https://discourse.hanakai.org/t/share-code-for-view-is-not-working/836/1 "2023-05-10T04:07:26Z")

</div>

Hi,

I have a share code module in `lib/tmsr/addons/tsr_helpers.rb`, required in `config/environment.rb` and included in `apps/myapp/application.rb`as follows:

```auto
controller.prepare do
        include Hanami::TsrHelpers
        # include MyAuthentication # included in all the actions
        # before :authenticate! # run an authentication before callback
      end

      # Configure the code that will yield each time Monocular::View is included
      # This is useful for sharing common functionality
      #
      # See: http://www.rubydoc.info/gems/hanami-view#Configuration
      view.prepare do
        include Hanami::TsrHelpers
      end

```

This is working for the controller, but when I try to use it in a view I get this error: `undefined local variable or method `get\_current\_decimal\_separator’ for Myapp::Views::Qareports::Show:Class`.

Why is it blowing up?

---

<div class="post-metadata">

**Author:** ![sebastjan\_hribar](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/sebastjan_hribar/32/323_2.png) [@sebastjan\_hribar](https://discourse.hanakai.org/u/sebastjan_hribar)\
**Post date:** [May 10, 2023, 4:22am UTC](https://discourse.hanakai.org/t/share-code-for-view-is-not-working/836/2 "2023-05-10T04:22:13Z")

</div>

`puts Monocular::Views::Qareports::Show.ancestors` in the affected view gives me this, so the module is included:

```auto
#<Module:0x00005629ebed6820>
Myapp::Views::Qareports::Show
Hanami::TsrHelpers
Hanami::Assets::Helpers
Hanami::Helpers::NumberFormattingHelper
Hanami::Helpers::FormHelper
Hanami::Helpers::LinkToHelper
Hanami::Helpers::RoutingHelper
Hanami::Helpers::EscapeHelper
Hanami::Helpers::HtmlHelper
Hanami::Helpers
GetUser
Hanami::View::Escape::InstanceMethods
Hanami::View::Rendering::InstanceMethods
Myapp::View
Hanami::Utils::ClassAttribute
Object
PP::ObjectMixin
RequireAll
JSON::Ext::Generator::GeneratorMethods::Object
Kernel
BasicObject

```
