Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion method conditional option pattern
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jim Ruther Nill  
View profile  
 More options Nov 9 2012, 3:13 am
From: Jim Ruther Nill <jvn...@gmail.com>
Date: Fri, 9 Nov 2012 16:10:02 +0800
Local: Fri, Nov 9 2012 3:10 am
Subject: Re: [Rails] method conditional option pattern

On Fri, Nov 9, 2012 at 3:27 PM, Erwin <yves_duf...@mac.com> wrote:
> When I have this pattern

>        sign_me(@user, :event => :authentication, :subdomain => subdomain)

> how can I write it to avoid sending the :subdomain option if
> subdomain.nil?   ( if possible ..)

>        sign_me(@user, :event => :authentication  #?, :subdomain =>
> subdomain unless subdomain.nil?  )

I'm not sure if it's possible to do it in a single line (as far as you want
to have a tidy code)

opts = { event: :authentication }
opts[:subdomain] = subdomain if subdomain

sign_me @user, opts

>  --
> 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@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscribe@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/TOTAudTTAa8J.
> For more options, visit https://groups.google.com/groups/opt_out.

--
-------------------------------------------------------------
visit my blog at http://jimlabs.heroku.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.