# Using dry monads mixins in Rails views

**URL:** <https://discourse.dry-rb.org/t/using-dry-monads-mixins-in-rails-views/1743>\
**Category:** Support\
**Created:** [October 25, 2023, 1:29am UTC](https://discourse.dry-rb.org/t/using-dry-monads-mixins-in-rails-views/1743 "2023-10-25T01:29:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DawidJanczak](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/dawidjanczak/32/261_2.png) [@DawidJanczak](https://discourse.dry-rb.org/u/DawidJanczak)\
**Post date:** [October 25, 2023, 1:29am UTC](https://discourse.dry-rb.org/t/using-dry-monads-mixins-in-rails-views/1743/1 "2023-10-25T01:29:31Z")

</div>

Hello,

I was wondering if it’s possible to just use `Failure()` in a Rails view and if so how to mix those modules in. Simply doing `include Dry::Monads[:result]` in the controller works for the code inside controller actions, but doesn’t seem to cascade in any way to the views. I’m getting a

```auto
NameError - uninitialized constant #<Class:0x00007f46c356cac8>::Failure:

```

failure if I do that.

---

<div class="post-metadata">

**Author:** ![alassek](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/alassek/32/314_2.png) [@alassek](https://discourse.dry-rb.org/u/alassek)\
**Post date:** [October 25, 2023, 4:04pm UTC](https://discourse.dry-rb.org/t/using-dry-monads-mixins-in-rails-views/1743/2 "2023-10-25T16:04:27Z")

</div>

I create a shortcut constant for these situations. `T` is my `Types` shortcut, `M` is my `Dry::Monads` shortcut. You could just reference `M::Failure()` as you would with the mixin method.

Side note: as I mentioned [elsewhere](https://discourse.dry-rb.org/t/conflit-using-dry-monads-and-view-component/1728/3), I don’t think using Monads in view logic is a good idea for the same reasons why using branching logic is a bad idea.
