[Rails] What's the best way to embed a form?: Header showing multiple times?

softwareengineer 99 softwareengineer99 at yahoo.com
Sun Feb 5 18:17:51 GMT 2006


After some digging around, I found the solution to the error:
  
"::MemberController" is not a valid constant name!
  The error goes away if I comment out the following line in member_controller.rb
  
  before_filter :login_required
  
  
  My MemberController has the following layout applied to it
  class MemberController < ApplicationController
    layout  'default-layout'

  This is causing the header to show up two times (even for my new method login_form).
  
  How can I have a default layout applied to a Controller and then turn it off for one function?
  
  Currently my tags/show.rhtml reads
  
  <%= render_component :controller => "member",  :action => "login_form"%>
  
  And my login_form definition in member_controller is:
  
  def login_form
      return if generate_blank
      @member = Member.new(@params['member'])
      if @session['member'] = Member.authenticate(@params['member']['login'], @params['member']['password'])
        flash['notice'] = l(:member_login_succeeded)
        redirect_back_or_default :action => 'welcome'
      else
        @login = @params['member']['login']
        flash.now['message'] = l(:member_login_failed)
      end
      render :layout => false
    end
  
  Why isn't the render :layout => false working here? 
  
  I thought it would be nice to have the layout applied to the entire  controller. But I didn't know that tunring it off will become such a  hassle?
  
  So what are the best practices in this case? Is it good to apply a  "global" layout and then turn it off for each function (which isn't  working for me) or not have a "global" layout and then apply it for  each method?
  
  Needless to say, I am so confused with layouts here.
  
  Your continued assistance is highly appreciated. I am sure this will help a lot of new learners here too.
  
  Frank
  
  
Xavier Noria <fxn at hashref.com> wrote:  On Feb 4, 2006, at 23:53, softwareengineer 99 wrote:

> Thank you Xavier for your reply:


			
---------------------------------
 Yahoo! Mail - Helps protect you from nasty viruses.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060205/55589916/attachment.html


More information about the Rails mailing list