Yii generates error "Unable to resolve the request <controller/action>" - yii

After logged in successfully, Yii does not executing any page.
Showing an error:
Error 404 Unable to resolve the request "membersdet/index"
Here membersdet is controller Id and index is an action.

Make sure the filename of your controller is EXACTLY "MembersdetController.php". It is case sensitive.
I guess you were developing on local machine under Windows OS and server runs on *nix system. That's normal issue for novice developers, that they forget about case sensitive file system in *nix.

It is because of wrong controller file name given or may be actionIndex() method is not in your controller.

I have had a similar problem and got it solved. In this case the file was correctly named but the class name was wrongly spelled. When these two do not correspond, you could get this error too.

Check case sensitive exactly your controller: MembersdetController
Check alias (common in config/main.php) map with namespace in your controller
Yii::setAlias('#tienn2t', dirname(dirname(__DIR__)) . '/tienn2t');
In MembersdetController.php file
<?php
namespace tienn2t\controllers;
use Yii;
use yii\web\Controller;
class MembersdetController extends Controller{
public function actionIndex(){
echo 1;die;
}
}

There is not enough information in the question, but maybe you have an incorrect .htaccess or if you don't have an htaccess at all you should use the url:
http://host/index.php?r=membersdet/index

Make sure you have MembersdetController in /protected/controllers/ and this class "is a" CController and has a public method named actionIndex().

Check errorHandler block in your config file.
I had fix this error like this
'errorHandler' => [
'errorAction' => 'error/index',
],
By the way you should have appropriate ErrorController in your module and /error/index.php
file in view folder.
Hope will help you.

Related

ERR_UNSAFE_REDIRECT

I'm trying to get my server to redirect to another page in my 'public folder'. When I use:
response.redirect(path.join(__dirname, '../public/user_home.html'))
I get and error net::ERR_UNSAFE_REDIRECT
On the client side I have:
$.get( "/user_home", function( data ) {console.log(data)};
I can't find anything about this error. Am I going about this incorrectly?
Your public folder is already available if you have static middleware configured in your app.
app.use(express.static('public'))
You can use:
res.redirect("/user_home.html");
response.redirect(path.join(__dirname, '../public/user_home.html'),safe=true)

Couldn't get the uid in Odoo JavaScript

I'm trying to learn JavaScript for Odoo. I've created a new class in my custom module's js file.
openerp.odoojs = function(instance){
console.log('instance: ',instance);
console.log('session: ',instance.session);
}
This is what I'm getting when I browse the session object in the console.
But when I try to access the uid or any other attribute or parameter like instance.session.uid, I'm getting it as undefined. Please help! I'm stuck with this. I'm unable proceed further.
Try to extend the 'Backbone.Model' like 'PosModel' in 'model.js' file. Try to define the 'initialize' function, where you will find two parameters in function arguments as 'session' and 'attributes'. Here you can find the uid using 'session.uid'.

Is it possible to init AdminController from outside Prestashop?

I am trying to initiate the AdminController module from outside the Prestashop. Basically, I am creating an external program which uses Prestashop to get current employee for which I should instantiate the AdminController, but its throwing error.
Many modules init the FrontController but I cannot find any example for AdminController like :
include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../init.php');
Please advice.
I found the solution after all. Simply define _PS_ADMIN_DIR_ and init the config.inc.php, Prestashop will automatically load the admin environment. However, if you are loading this from a module, its tricky to find the admin directory as its not defined anywhere, so I have written this small script.
$admindir = '';
foreach (glob("../../*/ajaxfilemanager", GLOB_ONLYDIR) as $filename) {
$admindir = str_replace('../../', '', $filename);
$admindir = str_replace('/ajaxfilemanager', '', $admindir);
}
define('_PS_ADMIN_DIR_', getcwd().'/../../'.$admindir);
require(_PS_ADMIN_DIR_.'/../config/config.inc.php');
Enjoy!

yii-user-management Yumuser.php get() on a non-object yum_user_relations

I have just installed the yii-user-management module but when I try to access it via browser I get
Fatal error: Call to a member function get() on a non-object in ..../modules/user/models/YumUser.php on line 368
$relations = Yii::app()->cache->get('yum_user_relations');
Appreciate any help.
It seems like the yii-user-management module requires a cache component for it to work. So in your application config add the cache component as
'cache'=>array(
'class'=>'CDummyCache',
),
Here we are using CDummyCache copmponent which is, as its name says, acts as a dummy. You can replace it by any other cache components as described here
Thanks #dInGd0nG. Your answer works for me too. Just would want to remind people to follow his link. In the link, you will see the configure statement shall be added in
'components'=>array(
......
'cache'=>array(
'class'=>'CDummyCache',
),
)

Magento - Trouble with setting up Model Read Adapter

I was following through on Alan Storm's tutorial on Magento's Model and ORM basics and I've run into a bit of a problem. When I get to the portion where I load from the Model for the first time I get this error "Fatal error: Call to a member function load() on a non-object...". I've reset everything already and tried again from scratch but I still get the same problem. My code looks like this:
$params = $this->getRequest()->getParams();
$blogpost = Mage::getModel('weblog/blogpost');
var_dump($blogpost);
echo("Loading the blogpost with an ID of ".$params['id']);
$blogpost->load($params['id']);
As you can see I dumped the contents of $blogpost and it shows that it is just a boolean false. My guess is that there's either a problem with the connection to the database or, for some reason, the code for Mage::getModel() didn't get installed correctly.
EDIT - Adding Code
There's so many that I just decided to pastebin them lol
app/code/local/Ahathaway/Weblog/controllers/IndexController.php
app/code/local/Ahathaway/Weblog/etc/config.xml
app/code/local/Ahathaway/Weblog/Model/Blogpost.php
app/etc/modules/Ahathaway_Weblog.xml
Your Model/Blogpost.php file should actually be Model/Mysql4/Blogpost.php, and you are missing the real Model/Blogpost.php.
My guess is that Mage cannot find your model class. Double check the module/model name and also verify if the model is in a correct place in the filesystem (it should be in app/code/local/Weblog/Model/Blogpost.php).
You also need to check if your config.xml correctly defines your model classes. It would be best if you could past your config.xml and your model class...
A quick glance reveals you're missing the model resource. Go back to the section around the following code example
File: app/code/local/Alanstormdotcom/Weblog/Model/Mysql4/Blogpost.php
class Alanstormdotcom_Weblog_Model_Mysql4_Blogpost extends Mage_Core_Model_Mysql4_Abstract{
protected function _construct()
{
$this->_init('weblog/blogpost', 'blogpost_id');
}
}