code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
class Cv < ActiveRecord::Base
attr_accessible :language_id, :user_id, :cv
has_attached_file :cv,
:url => "/cvs/:id/:style/:basename.:extension",
:path => ":rails_root/public/cvs/:id/:style/:basename.:extension"
validates_attachment_content_type :cv,
:content_type ... | Ruby |
class Authentication < ActiveRecord::Base
attr_accessible :user_id, :provider, :uid, :token, :token_secret
end
| Ruby |
class Attend < ActiveRecord::Base
attr_accessible :job_id, :user_id
belongs_to :user
belongs_to :job
end
| Ruby |
class Post < ActiveRecord::Base
attr_accessible :title, :user_id, :content, :priority, :published, :short_content, :counter, :slug
belongs_to :user
def self.search(search)
find(:all, :conditions => ['title LIKE ? or short_content LIKE ? or content LIKE ?', "%#{search}%", "%#{search}%", "%#{search}%"])
end
... | Ruby |
class County < ActiveRecord::Base
attr_accessible :country_id, :name
belongs_to :country
has_many :cities
end
| Ruby |
class User < ActiveRecord::Base
rolify
after_create :assign_default_role
#before_save :set_default_role
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :omniauthable,
:recoverable, :r... | Ruby |
class Category < ActiveRecord::Base
attr_accessible :title, :description
has_many :jobs
end
| Ruby |
class Job < ActiveRecord::Base
attr_accessible :title, :description, :category_id, :short_content, :time,
:duties, :requirements, :preferences, :offer, :apply, :city_id, :education_id
belongs_to :company
belongs_to :category
belongs_to :city
belongs_to :education
has_many :attends
has_many :favorites
def se... | Ruby |
class Education < ActiveRecord::Base
attr_accessible :name
has_many :jobs
end
| Ruby |
class Favorite < ActiveRecord::Base
attr_accessible :job_id, :user_id
belongs_to :user
belongs_to :job
end
| Ruby |
class Ability
include CanCan::Ability
def initialize(user)
# Define abilities for the passed in user here. For example:
#
# user ||= User.new # guest user (not logged in)
# if user.admin?
# can :manage, :all
# else
# can :read, :all
# end
#
# The first argume... | Ruby |
class Role < ActiveRecord::Base
has_and_belongs_to_many :companies, :join_table => :companies_roles
has_and_belongs_to_many :users, :join_table => :users_roles
belongs_to :resource, :polymorphic => true
scopify
# attr_accessible :title, :body
end
| Ruby |
class City < ActiveRecord::Base
attr_accessible :county_id, :name
belongs_to :county
has_many :educations
end
| Ruby |
class Company < ActiveRecord::Base
rolify
after_create :assign_default_role
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# ... | Ruby |
class Country < ActiveRecord::Base
attr_accessible :name
has_many :counties
end
| Ruby |
class Language < ActiveRecord::Base
attr_accessible :name
has_many :cvs
end
| Ruby |
#coding:utf-8
class SearchController < ApplicationController
def index
if !params[:query].nil?
query = params[:query].parameterize
else
query = ''
end
end
def detailed_search
end
end
| Ruby |
class PostsController < InheritedResources::Base
def create
@post = Post.new(params[:post])
@post.user = current_user
@post.save
end
end
| Ruby |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery
rescue_from CanCan::AccessDenied do |exception|
redirect_to root_url, :alert => exception.message
end
require 'will_paginate/... | Ruby |
class WelcomeController < ApplicationController
def index
@posts = Post.all
@jobs = Job.find_by_sql("SELECT * FROM jobs WHERE published = 1 ORDER BY created_at desc")
@categories = Category.all
end
def about
end
end
| Ruby |
#coding:utf-8
class AuthenticationsController < ApplicationController
def index
@authentications = Authentication.all
end
def create
@authentication = Authentication.new(params[:authentication])
if @authentication.save
redirect_to authentications_url, :notice => "Successfully created authentica... | Ruby |
#coding:utf-8
class AttendsController < InheritedResources::Base
def attend
@attend = Attend.new
@attend.job_id = params[:id]
@attend.user = current_user
if @attend.save
flash[:notice] = "Sikeres jelentkezés"
redirect_to :back
else
flash[:notice] = "A jelentkezés nem sikerült"
end
end
def destr... | Ruby |
class CategoriesController < InheritedResources::Base
end
| Ruby |
#coding:utf-8
class CompaniesController < ApplicationController
def index
@companies = Company.all.paginate :page => (params[:page]) ? params[:page] : 1
respond_to do |format|
format.html
end
end
def show
@company = Company.find(params[:id])
respond_to do |format|
format.html
end
end
def des... | Ruby |
#coding:utf-8
class EducationController < ApplicationController
def index
@educations = Education.all
end
def new
@education = Education.new
end
def create
@education = Education.new(params[:education])
respond_to do |format|
if @education.save
format.html {redirect_to(@education, :notice => 'Vé... | Ruby |
class CountiesController < InheritedResources::Base
end
| Ruby |
#coding:utf-8
class CvsController < InheritedResources::Base
#downloads_files_for :cvs, :cv
def index
if params[:user_id]
@user = User.find(params[:user_id])
@cvs = @user.cvs
else
@cvs = Cv.all
end
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @cvs }
... | Ruby |
#coding: utf-8
class JobsController < ApplicationController
def attends
@attends = Attend.find_by_sql ["select * from attends inner join jobs on attends.job_id = jobs.id where jobs.company_id = ?", params[:company_id].to_i]
respond_to do |format|
format.html # index.html.erb
format.xml ... | Ruby |
#coding:utf-8
class UsersController < ApplicationController
def index
@users = User.all.paginate :page => (params[:page]) ? params[:page] : 1
respond_to do |format|
format.html
end
end
def show
@user = User.find(params[:id])
respond_to do |format|
format.html
end
end
def destroy
@user = User.... | Ruby |
class CitiesController < InheritedResources::Base
end
| Ruby |
class LanguageController < ApplicationController
end
| Ruby |
class RegistrationsController < Devise::RegistrationsController
def build_resource(*args)
super
if session[:omniauth]
@user.apply_omniauth(session[:omniauth])
@user.valid?
end
end
def create
super
session[:omniauth] = nil unless @user.new_record?
end
def update_with_password(params, *options)
... | Ruby |
#coding:utf-8
class CountriesController < InheritedResources::Base
def index
@countries = Country.all
respond_to do |format|
format.html
format.xml {@countries}
end
end
def show
end
def edit
end
def update
end
def new
@country = Country.new
end
def create
@country = Country.new(params[:c... | Ruby |
#coding:utf-8
class FavoritesController < InheritedResources::Base
def like
@favorite = Favorite.new
@favorite.job_id = params[:id]
@favorite.user_id = current_user.id
respond_to do |format|
if @favorite.save
flash[:notice] = "Sikeresen mentve a kedvencek közé"
format.html { redirect_to :back}
... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', ... | Ruby |
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a probl... | Ruby |
# Be sure to restart your server when you modify this file.
#
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters ... | Ruby |
# Use this hook to configure ckeditor
Ckeditor.setup do |config|
# ==> ORM configuration
# Load and configure the ORM. Supports :active_record (default), :mongo_mapper and
# :mongoid (bson_ext recommended) by default. Other ORMs may be
# available as additional gems.
require "ckeditor/orm/active_record"
# ... | Ruby |
#coding:utf-8
SEARCH_TYPES={:Job => 'Állások', :Post => 'Hírek'} | Ruby |
module Facebook
CONFIG = YAML.load_file(Rails.root.join("config/facebook.yml"))[Rails.env]
APP_ID = CONFIG['app_id']
SECRET = CONFIG['secret_key']
end
module Twitter
end
module Google
end
| Ruby |
# Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attac... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
| Ruby |
# Be sure to restart your server when you modify this file.
Rails3Allaskereso::Application.config.session_store :cookie_store, key: '_rails3_allaskereso_session'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the sessio... | Ruby |
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render invalid all existing
# confirmat... | Ruby |
Rails3Allaskereso::Application.routes.draw do
resources :favorites do
member do
get :like
end
end
resources :education
resources :languages
resources :cities
resources :counties
resources :countries
mount Ckeditor::Engine => '/ckeditor'
# The priority is based upon order ... | Ruby |
require 'rubygems'
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
| Ruby |
require File.expand_path('../boot', __FILE__)
require 'rails/all'
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.requi... | Ruby |
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Rails3Allaskereso::Application.initialize!
| Ruby |
Rails3Allaskereso::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
con... | Ruby |
Rails3Allaskereso::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart ... | Ruby |
Rails3Allaskereso::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for t... | Ruby |
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Rails3Allaskereso::Application
| Ruby |
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Rails3Allaskereso::Application.load_tasks
| Ruby |
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', ... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
| Ruby |
# Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attac... | Ruby |
# Be sure to restart your server when you modify this file.
#
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters ... | Ruby |
# Be sure to restart your server when you modify this file.
AddressBook::Application.config.session_store :cookie_store, :key => '_AddressBook_session'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table wi... | Ruby |
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a probl... | Ruby |
AddressBook::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.ac... | Ruby |
AddressBook::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the w... | Ruby |
AddressBook::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the t... | Ruby |
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
AddressBook::Application.initialize!
| Ruby |
require 'rubygems'
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
| Ruby |
require File.expand_path('../boot', __FILE__)
require 'rails/all'
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.requi... | Ruby |
AddressBook::Application.routes.draw do
resources :relation
resources :locations
resources :people
get "hello/index"
# The priority is based upon order of creation:
# first created -> highest priority.
# Sample of regular route:
# match 'products/:id' => 'catalog#view'
# Keep in mind you can ass... | Ruby |
module ApplicationHelper
end
| Ruby |
module LocationsHelper
end
| Ruby |
module HelloHelper
end
| Ruby |
module PeopleHelper
end
| Ruby |
module RelationHelper
end
| Ruby |
class Location < ActiveRecord::Base
has_many :person_to_location_relations
has_many :people, :through => :person_to_location_relations
def linked_people
return self.people
end
end
| Ruby |
class PersonToLocationRelation < ActiveRecord::Base
belongs_to :person
belongs_to :location
validates :person_id, :uniqueness => {:scope => :location_id}
def insert(person, location)
self.person_id = person
self.location_id = location
self.save
end
end
| Ruby |
class Person < ActiveRecord::Base
has_many :person_to_location_relations
has_many :locations, :through => :person_to_location_relations
end
| Ruby |
class RelationController < ApplicationController
def index
@people = Person.find(:all)
end
def edit
@selected_person = Person.find(params[:id]);
@my_locations_array = Location.find(:all, :joins => [:people], :conditions => {:people => {:id => params[:id]}}).collect{|loc| loc.id}
@all_locations = ... | Ruby |
class LocationsController < ApplicationController
# GET /locations
# GET /locations.json
def index
@locations = Location.all
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @locations }
end
end
# GET /locations/1
# GET /locations/1.json
def show
... | Ruby |
class PeopleController < ApplicationController
# GET /people
# GET /people.json
def index
@people = Person.all
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @people }
end
end
# GET /people/1
# GET /people/1.json
def show
@person = Person.fi... | Ruby |
class ApplicationController < ActionController::Base
protect_from_forgery
end
| Ruby |
class HelloController < ApplicationController
def index
end
end
| Ruby |
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
AddressBook::Application.load_tasks
| Ruby |
source 'http://rubygems.org'
gem 'rails', '3.1.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql'
gem 'json'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.1.5'
gem 'coffee-r... | Ruby |
class CreatePeople < ActiveRecord::Migration
def change
create_table :people do |t|
t.string :name
t.timestamps
end
end
end
| Ruby |
class CreatePersonToLocationRelations < ActiveRecord::Migration
def change
create_table :person_to_location_relations do |t|
t.references :person
t.references :location
t.timestamps
end
add_index :person_to_location_relations, :person_id
add_index :person_to_location_relations, :loc... | Ruby |
class CreateLocations < ActiveRecord::Migration
def change
create_table :locations do |t|
t.string :name
t.timestamps
end
end
end
| Ruby |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Mayor.create(:name =>... | Ruby |
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run AddressBook::Application
| Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integrati... | Ruby |
require 'sinatra/activerecord/rake'
require './main' | Ruby |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'sinatra-activerecord'
gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client'
group :development do
gem 'rake'
gem 'sqlite3-ruby'
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.string :profile_id
t.string :email
t.string :refresh_token
end
add_index :users, :profile_id
end
def down
drop_table :users
end
end
| Ruby |
# Copyright (C) 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Ruby |
require 'sinatra.rb'
# Sinatra defines #set at the top level as a way to set application configuration
set :run, false
set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development)
require './main'
run Sinatra::Application | Ruby |
require 'sinatra/activerecord/rake'
require './main' | Ruby |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'sinatra-activerecord'
gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client'
group :development do
gem 'rake'
gem 'sqlite3-ruby'
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.string :profile_id
t.string :email
t.string :refresh_token
end
add_index :users, :profile_id
end
def down
drop_table :users
end
end
| Ruby |
# Copyright (C) 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Ruby |
require 'sinatra.rb'
# Sinatra defines #set at the top level as a way to set application configuration
set :run, false
set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development)
require './main'
run Sinatra::Application | Ruby |
require 'RMagick'
class NumberImageGenerator
@@IMAGE_DIR = 'numbers-hdpi/'
def generate(text, fs=18)
#filename = "b" + sprintf("%03d", text) + ".png";
filename = "" + sprintf("%03d", text) + ".png";
font_size = fs;
height = 35;
width = 35;
image = Magick::Image.new(width, height) {self.ba... | Ruby |
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
LANGS_URI = 'http://ath.darshancomputing.com/bi/langs/'
langs = Net::HTTP.get(URI.parse(LANGS_URI)).split()
langs.each do |lang|
if lang.length == 2
dir = 'res/values-' << lang
else
dir = 'res/values-' << lang[0,2] << '-r' << lang[2,2]
end
if ! D... | Ruby |
require 'net/http'
server = "msdl.microsoft.com"
pdb = "ntkrnlmp"
guid = "30092be745b24fe2a311a936e7b7486f2"
uri = "/download/symbols/#{pdb}.pdb/#{guid}/#{pdb}.pd_"
dest = "#{pdb}.pd_"
puts uri
Net::HTTP.start(server) { |http|
headers = {"User-Agent" => "Microsoft-Symbol-Server/6.6.0007.5"}
resp = http.get(u... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.