Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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 %>