f.label在rails生产服务器中不起作用

时间:2013-06-05 05:40:29

标签: ruby-on-rails ruby-on-rails-3 amazon-web-services label production

 ActionView::Template::Error (wrong number of arguments (5 for 3)):
14:       <div class="form-inline loginsubmit">
15:         <%= f.submit "Sign in" ,:class =>"actionbtn login-load"%>
16:         <% if devise_mapping.rememberable? -%>
17:         <%= f.check_box :remember_me %> 
18:         <%= f.label :remember_me %>
19:         <% end %>
20:       </div>
21:
app/views/users/sessions/new.html.erb:18:in `block in_app_views_users_sessions_new_html_erb__321696909397072435_46750480'
app/views/users/sessions/new.html.erb:9:in `_app_views_users_sessions_new_html_erb__321696909397072435_46750480'

我使用标准形式的设计,第9行有表格

<%=form_for(resource, :as=>resource_name,:url =>session_path(resource_name)) do |f| %>

它在开发和生产环境中都在本地工作,但在服务器上它甚至不在开发环境中工作。 即使我传递了超过1个争论,它也会为所有f.label抛出相同的错误 像

<%= f.label :remember_me, "Remember me", :class => "some_class" %>

有关

<%= f.label>

错误是正确的,错误的参数数量(0表示1)

当我将f.label更改为label_tag或html标签时,它工作正常

Serverinfo:

aws
rails 3.2.11(3.2.13 also tried)
ruby 1.9.3
apache webserver
phusion passenger
mysql

1 个答案:

答案 0 :(得分:0)

我希望它会有所帮助。我只是不使用erb。我用的很苗条。但我想你会理解

h1 User login

= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f|
  .field
    = f.label :email, "Email"
    = f.email_field :email
  .field
    = f.label :password, "Password"
    = f.password_field :password
  .field
    = show_simple_captcha
  .field
    - if devise_mapping.rememberable?
      = f.label :remember_me do
        = f.check_box :remember_me
        '
        ' Remember me
  .actions
    = f.submit "Submit", :class => :btn

= render "users/shared/links"

我在标签中使用嵌套复选框。结果(复选框部分):

<div class="field">
  <label for="user_remember_me">
    <input type="hidden" value="0" name="user[remember_me]"><input type="checkbox" value="1" name="user[remember_me]" id="user_remember_me"> Remember me 
  </label>
</div>