# What's the best way to embed a form?

**URL:** <https://www.ruby-forum.com/t/whats-the-best-way-to-embed-a-form/101087>\
**Category:** Rails\
**Created:** [February 4, 2006, 7:25pm UTC](https://www.ruby-forum.com/t/whats-the-best-way-to-embed-a-form/101087 "2006-02-04T19:25:17Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 4, 2006, 7:25pm UTC](https://www.ruby-forum.com/t/whats-the-best-way-to-embed-a-form/101087/1 "2006-02-04T19:25:17Z")

</div>

I would like to embed my login form on my app’s home page. What’s the  
best way to render the login action of member controller from another  
action?

Thanks  
Frank

---

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 4, 2006, 7:37pm UTC](https://www.ruby-forum.com/t/whats-the-best-way-to-embed-a-form/101087/2 "2006-02-04T19:37:45Z")

</div>

On Feb 4, 2006, at 19:24, softwareengineer 99 wrote:

> I would like to embed my login form on my app’s home page. What’s  
> the best way to render the login action of member controller from  
> another action?

If there’s a controller that renders that form, a clean idiom is to  
embed it calling render\_component from the view:

```
http://api.rubyonrails.com/classes/ActionController/Components.html

```

– fxn

---

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 4, 2006, 7:47pm UTC](https://www.ruby-forum.com/t/whats-the-best-way-to-embed-a-form/101087/3 "2006-02-04T19:47:01Z")

</div>

Thanks Xavier for your quick assistance.

The problem is that when I use  
render\_component :controller =\> “member”, :action =\> “login”

the original home page doesn’t render anymore.

I tried the following after rendering the above component, but then my  
application stops. I am guessing it goes into an infinite loop.

render\_component :controller =\> “home”, :action =\> “show”, :params =\>  
{ “category” =\> @params[:category] }

How can I render my home page, but just add the form there?

Thanks  
Frank

Xavier N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote: On Feb 4, 2006, at 19:24,  
softwareengineer 99 wrote:

> I would like to embed my login form on my app’s home page. What’s  
> the best way to render the login action of member controller from  
> another action?

If there’s a controller that renders that form, a clean idiom is to  
embed it calling render\_component from the view:

```
http://api.rubyonrails.com/classes/ActionController/Components.html

```

– fxn

---

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 4, 2006, 7:47pm UTC](https://www.ruby-forum.com/t/whats-the-best-way-to-embed-a-form/101087/4 "2006-02-04T19:47:03Z")

</div>

Xavier,  
I figured it out.  
I was trying to put it in the controller, but if I put it in views  
directory, it works

Thanks for your assistance.

Frank

softwareengineer 99 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote: Thanks Xavier  
for your quick assistance.

The problem is that when I use  
render\_component :controller =\> “member”, :action =\> “login”

the original home page doesn’t render anymore.

I tried the following after rendering the above component, but then my  
application stops. I am guessing it goes into an infinite loop.

render\_component :controller =\> “home”, :action =\> “show”, :params =\>  
{ “category” =\> @params[:category] }

How can I render my home page, but just add the form there?

Thanks  
Frank

Xavier N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote: On Feb 4, 2006, at 19:24,  
softwareengineer 99 wrote:

> I would like to embed my login form on my app’s home page. What’s  
> the best way to render the login action of member controller f rom  
> another action?

If there’s a controller that renders that form, a clean idiom is to  
embed it calling render\_component from the view:

```
http://api.rubyonrails.com/classes/ActionController/Components.html

```

– fxn

* * *

Rails mailing list  
removed\_email\_address@domain.invalid  
[http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

* * *

Relax. Yahoo! Mail virus scanning helps detect nasty  
viruses!\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
Rails mailing list  
removed\_email\_address@domain.invalid  
[http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

---

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 4, 2006, 7:53pm UTC](https://www.ruby-forum.com/t/whats-the-best-way-to-embed-a-form/101087/5 "2006-02-04T19:53:12Z")

</div>

Now I am having an issue where my layout is rendered twice? My header  
is showing two times, once for the home page and the second time for  
the login page.

Is there a way that I can have the layout rendered only once?  
Thanks  
Frank

softwareengineer 99 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote: Xavier,  
I figured it out.  
I was trying to put it in the controller, but if I put it in views  
directory, it works

Thanks for your assistance.

Frank

softwareengineer 99 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote: Thanks Xavier  
for your quick assistance.

The problem is that when I use  
render\_component :controller =\> “member”, :action =\> “login”

the original home page doesn’t render anymore.

I tried the following after rendering the above component, but then my  
application stops. I am guessing it goes into an infinite loop.

render\_component :controller =\> “home”, :action =\> “show”, :params =\>  
{ “category” =\> @params[:category] }

How can I render my home page, but just add the form there?

Thanks  
Frank

Xavier N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote: On Feb 4, 2006, at 19:24,  
softwareengineer 99 wrote:

> I would like to embed my login form on my app’s home page. What’s  
> the best way to render the login action of member controller f rom  
> another action?

If there’s a controller that renders that form, a clean idiom is to  
embed it calling render\_component from the view:

```
http://api.rubyonrails.com/classes/ActionController/Components.html

```

– fxn

* * *

Rails mailing list  
removed\_email\_address@domain.invalid  
[http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

* * *

Relax. Yahoo! Mail virus scanning helps detect nasty  
viruses!\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
Rails mailing list  
removed\_email\_address@domain.invalid  
[http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

* * *

Yahoo! Mail - Helps protect you from nasty  
viruses.\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
Rails mailing list  
removed\_email\_address@domain.invalid  
[http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

---

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 4, 2006, 9:14pm UTC](https://www.ruby-forum.com/t/whats-the-best-way-to-embed-a-form/101087/6 "2006-02-04T21:14:44Z")

</div>

On Feb 4, 2006, at 10:24 AM, softwareengineer 99 wrote:

> I would like to embed my login form on my app’s home page. What’s  
> the best way to render the login action of member controller from  
> another action?

Unless your users are forced to view the home page via SSL, what you  
are trying to do (and is done so commonly) is not secure:

> **[IEBlog](https://learn.microsoft.com/en-us/archive/blogs/ie/)**

–  
– Tom M.

---

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 4, 2006, 9:14pm UTC](https://www.ruby-forum.com/t/whats-the-best-way-to-embed-a-form/101087/7 "2006-02-04T21:14:44Z")

</div>

I am using SSL for the entire app so security is not an issue here.  
Thanks  
Frank

Tom M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote: On Feb 4, 2006, at 10:24  
AM, softwareengineer 99 wrote:

> I would like to embed my login form on my app’s home page. What’s  
> the best way to render the login action of member controller from  
> another action?

Unless your users are forced to view the home page via SSL, what you  
are trying to do (and is done so commonly) is not secure:

> **[IEBlog](https://learn.microsoft.com/en-us/archive/blogs/ie/)**

–  
– Tom M.

---

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 4, 2006, 9:36pm UTC](https://www.ruby-forum.com/t/whats-the-best-way-to-embed-a-form/101087/8 "2006-02-04T21:36:39Z")

</div>

Thank you so much for your reply.

Unfortunately, I can’t get it to work.

According to  
[http://rails.techno-weenie.net/question/2006/1/14/render\_component\_infinite\_loop](http://rails.techno-weenie.net/question/2006/1/14/render_component_infinite_loop)  
, its the render method that supports :layout=\>false.

When I place :layout=\>false in render\_component, nothing happens.

When I palce render (:layout=\>false ) at the end of my function, no  
form is shown.

When I change render\_component to render, still no form shows up.

So far: in show.rhtml, I have  
\<%= render :controller =\> “member”, :action =\> “login”, :layout =\>  
false, :params =\> { “member[login]” =\> “” } %\>

When I put  
render (:layout=\>false)  
in my tags\_controller, the layout is shown 0 times.

I tried  
\<%= render\_component :controller =\> “member”, :action =\> “login”,  
:layout =\> false, :params =\> { “member[login]” =\> “” } %\>

but it causes the layout to show two times.

I am really confused at the moment and appreciate any help.

Thanks  
Frank  
Xavier N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote: On Feb 4, 2006, at 19:51,  
softwareengineer 99 wrote:

> Now I am having an issue where my layout is rendered twice? My  
> header is showing two times, once for the home page and the second  
> time for the login page.
> 
> Is there a way that I can have the layout rendered only once?

Yes, in your application the generation of the login form does not  
construct an entire HTML page, it only creates a HTML form. In those  
situations you need to render :layout =\> false.

– fxn

---

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 4, 2006, 9:14pm UTC](https://www.ruby-forum.com/t/whats-the-best-way-to-embed-a-form/101087/9 "2006-02-04T21:14:45Z")

</div>

On Feb 4, 2006, at 19:51, softwareengineer 99 wrote:

> Now I am having an issue where my layout is rendered twice? My  
> header is showing two times, once for the home page and the second  
> time for the login page.
> 
> Is there a way that I can have the layout rendered only once?

Yes, in your application the generation of the login form does not  
construct an entire HTML page, it only creates a HTML form. In those  
situations you need to render :layout =\> false.

– fxn

---

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 4, 2006, 11:26pm UTC](https://www.ruby-forum.com/t/whats-the-best-way-to-embed-a-form/101087/10 "2006-02-04T23:26:55Z")

</div>

Xavier,  
Thank you once again for your detailed reply.

I created a method named ‘login\_form’ and the corresponding .rhtml  
file. but now I just keep getting the following error:

“::MemberController” is not a valid constant name!

I thought one could add a new action by simply creating the method and  
the .rhtml file.

What am I missing?

Any pointers are greatly appreciated.

Thanks  
Frank

---

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 4, 2006, 10:31pm UTC](https://www.ruby-forum.com/t/whats-the-best-way-to-embed-a-form/101087/11 "2006-02-04T22:31:43Z")

</div>

On Feb 4, 2006, at 21:33, softwareengineer 99 wrote:

> Thank you so much for your reply.
> 
> Unfortunately, I can’t get it to work.

The idea is:

1. In the view that generates the home you put something like this:

2. In member\_controller.rb there’s the corresponding action whose  
only purpose is the generation of the login form:

3. The file login\_form.rhtml generates a HTML form that calls the  
actual “login” action if submitted.

This is a technique to include HTML from other controllers, it makes  
sense when the generated HTML needs to be included in several places,  
when the controller is needed to take some logic into account in the  
generation of the HTML, etc. If the controller is not needed then  
factoring out the very form in a private template plus  
render :partial in the view is another standard idiom.

– fxn

---

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 5, 2006, 12:56am UTC](https://www.ruby-forum.com/t/whats-the-best-way-to-embed-a-form/101087/12 "2006-02-05T00:56:11Z")

</div>

On Feb 4, 2006, at 23:26, softwareengineer 99 wrote:

> Thank you once again for your detailed reply.

Sure.

> I created a method named ‘login\_form’ and the corresponding .rhtml  
> file. but now I just keep getting the following error:
> 
> “::MemberController” is not a valid constant name!
> 
> I thought one could add a new action by simply creating the method  
> and the .rhtml file.
> 
> What am I missing?

Can you send the smallest relevant code snippets?

– fxn

---

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 4, 2006, 11:38pm UTC](https://www.ruby-forum.com/t/whats-the-best-way-to-embed-a-form/101087/13 "2006-02-04T23:38:59Z")

</div>

I just wanted to add to the following post that the moment I change  
\<%= render\_component :controller =\> “member”, :action =\>  
“login\_form”%\>  
to  
\<%= render\_component :controller =\> “member”, :action =\> “login”%\>  
I don’t get the exception error.

Can anyone please guide me as to what else is required to create an  
action? I have created the .rhtml file and defined the method in my  
controller?

Thanks

softwareengineer 99 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:  
Xavier,  
Thank you once again for your detailed reply.

I created a method named ‘login\_form’ and the corresponding .rhtml  
file. but now I just keep getting the following error:

“::MemberController” is not a valid constant name!

I thought one could add a new action by simply creating the method and  
the .rhtml file.

What am I missing?

Any pointers are greatly appreciated.

Thanks  
Frank

* * *

Brings words and photos together (easily) with  
PhotoMail - it’s free and works with Yahoo!  
Mail.\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
Rails mailing list  
removed\_email\_address@domain.invalid  
[http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

---

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 5, 2006, 12:56am UTC](https://www.ruby-forum.com/t/whats-the-best-way-to-embed-a-form/101087/14 "2006-02-05T00:56:23Z")

</div>

Thank you Xavier for your reply:

Here is the views/member/login\_form.rhtml (edited for html)  
\<%= head\_helper %\>  
\<%= start\_form\_tag\_helper %\>  
\<%= form\_input :text\_field, “login”, :size =\> 30 %\>  
  
\<%= form\_input :password\_field, “password”, :size =\> 30  
%\>  
  
\<%= button\_helper ‘login’ %\>  
\<%= link\_helper ‘login\_signup’, :action =\> ‘signup’ %\> |  
\<%= link\_helper ‘login\_forgot\_password’, :action =\>  
‘forgot\_password’ %\>  
\<%= end\_form\_tag %\>

The following is the line in views/tags/show.html

\<%= render\_component :controller =\> “member”, :action =\>  
“login\_form”%\>

If I change the above line back to login, I don’t get the exception  
error.

Here are the lines from member\_controller.rb

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

Unfortunately, since I ported my app to use SVN, I don’t have access  
to log contents either (an issue I am working on fixing).

If there is anything else that you would like to see, please let me  
know.

Once again, thank you very much for your assistance.

Frank

> What am I missing?

Can you send the smallest relevant code snippets?

– fxn

---

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 5, 2006, 12:56am UTC](https://www.ruby-forum.com/t/whats-the-best-way-to-embed-a-form/101087/15 "2006-02-05T00:56:24Z")

</div>

I was able to get access to logs using the webrick server and the  
following is an excerpt:

Processing MemberController#login\_form (for 151.213.150.183 at  
2006-02-04 15:50:05) [GET]  
Parameters: {“action”=\>“login\_form”, “id”=\>nil,  
“controller”=\>“member”}  
Redirected to [http://accounting.adoppt.com:3000/member/login](http://accounting.adoppt.com:3000/member/login)  
Filter chain halted as [login\_required] returned false  
Completed in 0.00104 (961 reqs/sec) | DB: 0.00000 (0%) | 302 Found  
[[http://accounting.adoppt.com/tag/business](http://accounting.adoppt.com/tag/business)]  
Start rendering component ({:controller=\>“/member”,  
:action=\>“login”}):

ActionView::TemplateError (“::MemberController” is not a valid  
constant name!) on line #9 of app/views/tags/show.rhtml:  
6:  
7:  
8:  
9: \<%= render\_component :controller =\> “member”, :action =\>  
“login\_form”%\>  
10:  
11:

  
12:

I appreciate your assistance.

Thanks  
Frank

softwareengineer 99 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote: Thank you  
Xavier for your reply:

Here is the views/member/login\_form.rhtml (edited for html)  
\<%= head\_helper %\>  
\<%= start\_form\_tag\_helper %\>  
\<%= form\_input :text\_field, “login”, :size =\> 30 %\>  
  
\<%= form\_input :password\_field, “password”, :size =\> 30  
%\>  
  
\<%= button\_helper ‘login’ %\>  
\<%= link\_helper ‘login\_signup’, :action =\> ‘signup’ %\> |  
\<%= link\_helper ‘login\_forgot\_password’, :action =\>  
‘forgot\_password’ %\>  
\<%= end\_form\_tag %\>

The following is the line in views/tags/show.html

\<%= render\_component :contro ller =\> “member”, :action =\>  
“login\_form”%\>

If I change the above line back to login, I don’t get the exception  
error.

Here are the lines from member\_controller.rb

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

Unfortunately, since I ported my app to use SVN, I don’t have acce  
ss to log contents either (an issue I am working on fixing).

If there is anything else that you would like to see, please let me  
know.

Once again, thank you very much for your assistance.

Frank

> What am I missing?

Can you send the smallest relevant code snippets?

– fxn

* * *

Rails mailing list  
removed\_email\_address@domain.invalid  
[http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

* * *

Brings words and photos together (easily) with  
PhotoMail - it’s free and works with Yahoo!  
Mail.\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
Rails mailing list  
removed\_email\_address@domain.invalid  
[http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

---

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 5, 2006, 10:05am UTC](https://www.ruby-forum.com/t/whats-the-best-way-to-embed-a-form/101087/16 "2006-02-05T10:05:13Z")

</div>

On Feb 4, 2006, at 23:53, softwareengineer 99 wrote:

> ```
> <%= link_helper 'login_forgot_password', :action =>  
> 
> ```
> 
> ‘forgot\_password’ %\>  
> \<%= end\_form\_tag %\>
> 
> The following is the line in views/tags/show.html
> 
> \<%= render\_component :contro ller =\> “member”, :action =\>  
> “login\_form”%\>

There’s a spurious space in “:contro ller”.

---

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 5, 2006, 6:48pm UTC](https://www.ruby-forum.com/t/whats-the-best-way-to-embed-a-form/101087/17 "2006-02-05T18:48:25Z")

</div>

I can’t say thanks enough for you continung to assist me.

I have no idea how the space got in the message. I checked with my  
code and there is no space or I edited it out earlier:

\<%= render\_component :controller =\> “member”, :action =\>  
“login\_form”%\>

I spent all night trying to figure it out but to no avail.

Am I right in assuming that a method and a corresponding .rhtml file  
is all that’s needed to create an action?

Frank

Xavier N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote: On Feb 4, 2006, at 23:53,  
softwareengineer 99 wrote:

> Thank you Xavier for your reply:
> 
> Here is the views/member/login\_form.rhtml (edited for html)  
> \<%= head\_helper %\>  
> \<%= start\_form\_tag\_helper %\>  
> \<%= form\_input :text\_field, “login”, :size =\> 30 %\>

> ```
> <%= form_input :password_field, "password", :size => 30 % 
> 
> ```
> 
> >

> ```
> <%= button_helper 'login' %>
> <%= link_helper 'login_signup', :action => 'signup' %> |
> <%= link_helper 'login_forgot_password', :action =>  
> 
> ```
> 
> ‘forgot\_password’ %\>  
> \<%= end\_form\_tag %\>
> 
> The following is the line in views/tags/show.html
> 
> \<%= render\_component :contro ller =\> “member”, :action =\>  
> “login\_form”%\>

There’s a spurious space in “:contro ller”.

---

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 5, 2006, 7:24pm UTC](https://www.ruby-forum.com/t/whats-the-best-way-to-embed-a-form/101087/18 "2006-02-05T19:24:42Z")

</div>

You can change the rendering of layouts in a more declarative way at the  
top  
of controllers with something like:

layout “application”, :except =\> [:login\_form]

---

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 5, 2006, 7:18pm UTC](https://www.ruby-forum.com/t/whats-the-best-way-to-embed-a-form/101087/19 "2006-02-05T19:18:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 6, 2006, 3:30am UTC](https://www.ruby-forum.com/t/whats-the-best-way-to-embed-a-form/101087/20 "2006-02-06T03:30:35Z")

</div>

Thanks Byron for your reply.

Frank

Byron S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote: You can change the  
rendering of layouts in a more declarative way at the top of controllers  
with something like:

layout “application”, :except =\> [:login\_form]

[Next page](https://www.ruby-forum.com/t/whats-the-best-way-to-embed-a-form/101087.md?page=2)
