When using 'Setting json variable in Controller' method there is an error if the view file for that action does not exist. The offending code is on line 47 where $view !== false in the if statement. It should be $view !== null.
I'm also getting the error:
Error: The view for RoomsController::index() was not found.
Error: Confirm you have created the file: .../app/View/Rooms/json.json.ctp
My controller code is:
$rooms = $this->paginate('Room');
$this->view = 'Json.Json';
To change the view within a method, I found that instead of using $this->view, use $this->viewClass variable will work.
$this->viewClass = 'Json.Json';
You also have to use $this->render(false) if you do not want to use a view file.
Fixed render without view file. Fixes #1.
Thank you guys, I changed the code to support both false and null as parameter in render. So it makes backward compatible and fix the issue. Thanks for all your help and sorry by delay, I was in vacation.