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
module Facebooker2 | |
module Rails | |
module Helpers | |
module Javascript | |
def fb_html_safe(str) | |
if str.respond_to?(:html_safe) | |
str.html_safe | |
else | |
str |
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
<%= 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 |
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
<% 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'}); |
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
<% 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'}); |
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 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 |
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
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 |
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
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 |
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
has_attached_file :photo, :convert_options => {:all => lambda {|i| "-crop '#{i.photo_custom_x}x#{i.photo_custom_y}+100+100'"}} |
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 check_attributes(user) | |
updated_user = user | |
if user.name != user.fb_data.name # update name if user e.g. changed it, it's missing, etc. | |
updated_user.name = user.fb_data.name | |
end | |
if user.gender != user.fb_data.gender | |
updated_user.gender = user.fb_data.gender | |
end | |
if user.age != user.fb_data.age | |
updated_user.age = user.fb_data.age |
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 CustomUser | |
def initialize(name) | |
@name = name | |
end | |
end |