text
stringlengths
10
2.61M
class TestsController < ApplicationController authorize_resource before_action :set_test, only: [:show, :edit, :update, :destroy] respond_to :json def index @tests = Test.all respond_with(@tests) end def show respond_with(@test) end def create @test = Test.new(test_params) ...
require "rspec" require_relative "account" describe Account do let(:my_account) { Account.new("1023456789",100) } context "#initialize" do it "should be an instance of Account" do expect(my_account).to be_an_instance_of Account end it "should set account number" do expect(my_account.acct_...
require "spec_helper" describe Api::ExerciseSessionsController, type: :controller do before do coach = create(:coach) login(coach) @exercise_plan = create(:exercise_plan, user: coach) @exercise_session = create(:exercise_session, exercise_pla...
class Navegador require 'selenium-webdriver' require 'nokogiri' attr_accessor :driver, :ciudad1, :ciudad2, :fecha def initialize(ciudad1 = nil ,ciudad2 = nil,fecha = Date::today) @driver = Selenium::WebDriver.for :chrome @ciudad1 = ciudad1 @ciudad2 = ciudad2 @fecha = fecha end def get_precio @driver...
class AddAcceptColumnToRequest < ActiveRecord::Migration def change add_column :requests, :accepted_offer, :boolean, default: nil end end
class Item < ApplicationRecord belongs_to :user has_one_attached :image has_one :buy extend ActiveHash::Associations::ActiveRecordExtensions belongs_to_active_hash :goods_category belongs_to_active_hash :goods_condition belongs_to_active_hash :shipping_charge belongs_to_active_hash :shipping_area b...
require './test/test_helper' feature 'View general list of projects' do scenario 'see all projects' do # Given that I want to see all projects # When I visit the index page visit projects_path # Then I see projects listed page.text.must_include 'Grimoire' page.text.must_include 'Heatmap' ...
require 'rails_helper' RSpec.describe User, type: :model do it { should validate_presence_of(:name) } context "sign in with omniauth" do let!(:exists_user) { FactoryGirl.create(:user) } let(:auth_info) { OmniAuth::AuthHash.new({ provider: 'github', uid: 9999, info: { ...
# Copyright (c) 2015 Vault12, Inc. # MIT License https://opensource.org/licenses/MIT require 'test_helper' require 'mailbox' class EncryptDecryptTest < ActionDispatch::IntegrationTest test 'encrypt and decrypt' do # generate alice's secret key @alicesk = RbNaCl::PrivateKey.generate # generate public ke...
class Platform::ExpressesController < Platform::BaseController def index @expresses = current_user.expresses.page(params[:page]) end def new @express = Express.new end def create @express = Express.new express_params @express.creator = current_user if @express.save flash[:notice] ...
# == Schema Information # # Table name: contributions # # id :integer not null, primary key # amount :float # project_id :integer # user_id :integer # payment_status :string(255) default("UNPROCESSED") # anonymous :boolean default(FALSE) # created_at ...
class AddBidRequestIdToMessageDeliveries < ActiveRecord::Migration def change add_column :message_deliveries, :bid_request_id, :integer end end
class HelloWorker include Sidekiq::Worker def perform(sidekiq_plan_id) sidekiq_plan = SidekiqPlan.find(sidekiq_plan_id) sidekiq_plan.started! puts "Hello, world!" sidekiq_plan.finished! rescue sidekiq_plan.failed! end end
require 'rails_helper' require 'byebug' RSpec.describe KepplerFrontend::Urls::Assets, type: :services do context 'assets urls' do before(:all) do @root = KepplerFrontend::Urls::Roots.new end context 'rails root' do it { expect(@root.keppler_root).to eq(Rails.root) } end context 'f...
class CreateCounties < ActiveRecord::Migration[5.1] def change create_table :counties do |t| t.string :name, :unique => true t.integer :county_code, :unique => true t.multi_polygon :geom, :srid => 4326 #t.timestamps null: false end change_table :counties do |t| t.index :geom, u...
class Topic < ActiveRecord::Base include MyConstants #acts_as_taggable belongs_to :user belongs_to :topic_type has_many :users has_many :topic_infos,:foreign_key=>'topic_id',:dependent=>:destroy has_many :topic_info_types,:foreign_key=>'topic_id',:dependent=>:destroy has_many :team_topics has_man...
class Wallet attr_reader :cents def initialize @cents = 0 @wallet = {0 => 0, :penny => 1, :nickel => 5, :dime => 10, :quarter => 25, :dollar => 100} end def <<(cents_key) @cents = @cents + @wallet[cents_key] end def take(coin, coin2 = 0) if @wallet[coin] > @cents @cents else ...
class CreateAuthors < ActiveRecord::Migration def up create_table :authors do |t| t.text :name t.text :twitter t.timestamps t.integer :image_id end end def down drop_table :authors end end
require File.dirname(__FILE__) + '/../test_helper' require 'tag_selections_controller' # Re-raise errors caught by the controller. class TagSelectionsController; def rescue_action(e) raise e end; end class TagSelectionsControllerTest < Test::Unit::TestCase fixtures :tag_selections def setup @controller = Tag...
require 'uri' require 'faraday_middleware' module Roe class Client attr_accessor :endpoint, :format attr_accessor *Configuration::VALID_OPTIONS_KEYS def initialize(endpoint, format = :json) @endpoint = endpoint @format = format Configuration::VALID_OPTIONS_KEYS.each do |key| s...
# == Schema Information # # Table name: categories # # id :bigint not null, primary key # name :string # image :string # created_at :datetime not null # updated_at :datetime not null # parent_id :bigint # class Category < ApplicationRecord has_many :products has_m...
# -*- mode: ruby -*- # vi: set ft=ruby : VM_NUM = 2 # netmask 255.255.255.0 IP_PREFIX = "172.16.42" IMAGE = "bento/ubuntu-22.04" Vagrant.configure(2) do |config| # limit the cpus and memory usage config.vm.provider "virtualbox" do |v| v.memory = 1024 v.cpus = 2 end (1..VM_NUM).each do |...
class CommentsController < ApplicationController before_action :authenticate_user! load_and_authorize_resource :project load_and_authorize_resource :comment, through: :project def index @comments = Comment.where(project_id: params[:project_id]).accessible_by(current_ability) end def create @project...
class Order < ApplicationRecord belongs_to :user, optional: true has_many :order_items, dependent: :delete_all enum status: { cart: 0, ordered: 1, confirmed: 2, on_the_way: 3, completed: 4, deferred: 5 } has_attached_file :contract_of_sale validates_attachment :contract_of_sale, :content_type => {:content_t...
class MatchesController < ApplicationController MATCH_PARAM_FIELDS = [ :map_id, :rank, :comment, :prior_match_id, :placement, :result, :time_of_day, :day_of_week, :season, :enemy_thrower, :ally_thrower, :enemy_leaver, :ally_leaver, :account_id ].freeze before_action :authenticate_user!, except: :inde...
class CreateAlunos < ActiveRecord::Migration[5.2] def change create_table :alunos do |t| t.string :nome t.string :rg t.string :cpf t.date :dtnasc t.string :telefone t.string :celular t.integer :sexo t.integer :status t.references :endereco, foreign_key: true ...
class ContestAction < ActiveRecord::Base default_scope where('status != ?', "deleted") default_scope order('created_at desc') attr_accessible :id, :contest_id, :user_id, :location_id, :item_id, :item_name, :type, :photo_url, :facebook, :twitter, :instagram, :grade, :comment, :status, :created_at belongs_to :us...
class AddRatingCountToPhotopost < ActiveRecord::Migration[6.0] def change add_column :photoposts, :rating_count, :integer, default: 0 add_column :photoposts, :comments_count, :integer, default: 0 end end
class User < ApplicationRecord has_many :orders, dependent: :destroy has_one :profile, dependent: :destroy devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable def has_profile? profile.present? && !profile.id.nil? end def full_name profile.ful...
class CampaniaController < ApplicationController before_action :set_campanium, only: [:show, :edit, :update, :destroy] # GET /campania # GET /campania.json def index @campania = Campanium.all end # GET /campania/1 # GET /campania/1.json def show end # GET /campania/new def new @campaniu...
class FavouritesController < ApplicationController before_action :authenticate_user! def index user = User.find(params[:user_id]) @products = user.favourited_products render 'favourites/index' end def create product = Product.find(params[:product_id]) if cannot? :favourite, product ...
class CreateExits < ActiveRecord::Migration def change create_table :exits do |t| t.column :exit_id, :integer t.column :name, :string t.column :description, :string t.column :transition_msg, :string t.column :command, :string, :limit => 1 t.column :origin_id, :integer t.c...
require_relative './test_base' require 'experiment' require 'test/unit' require 'tmpdir' require 'json' class TestSignal < ExperimentTestCase def test_sig ["TERM", "INT"].each do |s| @e["arguments"] = ["$SRC/test", "5000"] @e["iterations"] = 10 Dir.mktmpdir("test_", ".") {|d| build d d = File.ab...
module EasyPatch module RolesHelperPatch def self.included(base) # :nodoc: base.class_eval do def sorted_permission_keys(permissions) permissions.keys.sort_by do |x| case x.to_s when '' '' when 'easy_other_permissions' ...
class ItemsController < ApplicationController respond_to :html before_filter :authenticate_user!, :except => [:show, :welcome, :videos, :contact, :mailchimp] before_filter :find_item, :only => [:show, :edit, :update, :destroy] def pages @items = Page.list_order render 'index' end def categories ...
module Recliner class ViewFunction class_inheritable_accessor :definition def initialize(body) if body =~ /^\s*function/ @body = body else @body = "#{definition} { #{body} }" end end def to_s @body end def ==(other) to_s == other.to_...
class Api::V1Controller < ApiController include CanCan::ControllerAdditions rescue_from CanCan::AccessDenied do |e| render :json=>{success: false, error: e.message}, :status => 403 end def current_user @current_user ||= AuthCommands.current_user(params[:token]) end def can_vi...
#!/usr/bin/env rspec # Encoding: utf-8 require 'spec_helper' provider_class = Puppet::Type.type(:package).provider(:portagegt) describe provider_class do describe '#package_settings_insync?' do before :each do # Stub some provider methods to avoid needing the actual software # installed, so we can ...
class AddBodyToResearch < ActiveRecord::Migration[5.1] def change add_column :researches, :body, :text end end
log " ********************************************** * * * Recipe:#{recipe_name} * * * ********************************************** " thisdir = '/tmp/.oracle' #per doc id...
# PEDAC # Problem # Write a method that will take an array of numbers, and return the number of primes # in the array. # Input: array # Output: integer (the number of primes in the input array) # Examples / Test Cases # count_primes([1, 2, 3, 4]) == 2 # count_primes([4, 6, 8, 10]) == 0 # count_primes([0, 7, 8, 11, 21...
class HelloEepromLcdpa < ArduinoSketch # ----------------------------------------------------------------------- # Simple Byte Write and Byte Read-back of I2C EEPROM # # Brian Riley - Underhill Center, VT, USA July 2008 # <brianbr@wulfden.org> # # I2C Routines are in a plug...
class SessionsController < ApplicationController before_filter RubyCAS::Filter, :except => :logout def new path = params[:source] || root_path redirect_to path end def destroy RubyCAS::Filter.logout(self) end end
class Getaway < ActiveRecord::Base attr_accessible :category_id, :content, :image, :name, :snippet, :meta_title, :meta_description, :slug, :town_id, :crop_x, :crop_y, :crop_w, :crop_h default_scope order(:name) attr_accessor :crop_x, :crop_y, :crop_w, :crop_h, :crop_thumb, :crop_thumb_small validates :im...
FactoryBot.define do factory :user, class: "User" do name "John Schaffer" email "#{('a'..'z').to_a.shuffle.join}@yahoo.com" password "icedearth" password_confirmation "icedearth" end end
# frozen_string_literal: true class AddEventPriceToAttendance < ActiveRecord::Migration[4.2] def change add_column :attendances, :event_price, :decimal end end
# Example 1 # Take a moment to digest the following example: # [[1, 2], [3, 4]].each do |arr| # puts arr.first # end # 1 # 3 # => [[1, 2], [3, 4]] # So what's happening in this, seemingly simple, piece of code? # Take it apart and try to describe every interaction with precision. # .each method is invoked on the...
class Review < ApplicationRecord belongs_to :restaurant validates :content, :rating, presence: true validates :rating, inclusion: { in: [ 0 , 1 , 2 , 3 , 4 , 5 ]} validates :rating, numericality: { only_integer: true } end
# frozen_string_literal: true require 'yaml' namespace :mvr do desc 'generate gnuplot scripts' task :generate_scripts do yml = YAML.load_file('./mvr/parameters/simulate.yml') options = Simulation::Options.new(yml) options.jobs_options.each do |job_options| job_options.plots_options.each do |opt...
class EmployerSesssion < ActiveType::Object attribute :email, :string attribute :phone_number, :string validates :email, presence: true def self.employer(email) Employer.sign_in(email) end end
TagTextType = GraphqlCrudOperations.define_default_type do name 'TagText' description 'Tag text type' interfaces [NodeIdentification.interface] field :dbid, types.Int field :text, types.String field :tags_count, types.Int end
class CreateOrdenproduccions < ActiveRecord::Migration def change create_table :ordenproduccions do |t| t.datetime :fechaprogramacion t.string :ordennumero t.references :cliente, index: true t.text :descripcion t.string :referencia t.string :corte t.string :ancho t....
# 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 rails db:seed command (or created alongside the database with db:setup). # # Examples: # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) ...
class Event include DataMapper::Resource property :id, Serial property :name, String, :required => true property :max, Integer property :date, DateTime, :required => true property :members, String property :slug, String property :short_url, String property :hay_notificaciones, Integer, :default => 0...
module Zenform module Param class TicketForm < Base FIELDS = %w{name position end_user_visible display_name ticket_field_ids} FIELDS.each { |field| attr_reader field } attr_reader :ticket_fields def initialize(content, ticket_fields: {}, **_params) super @ticket_fields = t...
module PropertyScraper class VrboScraper < Scraper def self.can_scrape?(url) url =~ /.*vrbo.com\/.*/ end def name @name ||= self.find('.reviews-container .rating-box .item .fn') end def location @location ||= @wrapped_document.at("//meta[@name='Location']/@content").value.gsub...
class Gcode < ApplicationRecord belongs_to :model [:filename, :filament_length, :print_time].each do |field| validates field, presence: true end end
require 'csv' require 'pry' namespace :import do desc "concatenate category name to med and large restaurants" task update_names: :environment do categorize = Categorize.new categorize.concat_name_and_category(Restaurant.return_med_and_large) end end
# Имеет номер (произвольная строка) и тип (грузовой, пассажирский) и количество вагонов, эти данные указываются при создании экземпляра класса # Может набирать скорость # Может возвращать текущую скорость # Может тормозить (сбрасывать скорость до нуля) # Может возвращать количество вагонов # Может прицеплять/отцеплять ...
# frozen_string_literal: true class League include Mongoid::Document field :name, type: String include Mongoid::Timestamps has_many :divisions, foreign_key: 'custom_league_id' validates_presence_of(:name) def custom_name "League '#{name}'" end end
class TasksController < ApplicationController before_action :set_list before_action :set_task, only: [:edit, :update, :destroy] def new @task = Task.new end def create @task = @list.tasks.new(task_params) if @task.save redirect_to board_path(@list.board_id) else render :new end end def updat...
class Client < ApplicationRecord belongs_to :user has_many :projects, dependent: :destroy has_many :payments, through: :projects has_one_attached :avatar validates :name, presence: true end
require "yaml" require 'pry' def load_library(path) emoticons = YAML.load_file(path) new_hash = {} emoticons.each do |emotion, array| new_hash["get_meaning"] ||= {} new_hash["get_emoticon"] ||= {} new_hash["get_meaning"][array.last] ||= emotion new_hash["get_emoticon"][array.first] ||= array.l...
class PlaydatesController < ApplicationController #before_action :require_login def new @playdate = Playdate.new @family = current_user.family end def create @playdate = Playdate.new(playdate_params) @playdate.save redirect_to playdate_path(@playdate) end def show @playdate = Pl...
class ProjectManagerSerializer < ActiveModel::Serializer attributes :job_id, :user_id has_one :user has_one :contact end
# frozen_string_literal: true require 'spec_helper' # Test Plan scenarios from the handshake spec SCENARIOS = { 'Valid AWS' => { 'AWS_EXECUTION_ENV' => 'AWS_Lambda_ruby2.7', 'AWS_REGION' => 'us-east-2', 'AWS_LAMBDA_FUNCTION_MEMORY_SIZE' => '1024', }, 'Valid Azure' => { 'FUNCTIONS_WORKER_RUNTIME...
# Code shared between `Mdm::Reference` and `Metasploit::Framework::Reference`. module Metasploit::Model::Reference extend ActiveModel::Naming extend ActiveSupport::Concern include Metasploit::Model::Translation included do include ActiveModel::MassAssignmentSecurity include ActiveModel::Validations ...
require "features_helper" RSpec.feature "Admin User page functionality", type: :feature do let(:owner) { create(:admin, :power_user) } let!(:ihmi) { create(:organization, name: "IHMI") } let!(:path) { create(:organization, name: "PATH") } let!(:group_bathinda) { create(:facility_group, organization: ihmi, name...
class UsersController < ApplicationController before_action :require_login, except: [:index, :new, :create] before_action :set_user, except: [:index, :new, :create] before_action :require_correct_user, only: [:show, :edit, :update, :destroy] def index if current_user redirect_to "/users/#{current_use...
class CreateApplications < ActiveRecord::Migration def change create_table :applications do |t| t.string :path t.string :cmd_start t.string :cmd_restart t.string :cmd_stop t.integer :user_id t.string :release t.timestamps end end end
require 'ostruct' require 'forwardable' require 'time' require 'hashup' require 'habitica_client/restful' class HabiticaClient # A user task, which can be a habit, daily, or todo. class Task < HabiticaClient::Restful require 'habitica_client/task/date_accessor' require 'habitica_client/task/status' r...
require 'test_helper' class Admin::MenuControllerTest < ActionDispatch::IntegrationTest include Devise::Test::IntegrationHelpers def setup menus(:week2).make_current! sign_in users(:kyle) end test "get index" do get '/admin/menus' assert_response :success end test "get show" do obj =...
# Refs: # => http://devblog.avdi.org/2012/08/31/configuring-database_cleaner-with-rails-rspec-capybara-and-selenium/ # => http://blog.bignerdranch.com/1617-sane-rspec-config-for-clean-and-slightly-faster-specs/ # => https://github.com/bmabey/database_cleaner RSpec.configure do |config| config.before(:suite) do D...
module Ginatra class RepoStats # @param [Ginatra::Repo] repo Ginatra::Repo instance # @param [String] ref Branch or tag name of repository # @return [Ginatra::RepoStats] def initialize(repo, ref) @repo = repo @ref = repo.branch_exists?(ref) ? repo.ref("refs/heads/#{ref}") : repo.ref("refs/...
class UpdateHistoryCheckInOutViewsToVersion4 < ActiveRecord::Migration def change update_view :history_check_in_out_views, version: 4, revert_to_version: 3, materialized: true end end
class UsersController < ApplicationController before_action :authenticate_user! before_action :load_user def show type = params[:type] if type == "favorite_movie" @movies = current_user.movies.paginate(page: params[:page], per_page: 6) end end private def load_user @user = User.find_...
require "./config/data_mapper" require "sinatra/base" namespace :db do desc "upgrade my DB" task :auto_upgrade do DataMapper.auto_upgrade! if ENV['RACK_ENV'] == 'development' puts "Upgrade successful !" end desc "migrate my DB" task :auto_migrate do DataMapper.auto_migrate! if ENV['RACK_ENV'] == 'test...
class MatchedEffort < ApplicationRecord belongs_to :organisation belongs_to :activity FUNDING_TYPE_CODES = Codelist.new(type: "matched_effort_funding_type", source: "beis") CATEGORY_CODES = Codelist.new(type: "matched_effort_category", source: "beis") enum funding_type: FUNDING_TYPE_CODES.hash_of_coded_name...
class Direction < ActiveRecord::Base has_many :accesses, dependent: :destroy end
class AiPlayer attr_reader :name def initialize(name) @name = name end def guess(fragment, num_players) letter = winning_move(fragment, num_players) if letter letter else loop do letter = ('a'..'z').sample break if yield(letter) end end letter end ...
class Wallet < ActiveRecord::Base include Archiving has_many :transactions belongs_to :concernable, polymorphic: true def self.create_for_concernable concernable concernable.create_wallet unless concernable.wallet.present? end end
require 'rails_helper' RSpec.describe Group, :type => :model do let (:group){FactoryGirl.create(:group)} let (:user){FactoryGirl.create(:user)} let (:jef){FactoryGirl.create(:user)} let (:args) {{group_id: group.id, user_id:jef.id, description: "Winkel",amount: 10}} it "has a valid factor...
class InventoryModelsController < ApplicationController before_action :set_inventory_model, only: [:show, :edit, :update, :destroy] before_action :authenticate_user!, except: [:index, :show] # GET /inventory_models # GET /inventory_models.json def index @inventory_models = InventoryModel.all end # ...
class OrderItemsController < ApplicationController before_action :prepare_order, :prepare_order_item, only: :add_to_cart def destroy @order = current_order @order_item = @order.order_items.find(params[:id]) @order_item.destroy @order_items = @order.order_items end def add_to_cart store_ses...
class Ckeditor::Asset include Ckeditor::Orm::Mongoid::AssetBase delegate :url, :current_path, :size, :content_type, :filename, :to => :data validates_presence_of :data belongs_to :orig, class_name: 'TextDocument', autosave: true end
require 'minitest/autorun' require 'minitest/nyan_cat' require './lib/router' require 'pry' class RouterTest < Minitest::Test attr_reader :router, :request def setup @router = Router.new @request = {} end def test_route_hello_returns_hello_world request = {'Path' => "/hello"} assert_equal "He...
#encoding: utf-8 class Organisation < ActiveRecord::Base # Constants # Put here constants for Organisation # Relations has_many :work_orders, dependent: :restrict_with_error has_many :users # Callbacks # Put here custom callback methods for Organisation # Validations validates :name, presence: t...
require 'test_helper' class BlogTest < ActiveSupport::TestCase def setup Blog.delete_all end test "sould not save without a title" do b = Blog.new assert !b.valid?, "A blog without a title should not be valid" b.title = 'My Testtitle' assert b.valid?, "A blog with a title sould be valid" ...
require "spec_helper" describe "issues/show.html.erb" do let(:issue) { FactoryBot.create(:issue) } let(:double_controller) { double(ApplicationController, params: ActionController::Parameters.new(id: issue.friendly_id)) } let(:issue_detail) { IssueDetail.build(double_controller) } it "succeeds" do @issue_...
class Web::SectionsController < Web::WebController layout "web/referendum" before_filter :set_last_id def test_proxy t = params[:sleep].to_i sleep(t) render :nothing=>true end def topics add_breadcrumb "Témata", topics_path render :layout=>"web/gallery" end def index redirect_to...
require 'spec_helper' module EZAPIClient RSpec.describe GenPasswordToken do it "generates a password token" do result = described_class.( prv_path: CONFIG[:prv_path], eks_path: CONFIG[:eks_path], username: CONFIG[:username], password: CONFIG[:password], reference_no...
require 'netlink/constants' module Netlink module Util PAD_BYTE = [0].pack('C') class << self def align(length, alignto=Netlink::NLMSG_ALIGNTO) # Round to the nearest multiple of alignto (length + alignto - 1) & ~(alignto - 1) end # Pads the supplied string until aligned ...
class Admin::ThoughtsController < ApplicationController before_filter :require_thought_creator! respond_to :html def index if is_admin? @thoughts = Thought.order(:weight) else @thoughts = current_user.thoughts.order(:weight) end respond_with(@thoughts) end def show @thought = Thought.find(param...
class FavoriteMoviesController < ApplicationController before_action :set_movie def create @movie.favorite = true @movie.save redirect_to movies_path notice: 'Peli agregada a favoritos' end def destroy @movie.favorite = false @movie.save redirect_to movies_path notice: 'Peli elim...
# frozen_string_literal: true RSpec.describe ProgressNotifier do subject { ProgressNotifier.new(topic_arn: topic_arn, effort_data: effort_data, sns_client: sns_client) } let(:topic_arn) { 'arn:aws:sns:us-west-2:998989370925:d-follow_joe-lastname-1' } let(:effort_data) { {full_name: 'Joe LastName 1', ...
class CreateGames < ActiveRecord::Migration def change create_table :games do |t| t.text :description t.text :summary t.text :variations t.text :example t.integer :maximum t.integer :minimum t.integer :total_stars, :default => 0 t.integer :num_of_reviews, :default =...
class TeachersController < ApplicationController def index @teachers = Teacher.all end def new @teacher = Teacher.new end def show @teacher = Teacher.find_by(id: params[:id]) @class_room = ClassRoom.find_by(id: @teacher.class_room) end def create @teache...
module LayoutHelper attr_accessor :title, :heading, :heading_image, :body_class, :crumbs #for any options that match setter methods, set them. Raise errors for the rest. def layout_options(options={}) return if options.blank? options = options.clone options.keys.each do |key| #if there is a la...
class Downloader::AbstractHandler < Object attr_accessor :request def initialize(request) self.request = request end def parameters request.parameters end def email request.email end def export_request_message_template config = Settings.downloader Hash.new.tap do |h| h[:ac...
Blog::Application.routes.draw do root 'layouts#application' scope :api do devise_for :users, controllers: { sessions: 'sessions', registrations: 'registrations' } resources :posts, defaults: {format: :json} end match '*path' => 'layouts#application', via: [:get, :post] end