10

Currently, I am upgrading my application from rails 3.2 to rails 4. When I navigate to a particular tab, I get the following error:

undefined method `raw' for #<LeaseController:0x00000006935e30>

My code:

        vacant.tenant = raw("Vacant")
        vacant.lease_start_date = raw("&nbsp;")
        vacant.rent_end = raw("&nbsp;")
        vacant.base_rent_monthly_amount = raw("")
        vacant.base_rent_annual_psf = raw("")
        vacant.options = raw("")
        vacant.security_deposit_amount = raw("")
        vacant.tis_amount = raw("")
        vacant.lcs_amount =raw("")

Why is this method now undefined?

carols10cents
  • 6,943
  • 7
  • 39
  • 56
kannathasan
  • 565
  • 7
  • 21

2 Answers2

13

This helper is depreceted. http://apidock.com/rails/ActionView/Helpers/RawOutputHelper

If you still want to use raw , try including

include ActionView::Helpers::OutputSafetyHelper

into your controller.

In rails 4 raw method is provided by ActionView::Helpers::OutputSafetyHelper

You can check out its documentation at:

http://api.rubyonrails.org/classes/ActionView/Helpers/OutputSafetyHelper.html

But most importantly this code belongs to view helpers, not controller.

Sahil Dhankhar
  • 3,596
  • 2
  • 31
  • 44
4

You can use html_safe in your controller. like this string.html_safe

LHH
  • 3,233
  • 1
  • 20
  • 27