yes (sheepish grin) after while I realize I was using Zend convention for controller actions method name
(OOPS)
so I renamed it to
actionSubmitRating and also enabled any logged in user to do it in the access
The full url for everything is actually like
http://testing1/yiijokes/index.php/joke/list (which works)
The virtual server is name testing1 so I fixed the url in the ajax routine to be
‘/yiijokes/index.php/joke/submitRating’,
and I access directly in browser already and it is still getting page not found but actually
[size="5"][color="#FF0000"]the URL is working!!!!![/color][/size]
because it’s getting into the action routine and trying to loadJoke but I don’t know how to know which joke we’re on since sending thru ajax does a whole new Yii this way. I don’t want to do put the joke id through the form because security. That’s why I don’t put the user ID in the form also, the app already knows which user in the cookie. Where is saved the id of the active record we were on before we submit this server call?
Here is the entire error stack:
exception ‘CHttpException’ with message 'The requested page does not
exist.’ in
/Users/tpdick/Sites/testing1/yiijokes/protected/controllers/JokeController.php:234
Stack trace:
#0 /Users/tpdick/Sites/testing1/yiijokes/protected/controllers/JokeController.php(257):
JokeController->loadJoke()
#1 /Users/tpdick/Sites/testing1/yii-1.1a.r1436/framework/web/actions/CInlineAction.php(32):
JokeController->actionSubmitRating()
#2 /Users/tpdick/Sites/testing1/yii-1.1a.r1436/framework/web/CController.php(300):
CInlineAction->run()
#3 /Users/tpdick/Sites/testing1/yii-1.1a.r1436/framework/web/filters/CFilterChain.php(129):
CController->runAction(Object(CInlineAction))
#4 /Users/tpdick/Sites/testing1/yii-1.1a.r1436/framework/web/filters/CFilter.php(41):
CFilterChain->run()
#5 /Users/tpdick/Sites/testing1/yii-1.1a.r1436/framework/web/CController.php(957):
CFilter->filter(Object(CFilterChain))
#6/Users/tpdick/Sites/testing1/yii-1.1a.r1436/framework/web/filters/CInlineFilter.php(59):
CController->filterAccessControl(Object(CFilterChain))
#7/Users/tpdick/Sites/testing1/yii-1.1a.r1436/framework/web/filters/CFilterChain.php(126):
CInlineFilter->filter(Object(CFilterChain))
#8/Users/tpdick/Sites/testing1/yii-1.1a.r1436/framework/web/CController.php(283):
CFilterChain->run()
#9/Users/tpdick/Sites/testing1/yii-1.1a.r1436/framework/web/CController.php(257):
CController->runActionWithFilters(Object(CInlineAction), Array)
#10/Users/tpdick/Sites/testing1/yii-1.1a.r1436/framework/web/CWebApplication.php(320):
CController->run(‘submitRating’)
#11/Users/tpdick/Sites/testing1/yii-1.1a.r1436/framework/web/CWebApplication.php(120):
CWebApplication->runController(‘joke/submitRati…’)
#12/Users/tpdick/Sites/testing1/yii-1.1a.r1436/framework/base/CApplication.php(135):
CWebApplication->processRequest()
#13 /Users/tpdick/Sites/testing1/yiijokes/index.php(11):
CApplication->run()
#14 {main} REQUEST_URI=/yiijokes/index.php/joke/submitRating
/**
* triggered by ajax, sends asynchronous ratings update to server
* @return unknown_type
*/
public function actionSubmitRating()
{
return $this->loadJoke()->addRating($_REQUEST['rating'], $_REQUEST['userId']); //dunno if this is how u do it
}
and here is the addRating function from the Joke model not sure how you really suppose to do it but that is a start.
public function addRating($rating,$userId)
{
$q = "INSERT Rating (rating, jokeId, userId, dateCreated, dateUpdated) values(' . $rating . ', ' . $this->model->id . ', ' . $userId . ', NOW(), NOW )";
//how do you submit a query to this thing
Yii::app()->db->execute($q); //no error checking for now
return 1;
}