Ruby on rails 如何在Rails中查看网页的操作?
在Ruby on rails 如何在Rails中查看网页的操作?,ruby-on-rails,ruby-on-rails-3,ruby-on-rails-3.2,action,erb,Ruby On Rails,Ruby On Rails 3,Ruby On Rails 3.2,Action,Erb,在.html.erb文件中是否有可以查找的字段或方法,可以告诉我当前用于呈现页面的操作?这段代码将是部分的。我在找这样的东西: <% if @action == :new %> this is new <% end %> 这是新的 是的,为此,您有动作名称和控制器名称 但请注意:结果是字符串,而不是符号 请参阅。您可以这样做 <% if params[:action] == "new" %> # do something here <% e
.html.erb
文件中是否有可以查找的字段或方法,可以告诉我当前用于呈现页面的操作?这段代码将是部分的。我在找这样的东西:
<% if @action == :new %>
this is new
<% end %>
这是新的
是的,为此,您有动作名称
和控制器名称
但请注意:结果是字符串,而不是符号
请参阅。您可以这样做
<% if params[:action] == "new" %>
# do something here
<% end %>
#在这里做点什么