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

PHP Laravel 4 Basics Validation & Flash Messages Sessions and Messages

Shen JIE LIN
Shen JIE LIN
10,612 Points

502 Bad Gateway Error

Hi, I was following alone with Sessions and Messages with Laravel

and I get an 502 Bad Gateway Error with this follow code

return Redirect::route('todos.index')->with('message','List was created!');

when I just simply have

return Redirect::route('todos.index);

the error goes away

anybody has any ideas on how to fix this ?

Thanks

2 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Shen;

502 errors can be caused by a few different things. One of them is different spellings of words in View files. Check your main.blade.php page and todos.index page to make sure everything is spelled the same. One common error is the spelling of "Session" differently in various files. That can generate 502 errors and be problematic to debug.

Post back if that is not the case.

Ken

Shen JIE LIN
Shen JIE LIN
10,612 Points

Hi, Ken

Thanks for the reply.

I have commented out the "Session" is spelled correctly in the main.blade.php file. If I cannot figure out the error I am gonna try to recreate the project again.

Shen

Shen JIE LIN
Shen JIE LIN
10,612 Points

as an update, just for curiosity sakes. I went into my Routes.php file and changed the root routing to the hello.blade.php file, and I get this error

ErrorException (E_UNKNOWN) Undefined offset: 1

Open: /home/vagrant/Sites/laravel-basics/vendor/laravel/framework/src/Illuminate/Routing/Router.php

:S

Now, even just basic routing doesn't work anymore...

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Shen;

Taking another look at this, I noticed that your code:

return Redirect::route('todos.index')->with('message','List was created!');

does not match the code in the video:

return Redirect::route('todos.index')->withMessage('List was created!');

In the video there is a screen shot at 2:14, and the line of code is Line 59.

Hope it help,

Ken

Shen JIE LIN
Shen JIE LIN
10,612 Points

Hi, Ken

about that line of code, instructor said it is fine with both methods, it is for personal preferences which way we would like to code it.

However, when I was fixing the code, I have tried both ways and it did not work. I am going to recreate the project. if it works after recreation I'll post back to let you know.

Thanks for the help

Shen

Shen JIE LIN
Shen JIE LIN
10,612 Points

Hi, Ken

I have successfully recreated the project and everything works fine now.

I guess it was corrupted code somewhere.

Thanks for your help