code
stringlengths
1
1.73M
language
stringclasses
1 value
require './spec_helper.rb' describe User do #Before each test runs, run this: # before :each do # @user = User.new "John", "Doe" , "BigDoe@gmail.com", "hunter2" # end #t’s a convention in Ruby to talk refer to instance methods #like this: ClassName#methodName describe do it "Takes 4 params and re...
Ruby
require '../test_helper' class InventoryitemTest < ActionController::IntegrationTest include Devise::TestHelper test "Adds item" do visits "/inventoryitems" assert_response :success clicks "Add Item" page.should have_content "NEW ITEM" fill_in "Name", :with => "Name" fill_in "Cost", :with =>...
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
#!/usr/bin/ruby require 'cgi' # Set this to the path of your database file. # $FILE = "/cs/cgi/people/jdahern/database.txt" $FILE = "/Users/jdahern/Documents/Dropbox/CS372/ass8/database.txt" $cgi = CGI.new("html3") ############################################################### # User ###############################...
Ruby
#!/usr/bin/ruby require 'cgi' $cgi = CGI.new("html3") def calcForm(left, op, right, value) addselected = (op=="add")?"selected":"" mulselected = (op=="mul")?"selected":"" return <<-END <center><h1>Welcome to the calculator!</h1></center><br> <form target="calc.cgi"> <center> <input ty...
Ruby
#!/usr/bin/ruby require 'cgi' # Set this to the path of your database file. $FILE = "database.txt" # $FILE = "/Users/jdahern/Documents/Dropbox/CS372/ass8/database.txt" $cgi = CGI.new("html3") $FRIEND_OPTIONS = {"dated" => "dated", "family" => "in my family", "friend" => "met through a friend", "work" => "worke...
Ruby
#!/usr/bin/ruby require 'cgi' # Set this to the path of your database file. # $FILE = "/cs/cgi/people/jdahern/database.txt" $FILE = "/Users/jdahern/Documents/Dropbox/CS372/ass8/database.txt" $cgi = CGI.new("html3") ############################################################### # User ###############################...
Ruby
#!/usr/bin/ruby require 'cgi' $cgi = CGI.new("html3") def calcForm(left, op, right, value) addselected = (op=="add")?"selected":"" mulselected = (op=="mul")?"selected":"" return <<-END <center><h1>Welcome to the calculator!</h1></center><br> <form target="calc.cgi"> <center> <input ty...
Ruby
#!/usr/bin/ruby require 'cgi' # Set this to the path of your database file. $FILE = "database.txt" # $FILE = "/Users/jdahern/Documents/Dropbox/CS372/ass8/database.txt" $cgi = CGI.new("html3") $FRIEND_OPTIONS = {"dated" => "dated", "family" => "in my family", "friend" => "met through a friend", "work" => "worke...
Ruby
$FILE = "/Users/jdahern/Documents/Dropbox/CS372/ass8/database.txt" ############################################################### # User ############################################################### class User attr_reader :username, :name, :friends, :sex, :password attr_writer :username, :name, :sex, :password ...
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
class ChangeUserTable2 < ActiveRecord::Migration def self.up change_table :users do |t| t.boolean :is_active end end def self.down end end
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.string :username t.string :password t.string :name t.string :email t.boolean :is_admin t.timestamps end end def self.down drop_table :users end end
Ruby
class CreatePosts < ActiveRecord::Migration def self.up create_table :posts do |t| t.references :user t.text :data t.references :post t.timestamps end end def self.down drop_table :posts end end
Ruby
class ChangePostTable2 < ActiveRecord::Migration def self.up change_table :posts do |t| t.float :score_total end end def self.down end end
Ruby
class CreateVotes < ActiveRecord::Migration def self.up create_table :votes do |t| t.references :user t.references :post t.timestamps end end def self.down drop_table :votes end end
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
source 'http://rubygems.org' gem 'rails', '3.0.9' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'sqlite3' # Use unicorn as the web server # gem 'unicorn' # Deploy with Capistrano # gem 'capistrano' # To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1....
Ruby
#!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands'
Ruby
module ApplicationHelper end
Ruby
module UsersHelper end
Ruby
module PostsHelper end
Ruby
module VotesHelper end
Ruby
class Post < ActiveRecord::Base belongs_to :user belongs_to :post has_many :votes # Validation # Author of the post is required. validates :user_id, :presence => true # The post must contain some data. validates :data, :presence => true # Make sure that if this is supposed to be a reply that the po...
Ruby
class User < ActiveRecord::Base has_many :posts has_many :votes # Attributed used to store the password passed in by the forms. This is necessary # to be able to encrypt the password before storing it into the database. attr_accessor :rpassword # Attribute used when creating or editing a user. The current...
Ruby
class Vote < ActiveRecord::Base belongs_to :user belongs_to :post # Validation # Both the user and post are required to make a vote. validates :user_id, :presence => true validates :post_id, :presence => true # A user cannot vote on the same post more than once. validates :user_id, :uniqueness => { :s...
Ruby
class PostsController < ApplicationController # Make sure the user is logged in to access these actions. before_filter :login_required, :except => [:all,:search,:top] before_filter :owner_required || :admin_required, :only => [:edit, :update] before_filter :admin_required, :except => [:all,:search,:top,:new,:c...
Ruby
class ApplicationController < ActionController::Base protect_from_forgery before_filter :set_current_user protected # Defines the current_user variable to store the current user's information if they are logged in. def set_current_user @current_user = User.find(session[:id]) if @current_user.nil? and s...
Ruby
class VotesController < ApplicationController # Make sure the user is logged in to access these actions. before_filter :login_required before_filter :admin_required, :except => [:new,:create] # GET /votes # GET /votes.xml def index @votes = Vote.all respond_to do |format| format.html # index...
Ruby
class UsersController < ApplicationController # Make sure the user is logged in to access these actions. before_filter :login_required, :except => [:login,:new,:create,:show] before_filter :yours_required || :admin_required, :only => [:edit, :update] before_filter :admin_required, :except => [:login,:logout,:ne...
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. # 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. Csc517proj1::Application.config.session_store :cookie_store, :key => '_csc517proj1_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
Csc517proj1::Application.routes.draw do resources :votes resources :posts do collection do get "all" post "new_reply" post "search" get "top" end end resources :users do get :details, :on => :member get :deactivate, :on => :member get :activate, :on => :member ...
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 you have a Gemfile, require the gems listed there, including any gems # you've limited to :test, :development, or :production. Bundler.require(:default, Rails.env) if defined?(Bundler) module Csc517proj1 class Application < Rails::Application ...
Ruby
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application Csc517proj1::Application.initialize!
Ruby
Csc517proj1::Application.configure do # Settings specified here will take precedence over those in config/application.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Full error reports are disabled and caching is turne...
Ruby
Csc517proj1::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
Csc517proj1::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
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run Csc517proj1::Application
Ruby
# 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__) require 'rake' Csc517proj1::Application.load_tasks
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__) Blog::Application.load_tasks
Ruby
#!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands'
Ruby
#!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands'
Ruby
class CreateOrganizations < ActiveRecord::Migration def change create_table :organizations do |t| t.timestamps end end end
Ruby
class CreateGroups < ActiveRecord::Migration def change create_table :groups do |t| t.string :name t.timestamps end end end
Ruby
class AddBoolToInvitee < ActiveRecord::Migration def change add_column :invitee_lists, :attended, :boolean end end
Ruby
class AddIdtoPost < ActiveRecord::Migration def change add_column :posts, :author_id, :int end end
Ruby
class ChangeDatetodate < ActiveRecord::Migration def change remove_column :events, :date add_column :events, :date, :date end end
Ruby
class AddIdToLocation < ActiveRecord::Migration def change add_column :locations, :event_id, :integer end end
Ruby
class CreateInviteeLists < ActiveRecord::Migration def change create_table :invitee_lists do |t| t.integer :user_ids t.references :event t.timestamps end add_index :invitee_lists, :event_id end end
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.string :email t.string :hashed_password t.string :salt t.string :created_at #id already included t.string :first_name t.string :middle_name t.string :last_name #list of groups...
Ruby
class CreateLocations < ActiveRecord::Migration def change create_table :locations do |t| t.string :locationName t.string :locationDescription t.string :addressName t.string :addressLn1 t.string :addressLn2 t.string :city t.string :stateCode t.string :zipCode ...
Ruby
class CreatePosts < ActiveRecord::Migration def change create_table :posts do |t| t.string :name t.string :title t.text :content t.timestamps end end end
Ruby
class AddTimeToEvents < ActiveRecord::Migration def change add_column :events, :time, :time end end
Ruby
class CreateEvents < ActiveRecord::Migration def change create_table :events do |t| t.string :name t.string :author t.text :description t.date :date t.text :location t.timestamps end end end
Ruby
class ChangeDateToDatetime < ActiveRecord::Migration def change remove_column :events, :date remove_column :events, :time add_column :events, :starts_at, :datetime end end
Ruby
class CreateResponses < ActiveRecord::Migration def change create_table :responses do |t| t.string :commenter t.text :body t.references :event t.timestamps end add_index :responses, :event_id end end
Ruby
class CreateComments < ActiveRecord::Migration def change create_table :comments do |t| t.string :commenter t.text :body t.references :post t.timestamps end add_index :comments, :post_id end end
Ruby
class AddIdtoEvent < ActiveRecord::Migration def change add_column :events, :author_id, :int 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
#!/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__) Blog::Application.load_tasks
Ruby
source 'http://rubygems.org' gem 'rails', '3.2.3' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'pg' gem 'xml-simple' gem 'json' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', '~> 3.2.3' ge...
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run Blog::Application
Ruby
class Response < ActiveRecord::Base belongs_to :event attr_accessible :body, :commenter end
Ruby
class Organization < ActiveRecord::Base # attr_accessible :title, :body end
Ruby
class Group < ActiveRecord::Base # attr_accessible :title, :body has_many :users belongs_to :organization end
Ruby
class InviteeList < ActiveRecord::Base attr_accessible :user_ids, :event_id belongs_to :event end
Ruby
class Event < ActiveRecord::Base attr_accessible :name, :author, :description, :starts_at, :location validates :name, :presence => true validates :description, :presence => true validates :starts_at, :presence => true validates :location, :presence => true has_many :responses has_one :inviteeList...
Ruby
class Post < ActiveRecord::Base attr_accessible :content, :name, :title validates :name, :presence => true validates :title, :presence => true, :length => { :minimum => 5 } has_many :comments end
Ruby
require 'digest/sha1' class User < ActiveRecord::Base attr_accessible :password, :password_confirmation, :email, :first_name, :middle_name, :last_name, :phone_num, :address, :alt_email, :authority validates_length_of :email, :within => 3..40 ########### # VALIDATION NEEDS TO BE MOVED OUT OF THE MODEL # va...
Ruby
class Location < ActiveRecord::Base attr_accessible :addressLn1, :addressLn2, :addressName, :city, :gmapString, :locationDescription, :locationName, :stateCode, :zipCode, :event_id end
Ruby
class Comment < ActiveRecord::Base belongs_to :post attr_accessible :body, :commenter end
Ruby
module LocationsHelper end
Ruby
module ApplicationHelper end
Ruby
module PostsHelper end
Ruby
module UsersHelper end
Ruby
module ResponsesHelper end
Ruby
module HomeHelper end
Ruby
module CommentsHelper end
Ruby
module EventsHelper end
Ruby
module InviteeListsHelper end
Ruby
class Notification < ActionMailer::Base default from: "adelmoral13@gmail.com" def welcome_email(user) @user = user @url = "http://cel.herokuapp.com/login" mail(:to => @user.email, :subject => "Welcome to Student Organization") end def forgot_password(user, pass) @user = user @url = "http://cel.h...
Ruby
class CommentsController < ApplicationController def create @post = Post.find(params[:post_id]) @comment = @post.comments.create(params[:comment]) redirect_to post_path(@post) end # DELETE /comments/1 # DELETE /comments/1.json def destroy @comment = Comment.find(params[:id]) @comm...
Ruby
class ResponsesController < ApplicationController def create @event = Event.find(params[:event_id]) @response = @event.responses.create(params[:response]) redirect_to event_path(@event) end # DELETE /responses/1 # DELETE /responses/1.json def destroy @response = Response.find(params[:...
Ruby
require "net/http" require "uri" require "rubygems" require 'xmlsimple' class EventsController < ApplicationController # GET /events # GET /events.json def index @events = Event.all respond_to do |format| format.html # index.html.erb format.json { render :json => @events } end end #...
Ruby
class HomeController < ApplicationController def index end end
Ruby
#remember to finish up on the application controller...
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 ApplicationController < ActionController::Base protect_from_forgery def login_required if session[:user] return true end flash[:warning]='Please login to continue' session[:return_to]=request.url redirect_to :controller => 'user', :action => 'login' return false ...
Ruby
class InviteeListsController < ApplicationController def create @event = Event.find(params[:event_id]) @inviteeList = @event.inviteeLists.create(params[:inviteeList]) redirect_to event_path(@event) end # DELETE /users/1 # DELETE /users/1.json def destroy @invitee = Invite...
Ruby
class PostsController < ApplicationController # GET /posts # GET /posts.json def index @posts = Post.all respond_to do |format| format.html # index.html.erb format.json { render :json => @posts } end end # GET /posts/1 # GET /posts/1.json def show @post = Post.find(params[:id...
Ruby
class UsersController < ApplicationController before_filter :login_required, :only=>['welcome', 'change_password', 'hidden'] # GET /users # GET /users.json def index @users = User.all respond_to do |format| format.html # index.html.erb format.json { render :json => @users } end e...
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
Blog::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.action_co...
Ruby
Blog::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 web serve...
Ruby
Blog::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 test suite...
Ruby