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 Controller Action to Create Pets

Yuichi Narisawa
Yuichi Narisawa
19,548 Points

Where did I make a mistake? (Challenge 1)

I think I fulfill the requirement, but it doesn't. Where should I fix this code?

app/controllers/pets_controller.rb
class PetsController < ApplicationController

  def show
    @pet = Pet.find(params[:id])
  end

  def new
    @pet = Pet.new
  end

  def create
    # YOUR CODE HERE
    pet_params = params.require(:pet), permit(:name)

  end

end

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi Yuichi,

I believe you may be referring to the second Task.

For the first task, you have the correct code with

pet_params = params.require(:pet)

For the second task, it wants you to add the permit method. Remember, that you can chain the methods using the period. Right now, you have both methods, but they aren't chained... they are just separated with a comma. So, everything is there.. just not joined properly.

Give it another go with that in mind. :)

:dizzy:

Yuichi Narisawa
Yuichi Narisawa
19,548 Points

Hi Jason,

Thank you for your quick response! I should have paid more attention to the task.