Name of action inside template


#1

Hi all,

How do I know the name of the action currently invoked inside RHTML
template?
I need to make a text_field readonly when the action is ‘edit’ and
readwrite when the action is ‘new’.

Tq,
John


#2

Hi John,

John I. wrote:

How do I know the name of the action currently invoked inside RHTML
template? I need to make a text_field readonly when the action is ‘edit’
and readwrite when the action is ‘new’.

I may be completely misunderstanding your question, but…

In Rails, you will have a seperate view (RHTML template) for each
controller
action. So you’ll have a ‘new.rhtml’ and an ‘edit.rhtml’ and you’ll
just
include a contentEditable=false attribute on the field in your
‘edit.rhtml’.

hth,
Bill


#3

John I. wrote:

How do I know the name of the action currently invoked inside RHTML
template?
I need to make a text_field readonly when the action is ‘edit’ and
readwrite when the action is ‘new’.

<% if controller.action_name == ‘edit’ -%>

etc.

Ray


#4

Ray B. wrote:

<% if controller.action_name == ‘edit’ -%>

Thanks Ray!
Another way I managed to find myself is:
<% if params[:action] == ‘edit’ -%>

Ray

John