# Undefining an engine action?

**URL:** <https://www.ruby-forum.com/t/undefining-an-engine-action/68839>\
**Category:** Engines\
**Created:** [February 15, 2006, 9:07pm UTC](https://www.ruby-forum.com/t/undefining-an-engine-action/68839 "2006-02-15T21:07:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jay-levitt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a88e57/32.png) [@jay-levitt](https://www.ruby-forum.com/u/jay-levitt)\
**Post date:** [February 15, 2006, 9:07pm UTC](https://www.ruby-forum.com/t/undefining-an-engine-action/68839/1 "2006-02-15T21:07:08Z")

</div>

How can I override an engine action with nothingness? For instance, I  
want  
all my users to register themselves, so I want to remove the ability to  
create a new user.

I tried

def new  
end

as well as

undef new

in my user\_controller.rb, but in each case, Rails still tried to render  
the  
engine’s new template, with some errors presumably due to the  
now-improperly-set up instance variable.

In this case, I’m happy creating a fake new action that redirects to  
:action =\> ‘home’, but it seems like a general need people might have  
with  
engines.

Jay L.

---

<div class="post-metadata">

**Author:** ![jay-levitt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a88e57/32.png) [@jay-levitt](https://www.ruby-forum.com/u/jay-levitt)\
**Post date:** [February 15, 2006, 11:11pm UTC](https://www.ruby-forum.com/t/undefining-an-engine-action/68839/2 "2006-02-15T23:11:53Z")

</div>

On Feb 15, 2006, at 12:24 PM, Jay L. wrote:

> :action =\> ‘home’, but it seems like a general need people might  
> have with  
> engines.
> 
> Jay L.

I think this is actually an issue with rails itself–whether or not  
you have a method in your controller, if the view file (.rhtml file)  
exists, it will be rendered when called upon.

I would try this instead:

def new  
render :action =\> ‘home’  
end

Duane J.  
(canadaduane)  
[http://blog.inquirylabs.com/](http://blog.inquirylabs.com/)

---

<div class="post-metadata">

**Author:** ![jay-levitt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a88e57/32.png) [@jay-levitt](https://www.ruby-forum.com/u/jay-levitt)\
**Post date:** [February 15, 2006, 11:14pm UTC](https://www.ruby-forum.com/t/undefining-an-engine-action/68839/3 "2006-02-15T23:14:55Z")

</div>

Might this be due to the fact that Rails will render a view even if  
there’s no corresponding controller action behind it? I.E. even though  
you are removing the ‘new’ action, because the ‘new.rhtml’ file is  
present and locatable, Rails will presume that you want to render  
that.

I’m not sure that I can see a way around this at the moment, since the  
idea of Engines is that you don’t need to mess with the internals. As  
you say, you can always fake out the action to send the user somewhere  
else.

If anyone has any better ideas, let us know…

- james

On 2/15/06, Jay L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Jay L.
> 
> * * *
> 
> engine-users mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org](http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org)

–

- J \*  
~

---

<div class="post-metadata">

**Author:** ![jay-levitt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a88e57/32.png) [@jay-levitt](https://www.ruby-forum.com/u/jay-levitt)\
**Post date:** [February 15, 2006, 11:14pm UTC](https://www.ruby-forum.com/t/undefining-an-engine-action/68839/4 "2006-02-15T23:14:55Z")

</div>

Yes, what he said 🙂

---

<div class="post-metadata">

**Author:** ![jay-levitt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a88e57/32.png) [@jay-levitt](https://www.ruby-forum.com/u/jay-levitt)\
**Post date:** [February 16, 2006, 5:08am UTC](https://www.ruby-forum.com/t/undefining-an-engine-action/68839/5 "2006-02-16T05:08:28Z")

</div>

On Wed, 15 Feb 2006 22:12:57 +0000, James A. wrote:

> Might this be due to the fact that Rails will render a view even if  
> there’s no corresponding controller action behind it? I.E. even though  
> you are removing the ‘new’ action, because the ‘new.rhtml’ file is  
> present and locatable, Rails will presume that you want to render  
> that.

Ah! Yes, that’s exactly what it is. I never realized that feature of  
Rails (but it’s perfect, as I was just about to create a bunch of  
pseudo-actions for some static pages, and now I don’t have to).

So no, I can’t think of a way around it either - if new.rhtml exists in  
the  
search path, then it exists, and there’s no way to negate that. For my  
current case, re-rendering a different page is fine; I guess if it ever  
becomes a real problem, I’ll just think harder.

Jay
