开发者

rails 3 is printing html tags to screen instead of rendering them

I'm using vhochstein's fork of active_scaffold, which runs quite nicely on rails 3, except for a few small bugs - http://github.com/vhochstein/active_scaffold.

In rails 2.3, the following code disables a link:

return "<a class='disabled'>#{text}</a>" unless authorized

But in Rails 3, it causes the escaped html tags to be printed out instead as in the following photo:

rails 3 is printing html tags to screen instead of rendering them

How can I make the content of this return statement render the way it should in rails 3?

The code above, is from the list_column_helpers.rb file in vendor/plugins/active_scaffold/helpers/

UPDATE:

Floatless fixed this by suggesting to add .html_safe to the code.

I have since found that the folowing change also needs to be made as there's more than one bit of code that is respondible for disabling action links in active_Scaffold:

In /plugins/active_scaffold/frontends/default/views/_list_actions.html.er开发者_如何学Cb change:

<%= record.authorized_for?(:crud_type => etc etc etc -%>

By making it use "raw"

i.e. 

<%= raw record.authorized_for?(:crud_type => etc etc etc -%>

Anyway, thanks to floatless and hopefully mr hochstein will be able to use this stuff.


Try this:

return "<a class='disabled'>#{text}</a>".html_safe unless authorized
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜