Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthordrmagu
     
    Sorry to start another thread on this. But I have now installed Akelos 3 times, thinking/hoping this might fix things. The last / most recent time the nightly build.
    I have gotten to the point where creating a book or an author works. I added two books, and one author.
    When doing /booklink/book/ or /booklink/author/ I DO get a listing with the data.
    HOWEVER, show, edit and destroy crashes.
    I have spent well in excess of 10 hours on this so ... PLEASE HELP ...
    After some debugging in book_controller.php it would appear that the $this->Book object exists when the listing method is invoked, but DOES NOT EXIST in any of the other methods (actions).
    This object ($this->Book) I am sure should be constructed SOMEWHERE, but, as I am an Akelos newbie, I have no idea where. In any case, neither the Book object in the book_controller NOR the Author object in the author_controller seem to exist - other than when the listing method is invoked.

    DrMagu
    • CommentAuthorKaste
     
    you should have a BookController at /app/controllers/book_controller.php
    there you find a function named "show" (function = action)

    function show(){
    $this->book = $this->Book->find(@$this->params['id']);
    }
    should do it.
    • CommentAuthordrmagu
     
    Kaste,
    Thank you for your response. Unfortunately, this does not work. The error I get is:
    Fatal error: Call to a member function find() on a non-object in /home/drmagu/booklink/app/controllers/book_controller.php on line 18
    Line 18, as you might guess, is in the show() function and is the line you suggested.
    For whatever reason, the $this->Book object DOES NOT EXIST inside the show() function. ( and neither inside edit() and destroy() )
    However, if I do a var_dump, or a simple 'echo $this->Book;' INSIDE THE listing() function, it DOES exist.
    Maddening.
    DrMagu
    • CommentAuthorKaste
     
    double-f**+#-check spelling and plural-singular naming. :-)
    get the object via
    $this->book =& new Book(@$this->params['id']);
    do you have set
    var $model=...
    or var $models=...
    in the controller?
    • CommentAuthordrmagu
     

    I have attached my book_controller.php file. The debug statements - and their effects - are included. I checked the spelling, and made the changes (additions) you suggested.

    class BookController extends ApplicationController
    {
        var $model = 'book';  // added per Kaste
    
        function index()
        {
            $this->renderAction('listing');
        }
    
        function listing()
        {
            // This outputs: "Book: Object id #11" when called as /booklink/book/listing
            echo 'Book: '.$this->Book.'<br />';  
    
            $this->book_pages = $this->pagination_helper->getPaginator($this->Book, array('items_per_page' => 10));        
            $this->books =& $this->Book->find('all', $this->pagination_helper->getFindOptions($this->Book));
        }
    
        function show()
        {
            // This outputs: "Book:" when called as /booklink/book/show/1
            echo 'Book: '.$this->Book.'<br />';  
    
            // this line creates the error "Call to a member function find() on a non-object"
            $this->book =& $this->Book->find(@$this->params['id']);  // added per Kaste
       }
    
    .... rest omitted
    }
    

    DrMagu

    • CommentAuthorKaste
     

    obviously that makes no sense. if you wanna debug look in

    lib/AkActionController line 352++

    there you find the method 'instantiateModelClass' where all the magic (brrr...) happens. look if $id gets the right value. i think beside the weird $id assing-statement the code is pretty straight forward.

    line 366: $model =& new $model_class_name();

    line 376: $this->$model_class_name =& $model;

    $model_class_name should be ="Book";