Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Partial form rendering but not showing

I have been following a tutorial that allows me to make login accounts. I am pretty sure I have followed all the steps but the form to make a new account won't display.

new.html.erb:

  <% form_for @user, :url => account_path do |f| %>

  <%= f.error_messages %>

  <%= render :partial => 'form', :locals => { :f => f } %>

  <%= f.submit "Register" %>

  <% end %>

_form.html.erb:

   <p><%= f.label :login %></p>

   <p><%= f.text_field :login %></p>

   <p><%= f.label :email %></p>

   <p><%= f.text_field :email %></p>

   <p><%= f.label :password, f.object.new_record? ? nil : "Change password" %></p>

   <p><%= f.password_field :password %></p>

   <p><%= f.label :password_confirmation %></p>

   <p><%= f.password_field :password_confirmation %></p>

The debugger spits this out when I go to /users/new:

   ApplicationController::current_user_session
   Rendered users/_form.html.erb (3.0ms)
   Rendered users/new.html.erb within layouts/application (9.8ms)
   Completed 200 OK in 165ms (Views: 99.7ms | ActiveRecord: 0.0ms)


   Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2012-08-12 09:06:44 -0500

so, it is telling me that it successfully rendered but when I visit the link nothing shows up. Does anyone know why?

like image 992
user1593518 Avatar asked Dec 16 '22 20:12

user1593518


1 Answers

You need to use <%= erb tags with any helper methods that generate output. This includes form_for and input tags.

<%= form_for ... %>

<% end %>
like image 125
Peter Brown Avatar answered Dec 27 '22 22:12

Peter Brown