This method won't throw an error: def a_method raise ensure return :something end it will in fact return :something So please proceed with care...
...and complexity in the code is when a functional method (that we expect to return a value) return different values under different circumstances. For example, we ruby programmers have a...
...bad habit of returning nil from a method when certain condition is not fulfilled else return an Array or Hash. That just makes the calling code unnecessary complex and error...
# => {:conditions => "foo2 IS NOT NULL"} As you can see, proxy_options only returns conditions for last scope, but one possible use case of this is using proxy_options...
...data: JSON.stringify(params), }) .done(onDone) .fail(onFail); Always make sure your rails controller returns something: if @property.update_attributes(params[:property]) render :json => { :ok => true }, :status => :ok else render :json => { :ok...
Best results in other decks
Use return to return from a method. return accepts a value that will be the return value of the method call. Use break to quit from a block and...
...serve as an example in the details below: def example puts yield puts 'done' return 'example' end # Intended usage & output: example { 'hallo welt' } # hallo welt # done # => 'example' Return within a...
...IN (?)", excluded_ids) When the exclusion list is empty, you would expect this to return all records. However, this is not what happens: # Broken example User.where("id NOT IN (?)", []).to...
...SELECT `users`.* FROM `users` WHERE (id NOT IN (NULL)) Passing an empty exclusion list returns no records at all! See below for better implementations. Rails 4+ Use the .not method...