View gist:5275479
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ def ble # concatenates everything and you can render whole part in partial by calling yield :ble, or content_for :ble | |
+ content_for :ble, content_tag(:p, "Here form starts:") | |
+ content_for :ble, content_tag(:p, "Here form starts:") | |
+ content_for :ble, content_tag(:p, "Here form starts:") | |
+ content_for :ble, content_tag(:p, "Here form starts:") | |
+ render "shared/bootstrap/ble" | |
+ end | |
+ | |
+ def ble2 # you can render everything on the end of helper as well | |
+ content_for :ble, content_tag(:p, "Here form starts: asdfasdf") |
View index.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.container | |
%h1 Todo List | |
%ul.todos(data-bind="foreach: todos") | |
%li(data-bind="attr: {class: className}") | |
%input(type="checkbox" data-bind="checked: completed") | |
%span(data-bind="text: title") | |
%a(data-bind="visible: allowClear, click: clearList") Clear List | |
%input(type="text" placeholder="New Todo Title" data-bind="value: todoToAdd, event: {change: addTodo}") | |
View gist:3978120
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppSettings::Base | |
@show_info = true | |
class << self | |
attr_accessor :cells | |
attr_accessor :show_info | |
end | |
def self.setup(&block) | |
yield(self) | |
end |
View to_proc.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Filter | |
def initialize() | |
@constraints = [] | |
end | |
def constraint(&block) | |
@constraints << block | |
end | |
def to_proc |
View AbstractModel.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AbstractModel | |
def self.set_target(model_name) | |
@@model_name = model_name | |
AbstractModel.class.delegate :find, :to => :"#{@@model_name}" | |
AbstractModel.class.delegate :all, :to => :"#{@@model_name}" | |
end | |
end | |
#AbstractModel.set_target("Product") | |
#AbstractModel.find(1) |
View fb_connect.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails) | |
require 'sinatra/base' | |
require 'curl' | |
class FbConnect < Sinatra::Base | |
get '/info' do | |
"Redirect URL: #{ENV['REDIRECT_URL']} session_data:#{session.inspect}" | |
end |
View many_proxy_custom_method_call.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'mongo_mapper' | |
MongoMapper.connection = Mongo::Connection.new('localhost',27017) | |
MongoMapper.database = "test" | |
class User | |
include MongoMapper::Document | |
key :name, String | |
many :ideas do |
View embedded_document_delete.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MongoMapper "embedded document delete" plugin | |
# By Peter Cooper | |
# | |
# Got embedded documents you want to delete? You can delete them as if the | |
# embedded document collection were an array, but then there's no way to get | |
# a callback (as far as I could tell). This plugin gives you a call back | |
# (if you want it) and gives a nicer syntax to deleting embedded docs. | |
# | |
# Example: | |
# |
View mongo_mapper_order_by_array_ids.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'mongo_mapper' | |
MongoMapper.connection = Mongo::Connection.new('localhost',27017) | |
MongoMapper.database = "test" | |
class Word | |
include MongoMapper::Document | |
key :content, String | |
key :translation_ids, Array |
View mm_embedded_documents_sorting.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'mongo_mapper' | |
MongoMapper.connection = Mongo::Connection.new('localhost',27017) | |
MongoMapper.database = "test" | |
class Word | |
include MongoMapper::Document | |
key :content, String | |
many :translations do |