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

Trouble Creating Profile Page

Hey everyone so I am on the creating a ruby application portion of the ruby track. I am following along with Jason and am trying to create the user profile page. Everytime I go to localhost:3000/drewkono13 I keep getting the error

/home/treehouse/projects/Viewbly/app/controllers/profiles_controller.rb:8: syntax error, unexpected tIDENTIFIER, expecting keyword_end render file: 'public/404', status: 404 formats: [:html] ^

Currently I have all the code exactly like Jason has on his minus instead of it saying "@user = User.find_by_profile_name(params[:id])" it says "@user = User.find_by_username(params[:id])" This is because my users table uses username instead of profile_name

All the code looks like it should be running smooth when I try to create the account. However, I am wondering if it is the differences between ruby 3 that Jason is on and ruby version 4 that I am on that is causing this error to appear. Thank you all for your help.

Can you post the contents of the file

/home/treehouse/projects/Viewbly/app/controllers/profiles_controller.rb ?

Looks like you may be missing an end on one of your methods in there.

4 Answers

I think you need a comma after status: 404. These are options you pass to the method render so each key value pair needs to be separated by a ,

Yeah, try that and let us know if it works.

Twiz T

class ProfilesController < ApplicationController

def show

@user = User.find_by_username(params[:id])

if @user

    @views = @user.views.all

    render action: :show

else
    render file: 'public/404', status: 404 formats: [:html]

end 

end

end

Go to rails console (rails c) and check if the newly created user has any data or just nil values. I'm 99% sure it's Strong Parameters problem - the main difference between Rails 3 and 4 that causes lots of frustration among Treehouse students.

Hey thank you guys that is what my problem was I forgot to add a comma.