【发布时间】:2014-02-07 18:25:25
【问题描述】:
我有一个控制器,其中包含许多路由到不同页面的操作
def act1
@a=...
@b=....
@c=...
end
def act1
@a=...
@b=....
@c=...
end
def act2_ajax
@a=...
@b=....
@c=...
end
def act3
@a=...
@b=....
@c=...
end
def act4_ajax
@a=...
@b=....
@c=...
end
我想在一个单独的动作中编写这些变量并只调用动作名称,我在视图中使用了变量@a,@b @c,所以如果我调用一个单独的动作,这些变量应该会出现
例如,假设我们写了
def common(xx)
@a=...
@b=...
@c=...
end
我们在act1中调用common like
def act1
self.common1(var)
end
哪个输出像
def act1
@a=...
@b=...
@c=...
end
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-3 coding-style