Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Rails Routes and Resources Routes to Create Actions View for New Pets

André Hatlo-Johnsen
André Hatlo-Johnsen
1,170 Points

Cant understand what objects it wants

Any help?

app/views/pets/new.html.erb
<%= form_for(@pet) do |f| %>
<div class="field">
  <%= f.field :name %>
  <%= f.text_area :name %>
</div>  
<div>
  <%= f.submit %>
</div>
  <% end %>

I haven't done this exercise, but I'm pretty sure you don't need () around @pet and this is what's causing the problem.

Check out the RailsGuide for examples: http://guides.rubyonrails.org/form_helpers.html

2 Answers

Ethan Rivas
Ethan Rivas
9,979 Points

What asks the task?

No, my earlier answer was almost correct. You need to read the challenge questions closely, which I did this time. It just wants a simple form. Besides the (), there is no need to add <div> tags here.

Here's my final passing code for this challenge:

<%= form_for @pet do |f| %>
  <%= f.label :name, 'Name' %>
  <%= f.text_field :name %>
  <%= f.submit %>
<% end %>

I usually name my labels -- which I did here with 'Name'. However, this should still work if you want to leave that off.

<%= form_for @pet do |f| %>
  <%= f.label :name %>
  <%= f.text_field :name %>
  <%= f.submit %>
<% end %>