Checking content_for

benissimo Jul 10, 2012

@tordans You asked your question 3 years ago, but in any case, should anyone have that same issue, you can manage that with:

- unless content_for(:footer).blank?
yield(:footer)
- else
== render "layouts/footer_big"

content_for(:x) defaults to an empty string, that's why you need to...

Another usage example

meceo Jun 20, 2012 1 thank

given: order active record class with "state" string field

class Order < ActiveRecord::Base
def state
  @state ||= ActiveSupport::StringInquirer.new(read_attribute(:status))
end
end

order = Order.new(state: "initial")
order.state.initial? #=> true
order.state.paid...

more_than? instance method

dennismonsewicz Jun 11, 2012

Over the weekend I kept running into instances where I was writing code like this:

==== Code example arr = ['hello', 'world']

if arr.length > 2

do stuff

else

do something else

end

So I ended up extending the core and adding an instance method of more_than?

==== Code...