View feature.rb
class Feature | |
include Mongoid::Document | |
field :body, :type => String | |
embedded_in :suggestion, :inverse_of => :features | |
has_many_related :votes, :as => :votable | |
end |
View blueprints.rb
require 'machinist/mongoid' | |
require 'sham' | |
require 'faker' | |
Sham.define do | |
title { Faker::Lorem.words(5).join(' ') } | |
body { Faker::Lorem.paragraphs(3).join("\n\n") } | |
end |
View mongoid.rb
# MongoID adapter for Pickle | |
require 'mongoid' | |
class Mongoid | |
module PickleAdapter | |
include Pickle::Adapter::Base | |
# Do not consider these to be part of the class list | |
def self.except_classes |
View gist:573569
module Facebooker2 | |
module Rails | |
module Helpers | |
module Javascript | |
def fb_html_safe(str) | |
if str.respond_to?(:html_safe) | |
str.html_safe | |
else | |
str |
View index.html.erb
<%= fb_connect_async_js %> | |
<% if current_facebook_user %> | |
<%= "Welcome #{current_facebook_user.first_name} #{current_facebook_user.last_name}!" %> | |
or | |
<%= "Hello #{fb_name(current_facebook_user, :useyou => false)}!" # link to facebook profile | |
%> | |
<%= fb_logout_link("Logout of fb", request.url) %><br /> | |
<% else | |
# you must explicitly request permissions for facebook user fields. | |
# here we instruct facebook to ask the user for permission for our website |
View gist:573706
<% fb_connect_async_js do %> | |
<% unless current_facebook_user %> | |
FB.login(function(response) { | |
if (response.session) { | |
// window.location.href = '#{request.url}'; | |
window.location.href = '<%= root_url %>'; | |
} else { | |
// user cancelled login | |
} | |
}, {perms:'read_stream,offline_access,email,user_status,user_interests,user_location,user_online_presence'}); |
View index.html.erb
<% fb_connect_async_js do %> | |
<% unless current_facebook_user %> | |
FB.login(function(response) { | |
if (response.session) { | |
// window.location.href = '#{request.url}'; | |
window.location.href = '<%= root_url %>'; | |
} else { | |
// user cancelled login | |
} | |
}, {perms:'read_stream,offline_access,email,user_status,user_interests,user_location,user_online_presence'}); |
View gist:585083
def self.add_creation_method(name,klass) | |
define_method "#{name}_create" do |*args| | |
arg = args.first | |
params = arg.nil? ? {} : arg.post_params | |
klass_to_send = arg.nil? ? nil : klass | |
client.post("#{id}/#{name}", klass_to_send, params) | |
end | |
end |
View rails_guides_czech.txt
Začínáme s Rails | |
Tento průvodce popisuje jak začít s Ruby on Rails. Po jeho přečtení byste měli chápat následující: | |
Instalace Rails, vytvoření nové Rails aplikace a propojení aplikace s databází | |
Obecná struktura Rails aplikace | |
Základní principy MVC (Model, View, Controller) a designu založeného na REST přístupu |
View gist:606132
Match.delete_all | |
(1..10).each do |season| # 10 seasons | |
(1..3).each do |day| # 3 playing days a season | |
(1..5).each do |match| # 5 matches a day | |
Match.create(:start => Time.utc(2010,10,(2+(season-1)*3+day-1),(6+(match-1)*4),00,00).getlocal, :finish => Time.utc(2010,10,(2+(season-1)*3+day-1),(6+(match-1)*4),30,00).getlocal, :season_id => Season.find_by_name(season.to_s+".").id) | |
end | |
end | |
end |