anyone got a slicker way to do this? 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Thu, Jun 28, 2007 at 10:23:09PM -0600, ara.t.howard wrote:> anyone got a slicker way to do this? > > drawohara.tumblr.com/post/4517961You 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-WRrfy3IlpWYdnm+yROfE0A@public.gmane.org> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 6/29/07, ara.t.howard <ara.t.howard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > anyone got a slicker way to do this? > > 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 lamaAra, 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jun 28, 2007, at 10:29 PM, Marcel Molina Jr. wrote:> > On Thu, Jun 28, 2007 at 10:23:09PM -0600, ara.t.howard wrote: >> anyone got a slicker way to do this? >> >> 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! || returnright. 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jun 28, 2007, at 10:47 PM, Daniel N wrote:> > > On 6/29/07, ara.t.howard <ara.t.howard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > anyone got a slicker way to do this? > > 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 > > 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 > > >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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jun 28, 2007, at 10:47 PM, Daniel N wrote:> > > On 6/29/07, ara.t.howard <ara.t.howard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > anyone got a slicker way to do this? > > 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 > > 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 > >this summarizes i think 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---