Sha256: d258e8ca1f5a40ed2f0024ff5cadf63cd288ed4e7254e9ca2295e8665514f28d

Contents?: true

Size: 533 Bytes

Versions: 1

Compression:

Stored size: 533 Bytes

Contents

module BiteHelper
  def text_bite(identifier, options)
    bite = Bite.find_by(identifier: identifier)
    return bite_form(bite) if @bite_authentication
    return Bite.create(identifier: identifier, text: options.default).text if bite.nil?
    return bite.text unless bite.text.blank?
    return options[:default] if options.present?
  end

  private def bite_form(bite)
    render(
      inline: "<%= form_for bite do |f| %><%= f.text_area :text %><%= f.submit 'Update' %><% end %>",
      locals: { bite: bite }
    )
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bites-1.0.0 lib/bites/bite_helper.rb