Forum: Ruby on Rails rendering now!

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.
1bac2e65d64faf472cf2ebc94f0f5ee0?d=identicon&s=25 ara.t.howard (Guest)
on 2007-06-29 06:24
(Received via mailing list)
anyone got a slicker way to do this?

   http://drawohara.tumblr.com/post/4517961

thanks.

-a
--
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama
Cee0292fffa691f1fb320d5400200e99?d=identicon&s=25 Marcel Molina Jr. (Guest)
on 2007-06-29 06:31
(Received via mailing list)
On Thu, Jun 28, 2007 at 10:23:09PM -0600, ara.t.howard wrote:
> anyone got a slicker way to do this?
>
>    http://drawohara.tumblr.com/post/4517961

You could have login! return false if it renders and then do something
like:

def post_comment
  return unless login!

or

def post_comment
  login! || return

Not very pretty and kind of a little too implicit versus the throw/catch
approach but it's less complex than the throw/catch for the case you
show in
your post.

marcel
--
Marcel Molina Jr. <marcel@vernix.org>
9d1f5d2d9de70bd9a934f557dc95a406?d=identicon&s=25 Daniel ----- (liquid)
on 2007-06-29 06:48
(Received via mailing list)
On 6/29/07, ara.t.howard <ara.t.howard@gmail.com> wrote:
> --
> we can deny everything, except that we have the possibility of being
> better. simply reflect on that.
> h.h. the 14th dalai lama


Ara,

Is there a reason why you couldn't put this into a before filter and
avoid
the problem altogether.

This is the way it's done in the restful_authentication plugin

before_filter :login_required, :(except | only) => [actions]

This way the action never gets called if the login_required method
returns
false.  Then the login_required method can call a render or redirect
etc.

Sorry If I'm missing something..
Cheers
Daniel
1bac2e65d64faf472cf2ebc94f0f5ee0?d=identicon&s=25 ara.t.howard (Guest)
on 2007-06-29 07:02
(Received via mailing list)
On Jun 28, 2007, at 10:29 PM, Marcel Molina Jr. wrote:

>   return unless login!
>
> or
>
> def post_comment
>   login! || return

right.  i'm way too stupid the remember that every time though ;-)

>
> Not very pretty and kind of a little too implicit versus the throw/
> catch
> approach but it's less complex than the throw/catch for the case
> you show in
> your post.
>

completely agree.  the issue, i guess, is that there is no way to
pull out any logic that does a render under some condition and place
it outside the controller.  so every controller then has to
duplication the code.  of course there are filters, but that's not
well suited to something you only do some of the time.

in this case though your solution or a filter is far easier.

kind regards.

-a
--
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama
1bac2e65d64faf472cf2ebc94f0f5ee0?d=identicon&s=25 ara.t.howard (Guest)
on 2007-06-29 07:11
(Received via mailing list)
On Jun 28, 2007, at 10:47 PM, Daniel N wrote:

>
>
> Daniel
>
>
>

that certainly seems to be the obvious answer here - i should have
picked a better example for that post!  ;-)

so yeah, that's fine here - i was more generally wondering about
being able to factor out and arbitrary peice of logic that might
cause something to be rendered and the login seemed like the obvious
example.

cheers.


-a
--
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama
1bac2e65d64faf472cf2ebc94f0f5ee0?d=identicon&s=25 ara.t.howard (Guest)
on 2007-06-30 17:45
(Received via mailing list)
On Jun 28, 2007, at 10:47 PM, Daniel N wrote:

>
>
> Daniel
>
>

this summarizes i think

http://drawohara.tumblr.com/post/4627267

cheers

-a
--
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama
This topic is locked and can not be replied to.