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
Ryan Flournoy
3,839 PointsHow can I make full_name not .profile name part of my ID key (Creating the Profiles Controller)
require 'test_helper'
class ProfilesControllerTest < ActionController::TestCase test "should get show" do get :show, id: user(:ryan) .profile_name (I want this to be based on my full_name variable) assert_response :success assert_template 'profile/show' end
end
Do I have to change the data base or is there code I can use to use the full_name thing, because I didnt want "profile names" just real ones. If not please let me know how to add this to the data base without messing my project up.
Thanks!
2 Answers
Jason Seifer
Treehouse Guest TeacherHey Ryan Flournoy you'll need to write a custom finder for something like that. In your controller you probably have something like:
User.where(profile_name: params[:id]).first
You'll have to change that to something like:
User.where(first_name: params[:first_name], last_name: params[:last_name]).first
Then in your test:
user = users(:ryan)
get :show, first_name: user.first_name, last_name: user.last_name
Hope that points you in the right direction!
Ryan Flournoy
3,839 PointsThanks!