从另一个模型添加字段以设计sign_up

时间:2017-07-01 13:22:49

标签: ruby-on-rails ruby ruby-on-rails-4

我尝试将其他模型(account.rb)中的某些字段添加到设计sign_up中。字段显示正确,但是当我提交表单时,值不会插入到account.rb模型中。 这就是我想要做的事情

<h2>Sign up</h2>

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

  <div class="field">
    <%= f.label :email %><br />
    <%= f.email_field :email, autofocus: true %>
  </div>

  <div class="field">
    <%= f.label :password %>
    <% if @minimum_password_length %>
    <em>(<%= @minimum_password_length %> characters minimum)</em>
    <% end %><br />
    <%= f.password_field :password, autocomplete: "off" %>
  </div>

  <div class="field">
    <%= f.label :password_confirmation %><br />
    <%= f.password_field :password_confirmation, autocomplete: "off" %>
  </div>


<%= form_for :account, :url => new_account_path, html: { method: :post }  do |f| %>


  <div class="field">
    <%= f.label :first_name %>
    <%= f.text_field :first_name, id: :account_first_name %>
  </div>

  <div class="field">
    <%= f.label :last_name %>
    <%= f.text_field :last_name, id: :account_last_name %>
  </div>

  <div class="field">
    <%= f.label :buisness_name %>
    <%= f.text_field :buisness_name, id: :account_buisness_name %>
  </div>

  <div class="field">
    <%= f.label :buisness_description %>
    <%= f.text_field :buisness_description, id: :account_buisness_description %>
  </div>

  <div class="field">
    <%= f.label :web_site %>
    <%= f.text_field :web_site, id: :account_web_site %>
  </div>

  <div class="field">
    <%= f.label :phone_number %>
    <%= f.text_field :phone_number, id: :account_phone_number %>
  </div>

  <div class="field">
    <%= f.label :street %>
    <%= f.text_field :street, id: :account_street %>
  </div>

  <div class="field">
    <%= f.label :city %>
    <%= f.text_field :city, id: :account_city %>
  </div>

  <div class="field">
    <%= f.label :state %>
    <%= f.text_field :state, id: :account_state %>
  </div>

  <div class="field">
    <%= f.label :zip_code %>
    <%= f.text_field :zip_code, id: :account_zip_code %>
  </div>

  <div class="field">
    <%= f.label :country %>
    <%= f.text_field :country, id: :account_country %>
  </div>

  <div class="actions">
    <%= f.submit "Sign up" %>
  </div>
<% end %>
<% end %>

0 个答案:

没有答案