Use ActionView stuff inside controller action

Railsers:

I am too lazy to write an RHTML file. I just want to write an action,
and stuff a string. The string needs ActionView things inside it, like
this:

def lazy
render :text => stylesheet_link_tag(‘application’) + …
end

How do I get lines like that working?


Phlip
http://c2.com/cgi/wiki?ZeekLand ← NOT a blog!!

On 1/24/07, Phlip [email protected] wrote:

How do I get lines like that working?

render :text => response.template.link_to(‘STFW’,
http://google.com/’)

You could also use method_missing to automatically delegate to
‘response.template’:

def blah
render :text => link_to(‘STFW’, ‘http://google.com/’)
end
def method_missing(*args, &block)
response.template.send(*args, &block)
end

Lazy enough for you? :wink:

Dear Phlip,

I am too lazy to respond.

RSL

[Heh. I couldn’t resist. The devil made me do it.]

Russell N. wrote:

I am too lazy to respond.

That contradicts itself; you did respond.

The answers so far be…

  • render :inline => ‘…’
  • render :file => ‘…’
  • response.template.blah(), as George O. reports.


Phlip
http://c2.com/cgi/wiki?ZeekLand ← NOT a blog!!