Skip to content

Instantly share code, notes, and snippets.

def facebook_account
u = self.user
link = "https://facebook.com/#{u.facebook}"
ActionController::Base.helpers.link_to("<i class='fa fa-facebook'></i>".html_safe, link, target: "_blank", class: "social-solo facebook") if (!(u.nil?) && !(u.facebook.nil?) && !(u.facebook.empty?) && u.show_facebook?)
end
form do |f|
f.semantic_errors *f.object.errors.keys
f.inputs "Details", :class => "collapsible" do
f.input :title
f.input :author, :label => "Name"
f.input :is_private
f.input :publish_date, :as => :datepicker
f.input :publish_frequency, :as => :number, :label => "Publish Frequency", :step => 1
#TODO: add slug again. Also, understand why this was removed
f.input :slug, :placeholder => "cannot be changed afterwards" unless !f.object.slug.nil?
@walidvb
walidvb / a.rb
Created September 16, 2014 09:51
mystring = "Charles Dickens first serialised&nbsp;<i>Great Expectations</i>&nbsp;to rave reviews in&nbsp;1859 and its wit, power and brilliance is just as fresh today.&nbsp;You may have read this story&nbsp;of first love and lost identity&nbsp;before,&nbsp;but not like this.<br>"
#In my view: - content_for :og_description = mystring
#in my layout.haml: %meta{content: CGI.unescapeHTML(strip_tags(yield(:og_description)))}
has_one :splash_page, :dependent => :destroy
accepts_nested_attributes_for :splash_page, :allow_destroy => true, reject_if: proc { |attributes| !SplashPage.new(attributes).valid? }
a {
color: blue;
@media (max-width:100){
color: red;
}
}
b{
@extend a;
}
computeElementsPositions = () ->
elements = new Array()
padding = parseInt $('body').css('paddingTop')
console.log 'computing elements with body padding of '+padding
$('.witness').remove()
$('[data-pid]').each () ->
$this = $(this)
pid = $this.attr("data-pid")
pos = $this.offset().top - padding
witness = $('<div class="witness">' + pid + ':' + pos + '</div>')
- @price_present = true
%span{"ng-cloak" => true, "ng-switch" => "currency"}
%span.animated{"ng-switch-when" => 'gbp'}= number_to_currency(locals[:gbp].to_d/100, {:unit => @currencies['gbp']})
%span.animated{"ng-switch-when" => 'eur'}= number_to_currency(locals[:eur].to_d/100, {:unit => @currencies['eur']})
%span.animated{"ng-switch-when" => 'usd'}= number_to_currency(locals[:usd].to_d/100, {:unit => @currencies['usd']})
@walidvb
walidvb / error
Last active August 29, 2015 14:03
1) WebReadsController when the book is published and the user is subscribed should display only published chapters
Failure/Error: get :show, id: @book
ActionController::UrlGenerationError:
No route matches {:id=>"slug_32", :controller=>"web_reads", :action=>"show"}
# ./spec/controllers/web_reads_controller_spec.rb:20:in `block (4 levels) in <top (required)>'
@walidvb
walidvb / Output
Last active August 29, 2015 14:03
/Users/Gaston/dev/pigeonhole/pigeonhole/spec/support/controller_macros.rb
/Users/Gaston/dev/pigeonhole/pigeonhole/spec/support/count_queries.rb
/Users/Gaston/dev/pigeonhole/pigeonhole/spec/support/delayed_jobs.rb
/Users/Gaston/dev/pigeonhole/pigeonhole/spec/support/rspec_extensions.rb
/Users/Gaston/dev/pigeonhole/pigeonhole/spec/support/stub_paperclip_attachment.rb
Run options: include {:locations=>{"./spec/controllers/send_to_kindle_controller_spec.rb"=>[41]}}
F
Failures:
include ActionDispatch::TestProcess
Fabricator(:chapter) do
body "Chapter Body"
tile_title "hello"
tile_description ""
tile_extra_html ""
file {fixture_file_upload(Rails.root + 'spec/fabricators/assets/chapter.rtf')}
end