Questions tagged «actionview»


4
Rails:分部应该知道实例变量吗?
例如,瑞安·贝茨(Ryan Bates)的nifty_scaffolding edit.html.erb <%= render :partial => 'form' %> new.html.erb <%= render :partial => 'form' %> _form.html.erb <%= form_for @some_object_defined_in_action %> 这种隐藏状态使我感到不舒服,所以我通常喜欢这样做 edit.html.erb <%= render :partial => 'form', :locals => { :object => @my_object } %> _form.html.erb <%= form_for object %> 那么哪个更好:a)使局部变量访问实例变量,或者b)传递局部变量所需的所有变量? 到目前为止,我一直在选择b),但确实遇到了一些泡菜: some_action.html.erb <% @dad.sons.each do |a_son| %> <%= …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.