Forum: Rails Engines Undefining an engine action?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A63764f318f10379c8b51349b757cf4b?d=identicon&s=25 Jay Levitt (Guest)
on 2006-02-15 21:07
(Received via mailing list)
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 Levitt
D8cb8c8cd40ddf0cd05241443a591868?d=identicon&s=25 Duane Johnson (Guest)
on 2006-02-15 23:11
(Received via mailing list)
On Feb 15, 2006, at 12:24 PM, Jay Levitt wrote:

>
> :action => 'home', but it seems like a general need people might
> have with
> engines.
>
> Jay Levitt
>

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 Johnson
(canadaduane)
http://blog.inquirylabs.com/
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 James Adam (Guest)
on 2006-02-15 23:14
(Received via mailing list)
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 Levitt <jay+news@jay.fm> wrote:
>
> Jay Levitt
>
> _______________________________________________
> engine-users mailing list
> engine-users@lists.rails-engines.org
> http://lists.rails-engines.org/listinfo.cgi/engine...
>


--
* J *
  ~
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 James Adam (Guest)
on 2006-02-15 23:14
(Received via mailing list)
Yes, what he said :)
A63764f318f10379c8b51349b757cf4b?d=identicon&s=25 Jay Levitt (Guest)
on 2006-02-16 05:08
(Received via mailing list)
On Wed, 15 Feb 2006 22:12:57 +0000, James Adam 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
This topic is locked and can not be replied to.