Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

undefined method `raw' for controller for rails 4

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?

like image 614
kannathasan Avatar asked Oct 28 '13 11:10

kannathasan


2 Answers

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.

like image 157
Sahil Dhankhar Avatar answered Nov 09 '22 06:11

Sahil Dhankhar


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

like image 38
LHH Avatar answered Nov 09 '22 06:11

LHH