SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Zealot HenriIV's Avatar
    Join Date
    Jun 2004
    Location
    France
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    bypass layouts/application ? (blank view)

    hi,

    I'm trying to setup an admin part of the site. I used Admin::mycontroller to generate the controller and subfolder to keep admin files together.
    So I have
    app/controllers/admin/my_controller.rb
    app/views/admin/my_controller.rhtml

    The admin part uses the same model objects, in fact I just move the create/update/delete parts but I get a blank page.

    The log reports "Rendering within layouts/application" but I don't want to use it, is there a simple way to bypass this? (layouts/application seems to refer to the whole site)

    thanks

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    I guess you have something like
    Code:
    layout 'application'
    in your ApplicationController?

    All you'd have to do for a separate layout is override Admin::MyController with its own layout:
    Code:
    class Admin::MyController < ApplicationController
      layout 'admin'
      #other stuff...
    end

  3. #3
    SitePoint Zealot HenriIV's Avatar
    Join Date
    Jun 2004
    Location
    France
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have no layout 'application' in my ApplicationController (application.rb I suppose).

    I've created a subfolder directly under views/layouts/admin instead of views/admin/layouts and it works now but I'm not sure it's a clean way to do it. Do you mix admin and app controllers and views for your websites?

  4. #4
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    California
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Its pretty late and I'm having trouble understanding so I'm just going to go over some concepts (if you know them arlready just ignore me)

    When you specify a layout via the "layout" tag it looks under 'layouts' so:
    Code:
    layout 'application'
    would look for 'layouts/application.rhtml'

    So:
    Code:
    layout 'admin/application'
    would look for 'layouts/admin/application.rhtml'

    I hope that helps. It is okay to use another controllers layout, as layouts don't necessarilly belong to specific controller.
    Happy switcher to OS X running on a MacBook Pro.

    Zend Certified Engineer

  5. #5
    SitePoint Zealot HenriIV's Avatar
    Join Date
    Jun 2004
    Location
    France
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys, I completely missed this concept!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •