text
stringlengths
10
2.61M
feature 'InvitationsController' do let!(:user){ create(:user) } describe 'send contact from webpage' do context 'send_contact' do it 'successfully sends contact email' do mail_count = ActionMailer::Base.deliveries.count visit "#{send_contact_invitations_path}.json?contact%5Bno...
# frozen_string_literal: true FactoryBot.define do factory :reservation do user schedule { find_or_create(:schedule, date: Time.zone.today, count: 10) } hour { (1..12).to_a.sample } guests { (1..10).to_a.sample } status :placed end end
# -*- coding: utf-8 -*- require File.expand_path("../test_helper", File.dirname(__FILE__)) require "s7n/gpass_file" require "time" module S7n class GPassFileTest < Test::Unit::TestCase # パスフレーズが不正な場合、 InvalidPassphrase 例外が発生する。 def test_read__invalid_passphrase invalid_passphrases = ["", "1234", "qwer...
require 'sorting_strategy' class CountingSort # Important Characteristics # 1. Must have values between (0, k) where k is larger than every value in the array # 2. Counting sort is extremely fast -- Theta(k + n), O(n) for worst case, best case and average # 3. Uses spaces O(k + n) # 4. Uses spaces O(k + n) ...
require "test_helper" class Admin::PostsControllerTest < ActionController::TestCase def setup setup_admin_user end def test_index post_1 = FactoryBot.create(:post, created_at: "2020-04-25") post_2 = FactoryBot.create(:post, created_at: "2020-04-26") get :index assert_template "admin/posts/...
class HimaDbDelta < Object #DbDelta = one migration command/one change to the database. require 'rubygems' require 'active_support/inflector' # * Adding a new table # * Removing an old table # * Renaming a table # * Adding a column to an existing table # * Changing a column's type and...
class HbaRule attr_accessor :line_no, :conn_type, :db_name, :user_name, :ip_addr, :net_mask, :auth_type, :comment def initialize args args.each do |k,v| ...
require 'spec_helper' describe RedisSet do let(:redis) { Redis.new } let(:name) { "some_set" } let(:set) { described_class.new(name, redis) } before do redis.flushall end context "instance methods" do describe '#all' do subject { set.all } it 'should return all the items in the set' do redis.sad...
################################### # framework rake tasks # # # # # # rake constants # # ENV['VERSION'] migrate版本号 # # ENV['GGA_ENV'] rake数据库环境 # ################################### # 加载核心模块 require './core/gga' # 加载自定义t...
class CreateUserLyrics < ActiveRecord::Migration[5.2] def change create_table :user_lyrics do |t| t.integer :user_id t.integer :lyric_id t.boolean :correct t.timestamps end end end
#!/home/takehiko/.rbenv/shims/ruby require "pg" class Response_To_Csv def initialize @csv_a = [] @csv_a << ["typed_char", "time1", "time2", "response_id", "question_id", "student_id", "start_at", "miss_count"] end def start connect_and_inquire make_table save_csv("response.csv") puts "s...
class Api::StoriesController < ApplicationController def index @stories = Story.includes(:author).all render :index end def show @story = Story.includes(:author).find(params[:id]) render :show end def create @story = Story.new(story_params) @s...
# frozen_string_literal: true class People < SitePrism::Section set_default_search_arguments '.people' element :headline, 'h2' element :dinosaur, '.dinosaur' # doesn't exist on the page elements :individuals, '.person' elements :optioned_individuals, 'span', class: 'person' # should not be found here ...
module Mirrors # A specific mirror for a class, that includes all the capabilites # and information we can gather about classes. # # @!attribute [rw] singleton_instance # @return [Mirror,nil] if a singleton class, the corresponding # instance. class ClassMirror < ObjectMirror # We are careful to...
class CreateVimCommands < ActiveRecord::Migration def change create_table :vim_commands do |t| t.string :mode_id t.string :command t.string :description t.timestamps end add_index :vim_commands, [:mode_id, :command], :unique end end
# == Schema Information # # Table name: onb_line_users # # id :bigint not null, primary key # line_uid :string # display_name :string # picture_url :string # status_message :string # language :string # archived :boolean default(FAL...
class Product < ActiveRecord::Base validates :title, :description, presence: true validates :price, numericality: { greater_than: 0 } validate :title_is_shorter_than_description validate :title_downcase def title_is_shorter_than_description return if title.blank? or description.blank? if title.length > descr...
# @param {Integer[]} target # @param {Integer[]} arr # @return {Boolean} def can_be_equal(target, arr) t_map = Hash.new(){0} target.each do |i| t_map[i] += 1 end a_map = Hash.new(){0} arr.each do |i| a_map[i] += 1 end t_map.keys.each do |k| return false if t_map[k] != a_map[k] e...
class User < ActiveRecord::Base # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable # Setup accessi...
module FormHelpers include ActivityHelper def fill_in_actual_form(expectations: true, value: "1000.01", financial_quarter: "4", financial_year: "2019-2020", comment: nil, receiving_organisation: OpenStruct.new(name: "Example receiver", reference: "GB-COH-123", type: "Private Sector")) fill...
class WeathersController < ApplicationController before_action :find_weather, only: [:update] def create @weather = Weather.create!(weather_params) render json: @weather end def update @weather.update(weather_params) if @weather.save render json: @weather, status: :accepted else ...
# frozen_string_literal: true module ActiveInteractor # The ActiveInteractor version # @return [String] the ActiveInteractor version VERSION = '1.0.4' end
FactoryGirl.define do factory :user do password "password" password_confirmation "password" role "normal" end factory :alice, :parent => :user do login_name "alice" end end
# spec/support/models/army.rb require 'active_model/sleeping_king_studios/validations/relations' class Army include ActiveModel::Validations include ActiveModel::SleepingKingStudios::Validations::Relations attr_accessor :general def soldiers @soldiers ||= [] end # method soldiers attr_writer :soldi...
module Api module V1 class OrgsController < Api::V1::ApiController before_action :set_org, only: [:agents_info] def agents_info json = @org.to_json(only: [:id, :name, :slug], include: {agents: { only: [:id, :name, :slug] ...
# encoding: UTF-8 require 'test_helper' class SessionsControllerTest < ActionController::TestCase setup do @client = Client.create name: "John", email: "john@gmail.com", password: 'tre543%$#', password_confirmation: 'tre543%$#' end test "should get new" do get :new assert_response :success asse...
require 'pry' require_relative 'battle.rb' # Class one raper class Raper attr_reader :name def initialize(name, list = []) @name = name @battles = list end def bad_words @bad_words = @battles.sum(&:bad_words_count) end def all_words @all_words = @battles.sum(&:sum_all_words) end def ...
# frozen_string_literal: true require './method.rb' RSpec.describe Enumerable do ar1 = [1, 2, 3, 4, 5, 6, 7, 8, 9] describe '#my_select' do it 'should return the elements that passes the test' do expect(ar1.my_select { |x| x > 3 }).to eql([4, 5, 6, 7, 8, 9]) end it 'should return the multiple of...
# frozen_string_literal: true require 'traject' require_relative 'cover_images.macro' extend FindIt::Macros::CoverImages require_relative 'lbcc_format.macro' require_relative 'wikidata_enrichment.macro' extend FindIt::Macros::WikidataEnrichment to_field 'thumbnail_path_ss', cover_image to_field 'id', extract_marc('...
module Refinery module PageResources include ActiveSupport::Configurable config_accessor :captions config_accessor :captions, :attach_to self.captions = true self.attach_to = [ { :engine => 'Refinery::Page', :tab => 'Refinery::Pages::Tab' } ] end end
=begin #Location API #Geolocation, Geocoding and Maps OpenAPI spec version: 2.0.0 Generated by: https://openapi-generator.tech OpenAPI Generator version: 3.3.4 =end require 'date' module unwiredClient # You can send 1 to 7 cell ID objects. If your device supports scanning for more than 7 cell objects, reach out...
# encoding: UTF-8 class Film class Scenes # Path du fichier contenant la liste des brins colllectés def collecte_file @collecte_file ||= File.join(film.collecte.folder, 'scenes.collecte') end end #/Scenes end #/Film
require 'rails_helper' RSpec.describe CoursesController, :type => :controller do before do @user = FactoryGirl.create :user sign_in @user end describe "GET index" do context 'params query' do it 'return http success' do get :index, query: "Hehe" expect(response).to have_http_s...
class CreateSubchurches < ActiveRecord::Migration def change create_table :subchurches do |t| t.string :subchurch_name t.string :subchurch_address t.integer :subchurch_phone_no t.integer :id_no t.timestamps end end end
namespace :scheduler do desc "Import all trials from clinicaltrials.gov" task :import_trials_from_clinicaltrials_gov => :environment do TrialsImporter.new.import RestClient.get(cronitor_url) end def cronitor_url "https://cronitor.link/#{ENV.fetch("CLINICALTRIALS_SYNC_CRONITOR_ID")}/complete" end ...
class Room < ActiveRecord::Base belongs_to :floor belongs_to :roomtype has_many :polygons, as: :imageable, dependent: :destroy # поиск def self.search(params) # result = Order.includes(:tariff, {:automobile => :drivers}).references(:tariff, {:automobile => :drivers}) result = Room.all if params[...
class OZBPerson < ActiveRecord::Base set_table_name "OZBPerson" set_primary_key :mnr # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recover...
require "google/cloud/language" require "googleauth" class Api::V1::PostsController < ApplicationController # skip_before_action :authenticate def index @posts = Post.all.reverse post_data = @posts.each_with_object([]) do |post, new_array| new_array << {id: post.id, content: post.content, created_at...
Fabricator(:hotel) do name { Faker::Company.name } address { Faker::Address.street_address } star_rating { rand(1..5) } accomodation_type { "hostel" } end
require_relative 'command.rb' module DBP::BookCompiler::TexToMarkdown class DoNothing include Command def initialize(name) @name = name end def to_s "#{self.class}(#{name})" end end end
require 'line/bot' require 'net/http' require 'uri' require 'rexml/document' class LinebotController < ApplicationController protect_from_forgery except: ['callback'] def callback message = { type: 'text', text: 'Hello, This is LINE bot' } client = Line::Bot::Client.new do |config| c...
class Task < ActiveRecord::Base belongs_to :project validates_presence_of :title, :due_date, :is_completed, :project_id end
require 'csv' require 'json' module Bb10Cli module Cli class App desc 'lsvolumes', 'Lists all the mountable volumes on the BB10 device' def lsvolumes run_command do |bb| response = bb.do_command('Status', path: '/cgi-bin/dynamicProperties.cgi', 'Attribute' => 'DeviceVolumes') ...
class CommentsController < ApplicationController skip_before_filter :verify_authenticity_token def index @comments = current_user.comments end def new @comment = Comment.new end def create @comment = Comment.new(comment_params) @comment.user_id = current_user.id @comment.status = "nouveau" if @comm...
class RemoveImageUrlFromBookmarks < ActiveRecord::Migration def up remove_column :bookmarks, :image_url end def down add_column :bookmarks, :image_url, :string end end
require 'sqlite3' namespace :users do namespace :mumble do desc 'Generate and export mumble passwords' task :export => :environment do db = SQLite3::Database.new("/var/lib/mumble-server/mumble-server.sqlite") db.prepare("INSERT OR IGNORE INTO users (server_id, name, pw, player_id) ...
require "aethyr/core/actions/commands/reply" require "aethyr/core/actions/commands/tell" require "aethyr/core/registry" require "aethyr/core/input_handlers/command_handler" module Aethyr module Core module Commands module Tell class TellHandler < Aethyr::Extend::CommandHandler def self.c...
require_relative '../test_helper' class ConfirmationsControllerTest < ActionController::TestCase def setup super @controller = Api::V1::ConfirmationsController.new @request.env["devise.mapping"] = Devise.mappings[:api_user] end test "should not confirm account if client host is not recognized" do ...
class CreateJoinTableProjectTool < ActiveRecord::Migration[5.1] def change create_join_table :projects, :tools end end
#!/usr/bin/env ruby require_relative '../lib/studio_game/game' require_relative '../lib/studio_game/clumsy_player' require_relative '../lib/studio_game/berzerk_player' knuckleheads = StudioGame::Game.new("Knuckleheads") default_player_file = File.join(File.dirname(__FILE__), 'players.csv') knuckleheads.load_players(A...
module Wait def self.until(timeout: nil, timeout_message:nil) wait_params = {message: timeout_message} wait_params[:timeout] = timeout if timeout # default timeout is 5 seconds Selenium::WebDriver::Wait.new(message: timeout_message).until { yield } end end
class Campaign < ActiveRecord::Base has_many :keywords, dependent: :destroy validates :name, presence: true def self.data_proccesing(yad_list) # все айди из ответа яндекса yad_ids = yad_list.map{ |c| c['Id'] } # удаляем не нужные where.not(id: yad_ids).destroy_all if yad_ids.any? # обновля...
class Task include Mongoid::Document include Mongoid::Timestamps field :task_name field :due_date field :assigned_to field :task_type field :lead_for_task validates_presence_of :task_type, :task_name, :assigned_to, :due_date, :lead_for_task belongs_to :user DUE_DATES = [['Overdue','overdue'],['A...
module DiceOfDebt class API resource :errors do desc 'Raise an error.' post do fail 'Internal Server Error' end get do fail 'Internal Server Error' end end helpers do def error(options = {}) error = Error.new(options) status error.stat...
# frozen_string_literal: true module Dynflow module ExecutionPlan::Steps class AbstractFlowStep < Abstract # Method called when initializing the step to customize the behavior based on the # action definition during the planning phase def update_from_action(action) @queue = action.queue...
def Caesar(string, shift) lower = ('a'..'z').to_a.rotate(shift) upper = ('A'..'Z').to_a.rotate(shift) alphabet = lower.concat(upper).join string.tr!('a-zA-Z', alphabet) end p "Enter text to cipher" input = gets.chomp if ! /[a-zA-Z]/.match(input).nil? p "You have entered " + input + " as your text ...
#!/usr/bin/env ruby require 'timeout' require 'date' module PolyComp class Sign DefaultBaud = 1200 TTYFlags = 'raw -parenb cstopb' BroadcastAddr = 0 DefaultLines = 2 DefaultWidth = 16 HeaderStart = 0.chr HeaderEnd = 3.chr EndOfText = 4.chr ACK = 6 AckTimeout = 10 #...
class Upload < Sequel::Model(WoodEgg::DB) many_to_one :researcher FILEDIR = '/srv/http/uploads/' class << self # NOTE: dataset, not results def missing_info filter(transcription: nil).or(transcription: '').or(notes: nil).or(notes: '').order(:id) end # NOTE: results, not dataset def mis...
require 'json' require 'thor' require 'English' require_relative 'consts' require_relative 'utils/run' require_relative 'utils/log' module Calypso class SimCtl < Thor KEYBOARD_PREFERENCES = { 'bool': { 'KeyboardAllowPaddle': 'NO', 'KeyboardAssistant': 'NO', 'KeyboardAutocapitaliz...
class TipoPontoTuristicosController < ApplicationController before_action :set_tipo_ponto_turistico, only: [:show, :edit, :update, :destroy] # GET /tipo_ponto_turisticos # GET /tipo_ponto_turisticos.json def index @tipo_ponto_turisticos = TipoPontoTuristico.all end # GET /tipo_ponto_turisticos/1 # G...
#!/usr/bin/env ruby require 'json' require 'net/http' require 'yaml' require 'puppet_litmus' require 'etc' require_relative '../lib/task_helper' def provision(platform, inventory_location) include PuppetLitmus::InventoryManipulation uri = URI.parse('https://cinext-abs.delivery.puppetlabs.net/api/v2/request') job...
# == Schema Information # # Table name: policy_coverage_status_histories # # id :integer not null, primary key # coverage_effective_date :date # coverage_end_date :date # coverage_status :string # data_source :string # lapse_days :integer # pol...
class ApplicationController < ActionController::Base include Pundit # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception before_action :authenticate_user! before_action :reset_flash before_action :set_paper_trail_whod...
feature 'Creating peeps' do scenario 'I can create a new peep if I am signed in' do sign_up visit '/peeps' fill_in 'text', with: 'Hello world!' click_button 'Create peep' expect(current_path).to eq '/peeps' within 'ol#peeps' do expect(page).to have_content('Hello world!') end end...
# your code goes here class Person attr_accessor :bank_account attr_reader :name, :happiness, :hygiene #happiness and hygiene must be reader methods #because we do not want to allow users to change #those values def initialize(name) @name = name @bank_account = 25 @hap...
class Robot attr_reader :name, :city, :state, :birthdate, :date_hired, :department, :id, :photo def initialize(robot) @id = robot[:id] @name = robot[:name] @city = robot[:city] @state = robot[:state] @birthdate = robot[:birthdate] @date_...
def script_tag(index) yield $script_tags_run[index] if block_given? $script_tags_run[index] end def have_run lambda { |obj| !obj.nil? } end def inline lambda { |obj| obj.has_key?(:inline) && obj[:inline] } end def deferred lambda { |obj| obj.has_key?(:defer) && obj[:defer] } end def in_order lambda { |o...
Pod::Spec.new do |s| s.name = 'isar_flutter_libs' s.version = '1.0.0' s.summary = 'Flutter binaries for the Isar Database. Needs to be included for Flutter apps.' s.homepage = 'https://isar.dev' s.license = { :file => '../LICENSE' } s.author = { 'Isar...
require 'rails_helper' RSpec.feature 'User signs in' do scenario 'tries to access admin dashboard and is redirected with error message' do user = create(:user) visit root_path find('#username-sign-in').set(user.username) find('#password-sign-in').set(user.password) click_button 'Submit' vis...
puts "On va compter le nombre d'heures de travail à THP" # On affiche l'intitulé de l'opération, donc la phrase entre guillement "Travail : #{10 * 5 * 11}" # On affiche "travail :" + le nombre d'heures grâce au calcule heures x jours x mois puts "En minutes ça fait : #{10 * 5 * 11 * 60}" #Idem que pour ligne ci-dessu...
Piccy::Application.routes.draw do resources :pictures root :to => 'pictures#index' end
module Aus module Lunh def self.is_number_valid? number ::Luhn.valid?(number) end def self.encode number "#{number}#{::Luhn.control_digit(number)}" end end end
class AddRefreshAndAccessTokenToUser < ActiveRecord::Migration def change add_column :users, :gg_access_token, :string add_column :users, :gg_refresh_token, :string end end
require_relative "../config/environment.rb" require 'active_support/inflector' class Song self.column_names.each do |col_name| attr_accessor col_name.to_sym end def self.table_name self.to_s.downcase.pluralize #Changes Song to songs for use when creating table end def self.column_names DB[:c...
class AdressesController < ApplicationController def search_postal_code begin address = get_address render :json => address.to_json rescue SocketError,RuntimeError, Timeout::Error address = {'bairro' => '','cep' => '','cidade' => '','logradouro' => '','tipo_logradouro' => '','uf' => '1'} ...
class Patient < ApplicationRecord has_and_belongs_to_many :physicians, through: :appointment end
require 'rails_helper' describe Profiles::PhotosController do context "when user is not logged in" do before :each do login_with nil @user = create(:user) @profile = create(:profile, user_id: @user.id ) @photo = create(:photo, profile_id: @profile.id) end it "redirect to log...
source 'https://rubygems.org' ruby '2.1.1' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.1.1' # Use postgresql as the database for Active Record gem 'pg' # Use SCSS for stylesheets gem 'sass-rails', '~> 4.0.3' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= ...
class Chapel < Formula desc "Programming language for productive parallel computing at scale" homepage "https://chapel-lang.org/" url "https://github.com/chapel-lang/chapel/releases/download/1.25.0/chapel-1.25.0.tar.gz" sha256 "39f43fc6de98e3b1dcee9694fdd4abbfb96cc941eff97bbaa86ee8ad88e9349b" license "Apache-...
class RenameImageUrlInSnapInviteAds < ActiveRecord::Migration def change rename_column :snap_invite_ads, :image_url, :media_url end end
class Room < ApplicationRecord has_many :entries,dependent: :destroy has_many :messages,dependent: :destroy end
class League class Roster < ApplicationRecord include MarkdownRenderCaching belongs_to :team, inverse_of: :rosters belongs_to :division, inverse_of: :rosters delegate :league, to: :division, allow_nil: true has_many :players, -> { order(created_at: :asc) }, dependent: :destroy, inverse_of: :rost...
class AddGenresDirectorsAndActorsToRatingsTable < ActiveRecord::Migration def change add_column :ratings, :actors, :string add_column :ratings, :directors, :string add_column :ratings, :genres, :string end end
class User < ActiveRecord::Base has_many :spendings, dependent: :destroy has_many :temp_budget_plans, dependent: :destroy before_create{generate_token(:auth_token)} # taken from Michael Hartl's tutorial VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i # the following uses Regex (lookahead assert...
class MachinesReadingsController < ApplicationController def index render 'index' end def show params.require(:search).permit(:machine, :option) if params[:search] selected_machine = params[:search][:machine] selected_option = params[:search][:option] ...
require 'yaml' require_relative 'player.rb' require_relative 'world.rb' class Game DIRECTIONS = ["north", "east", "south", "west"] attr_reader :world, :player, :current_room def initialize @world = World.new @player = Player.new @current_room end def start_game message('beginning') @wo...
class CreateBookmarksTagsJoin < ActiveRecord::Migration[5.2] def change create_table :bookmarks_tags, :id => false do |t| t.integer "bookmark_id" t.integer "tag_id" end add_index("bookmarks_tags", ["bookmark_id", "tag_id"]) end end
defaults = [] begin require 'rspec/core/rake_task' RSpec::Core::RakeTask.new :spec do |t| t.rspec_opts = ['--color', '--format progress', '--order rand'] t.ruby_opts = ['-W2'] end defaults << :spec rescue LoadError warn 'RSpec not available, spec task not provided.' end begin require 'cane/rake_ta...
require 'spec_helper' describe "Authentication" do subject{page} describe "signin page" do before {visit signin_path} it {should have_content("国科大跳蚤市场")} it {should have_content("主页")} it {should have_content("注册")} it {should have_content("登录")} it {should have_titl...
require_relative 'menumodule' class SetAccountDisplayPreferencesPage include PageObject include MenuPanel include AccountsSubMenu include ServicesSubMenu include MyInfoSubMenu include MessagesAlertsSubMenu include PaymentsSubMenu table(:heading, :id => 'tblMain') button(:updatebutto...
require 'dry-validation' require_relative './oob_dns' require_relative './helpers' require_relative './baseline' require_relative './schema/predicates' require_relative './detect/context' require_relative './detect/payload_check' require_relative './detect/vuln' require_relative './blocks/generate' require_relative...
require 'rails_helper' describe Product do before do @product = FactoryGirl.create(:product) @user = FactoryGirl.create(:user) #here you put your code to generate test content #@product = Product.create!(name: "race bike", description: "Another bike", image_url: "bike.jpg", colour: "purple", price:...
require "rails_helper" RSpec.describe Mechanic, type: :model do describe "validations" do it { should validate_presence_of :name} it { should validate_presence_of :years_experience} end describe "relationships" do it { should have_many :mechanic_rides } it { should have_many(:rides).through(:mec...
class Watchlist < ApplicationRecord belongs_to :user belongs_to :movie validates_presence_of :user, :movie validates :user_id, numericality: { only_integer: true, message: "Please add a valid Id" } validates :movie_id, numericality: { only_integer: true, message: "Please add a valid Id" } end
module Silence def silence # what happened to ActiveRecord::Base.silence? old_logger = ActiveRecord::Base.logger ActiveRecord::Base.logger = nil begin yield ensure ActiveRecord::Base.logger = old_logger end end end
class Computer #o nome da classe sempre começa com class, o nome dela poderia ser qualquer um, exemplo: cachorro, carro e etc def turn_on 'turn on the computer' end def shutdown 'shutdown the computer' end end computer = Computer.new #'Computer.new' é o objeto da classe puts computer.s...
class User include DataMapper::Resource property :id, Serial property :created_at, DateTime property :username, String, key: true property :enabled, Boolean has n, :apps end
#encoding: utf-8 # 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.cre...
class Seller::ProductsController < ApplicationController def index @stores = Store.where(seller_id: session[:seller_id]) end def show @product = Product.find(params[:id]) @store = Store.find_by(id: @product.store_id) end def edit @product = Product.find(params[:id]...
require 'faker' require "open-uri" def handle_string_io_as_file(io) return io unless io.class == StringIO file = Tempfile.new(["temp",".png"], encoding: 'ascii-8bit') file.binmode file.write io.read file.open end # -------------------------- Destroy --------------------------- # puts 'Destroying all indust...