Skip to content

Instantly share code, notes, and snippets.

View thomasmaas's full-sized avatar

Thomas Maas thomasmaas

View GitHub Profile
@thomasmaas
thomasmaas / gist:be597dc43b48444888b8
Created February 12, 2016 20:55
validation issue
casaschool/src/casaschool master ✗ 7h22m ⚑ ◒
▶ rails c
Loading development environment (Rails 4.2.5.1)
[1] pry(main)> group2 = Group.new
=> #<Group:0x007fb386d8c188 id: nil, slug: nil, description: nil, created_at: nil, updated_at: nil, email: nil, position: 0, page_id: nil, section_id: nil, parent: nil>
[2] pry(main)> group2.name = 'name'
=> "name"
[3] pry(main)> group2.save!
(0.4ms) BEGIN
(0.3ms) ROLLBACK
<!DOCTYPE html>
<html lang="en" class="">
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# object: http://ogp.me/ns/object# article: http://ogp.me/ns/article# profile: http://ogp.me/ns/profile#">
<meta charset='utf-8'>
<link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/github-6603a12316e50e603e0b44558adf7a5eb8cac166d102d798149c5553098a41c1.css" media="all" rel="stylesheet" />
<link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/github2-a87cd6dd740cc44b59219652052d8b935af35c8063ec31afbd38fb52cc526468.css" media="all" rel="stylesheet" />
<!DOCTYPE html>
<html lang="en" class="">
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# object: http://ogp.me/ns/object# article: http://ogp.me/ns/article# profile: http://ogp.me/ns/profile#">
<meta charset='utf-8'>
<link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/github-6603a12316e50e603e0b44558adf7a5eb8cac166d102d798149c5553098a41c1.css" media="all" rel="stylesheet" />
<link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/github2-a87cd6dd740cc44b59219652052d8b935af35c8063ec31afbd38fb52cc526468.css" media="all" rel="stylesheet" />
# Tasks
All open source gems, repos and internets are at your disposal for the excersise.
You have to use Ruby (1.9 or higher) and Rails (3.2 or higher) but all the remaining
technology decisions are yours. Good luck!
## 1) CRUD
Make a web application to manage a TODO list. Every (TODO) Item is just a piece of text that
is either `opened` or `closed`. The user has to be able to create an item, update an item
and list all of them.
class Data
class << self
def all
(1..10).to_a
end
def created
[4, 5, 6, 8, 9]
@thomasmaas
thomasmaas / gist:1063308
Created July 4, 2011 12:52 — forked from parndt/gist:1011435
How to cache pages and clear them in Refinery CMS
# put in config/application.rb
config.to_prepare do
::PagesController.module_eval do
caches_page :show, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
caches_page :home, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
end
::Page.module_eval do
after_save :clear_static_caching!
after_destroy :clear_static_caching!
@thomasmaas
thomasmaas / gist:1013101
Created June 7, 2011 20:39 — forked from parndt/gist:1011435
How to cache pages and clear them in Refinery CMS
# put in config/application.rb
config.to_prepare do
::PagesController.module_eval do
caches_page :show, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
caches_page :home, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
end
::Page.module_eval do
after_save :clear_static_caching!
after_destroy :clear_static_caching!
@thomasmaas
thomasmaas / fragment caching refinerycms menu
Created March 12, 2011 00:30
Fragment caching the refinerycms menu to speed things up dramatically. On Heroku, make sure to use memcached store if you use more than 1 dyno.
# views/layouts/shared/_menu.html.erb
hide_children = RefinerySetting.find_or_set(:menu_hide_children, false) if hide_children.nil?
+ cache('site_menu') do
collection ||= @menu_pages.includes(:slugs)
</nav>
Page::Translation Load (0.3ms) SELECT "page_translations".* FROM "page_translations" WHERE "page_translations"."locale" IN ('en') AND ("page_translations".page_id = NULL)
CACHE (0.0ms) SELECT "page_translations".* FROM "page_translations" WHERE "page_translations"."locale" IN ('en') AND ("page_translations".page_id = NULL)
CACHE (0.0ms) SELECT "page_translations".* FROM "page_translations" WHERE "page_translations"."locale" IN ('en') AND ("page_translations".page_id = NULL)
CACHE (0.0ms) SELECT "page_translations".* FROM "page_translations" WHERE "page_translations"."locale" IN ('en') AND ("page_translations".page_id = NULL)
CACHE (0.0ms) SELECT "page_translations".* FROM "page_translations" WHERE "page_translations"."locale" IN ('en') AND ("page_translations".page_id = NULL)
CACHE (0.0ms) SELECT "page_translations".* FROM "page_translations" WHERE "page_translations"."locale" IN ('en') AND ("page_translations".page_id = NULL)
CACHE (0.0ms) SELECT "page_translations".* FROM "page_translatio
/Users/thomasmaas/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/syck/rubytypes.rb:6:in `to_yaml'
activerecord (3.0.4) lib/active_record/connection_adapters/abstract/quoting.rb:34:in `quote'
friendly_id_globalize3 (3.2.0) lib/friendly_id/active_record_adapter/relation.rb:104:in `block in sluggable_ids_for'
friendly_id_globalize3 (3.2.0) lib/friendly_id/active_record_adapter/relation.rb:102:in `each'
friendly_id_globalize3 (3.2.0) lib/friendly_id/active_record_adapter/relation.rb:102:in `inject'
friendly_id_globalize3 (3.2.0) lib/friendly_id/active_record_adapter/relation.rb:102:in `sluggable_ids_for'
friendly_id_globalize3 (3.2.0) lib/friendly_id/active_record_adapter/relation.rb:62:in `find_one_with_slug'
friendly_id_globalize3 (3.2.0) lib/friendly_id/active_record_adapter/relation.rb:25:in `find_one'
friendly_id_globalize3 (3.2.0) lib/friendly_id/active_record_adapter/relation.rb:150:in `find_one'
activerecord (3.0.4) lib/active_record/relation/finder_methods.rb:281:in `find_with_ids'