0

I am currently working on a website that will require users to sign-up, in order to perform various tasks. However, I am having some trouble with sign-ups.

I have a partial named _form.html.erb, which is rendered in application.html.erb (so that it appears on every page users navigate to) as a fade-in, fade-out modal form (I am using Twitter Bootstrap). What do I need to do, in order to pass an instance variable to this partial and have a user created in the database, once the user presses the submit button? Do I need to create a new method in application_controller.rb and a new user model?

Thank you for the help!

Note: I've read this link (http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials), but did not get much out of it.

4

1 回答 1

0

在渲染存储用户对象的部分时,我会分配一个局部变量。

布局/application.html.erb

<%= render "users/form", :user => User.new %>

用户/new.html.erb

<%= render "form", :user => @user %>

使用这种技术,您的表单将引用局部变量。

<%= form_for user do |f| %>
  <!-- form fields here -->
<% end %>
于 2013-10-07T22:15:07.750 回答