Skip to content

Instantly share code, notes, and snippets.

View denysonique's full-sized avatar

Dennis Prochniak denysonique

View GitHub Profile
has_and_belongs_to_many :followers,
class_name: 'User',
foreign_key: 'follower_id',
join_table: 'followers_followees'
has_and_belongs_to_many :followees,
class_name: 'User',
foreign_key: 'followee_id',
join_table: 'followers_followees'
class Contacts::ApplicationController
respond_to :json, :html
def index
respond_with Contacts.all
end
end
@denysonique
denysonique / gist:2019269
Created March 12, 2012 02:03
How to build Ruby Kdebidings (QtRuby) on Windows
1. Download and install Qt SDK 4.8 (http://qt.nokia.com/downloads/)
2. Build Smokegen (https://projects.kde.org/projects/kde/kdebindings/smoke/smokegen/repository)
3. Build Smokeqt (https://projects.kde.org/projects/kde/kdebindings/smoke/smokeqt/repository)
4. Build (https://projects.kde.org/projects/kde/kdebindings/ruby/qtruby/repository)
foo << 'bar' do
something
end
menu = Menu.new
menu << 'Quit' do
$app.quit
end
#this appends a menu item 'Quit' which exits the application when clicked
$sessions = {}
class Test
def initialize(session, &blk)
$last_session = session
yield
end
end
class User
def initialize
# Standard QtRuby:
Menu.new do
action = Action.new
action.text = 'say hi'
action.connect(SIGNAL :clicked) { puts 'hi' }
add_action(action)
action_quit = Action.new
action_quit.text = 'quit'
def full_name
unless @_full_name
return @first_name + ' ' + @last_name
end
@_full_name
end
def full_name=(full_name)
@_full_name = full_name
end
most_recent: (id)->
@collection ||= new ProfileCollection
unless @collection.get(id)
@collection.fetch
success: =>
if id
@display @collection.get(id)
else
@display @collection.first()
else
$('a[href]').click ->
$('.menu li').removeClass('active')
$(this).parent('li').addClass('active')
MissNk.profile_router.navigate $(this).attr('href'), trigger: true
false