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
anyone got a slicker way to do this?
http://drawohara.tumblr.com/post/4517961
thanks.
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama
On Thu, Jun 28, 2007 at 10:23:09PM -0600, ara.t.howard wrote:
anyone got a slicker way to do this?
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 Molina Jr. [email protected]
On 6/29/07, ara.t.howard [email protected] 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
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.
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama
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.
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama
On Jun 28, 2007, at 10:47 PM, Daniel N wrote:
Daniel
this summarizes i think
http://drawohara.tumblr.com/post/4627267
cheers
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs