It's more personal taste; I actually prefer

```
instance = (model == Discussion) ? model.published.find_by_key! params[:id]
                                                      : model.find
params[:id]
```

But that's admittedly less readable.

This way I do think you make clearer that you're assigning a variable.


On Mon, Feb 10, 2014 at 10:49 AM, john irving <notifications@github.com>wrote:

> In app/controllers/translations_controller.rb:
>
> > @@ -0,0 +1,16 @@
> > +class TranslationsController < BaseController
> > +  skip_before_filter :authenticate_user!, only: :translate
> > +  before_filter :load_translation, only: :translate
> > +
> > +  def translate
> > +    render :template => "#{params[:model].to_s.downcase.pluralize}/#{params[:model].to_s.downcase}_translations"
> > +  end
> > +
> > +  def load_translation
> > +    model = params[:model].to_s.humanize.constantize
> > +    instance = if model == Discussion then model.published.find_by_key! params[:id]
>
> I haven't see this sort of if/then in ruby before, is it very standard.
>
> i think for readability this could be:
>
>   if model == Discussion
>     instance = model.published.find_by_key! params[:id]
>   else
>     instance = model.find(params[:id])
>   end
>
> --
> Reply to this email directly or view it on GitHub<https://github.com/loomio/loomio/pull/1281/files#r9571077>
> .
>