text
stringlengths
10
2.61M
# frozen_string_literal: true module GraphQL class Query # This object can be `ctx` in places where there is no query class NullContext class NullQuery def after_lazy(value) yield(value) end end class NullSchema < GraphQL::Schema end extend Forwardable...
require 'statement' describe Statement do RANDOM_AMOUNT = 600 RANDOM_AMOUNT_sf = "600.00" RANDOM_AMOUNT_2 = 500 RANDOM_AMOUNT_2_sf = "500.00" DATE = Date.new(2016,5,16) let(:transaction) { double(:transaction, calculate_change: RANDOM_AMOUNT, credit: 0, debit: RANDOM_AMOUNT, date: DATE, deposit_or_withdraw...
require File.dirname(__FILE__) + '/../../test_helper' require 'simplepay/services/donation' class Simplepay::Services::TestDonation < Test::Unit::TestCase def self.model_class; Simplepay::Services::Donation; end context 'Simplepay::Services::Donation' do should_have_service_field :access_key, ...
require 'spec_helper' describe ReviewsController do describe 'POST create' do let(:user) { Fabricate(:user) } context 'with authentication' do before do session[:user_id] = user.id end it 'should tell the user that its not possible to review a video twice ' do video = Video.create(titl...
class EmployersContractClaim < BaseForm attribute :make_employer_contract_claim, :boolean attribute :claim_information, :text def to_h employer_contract_claim_hash = { make_employer_contract_claim: make_employer_contract_claim } employer_contract_claim_hash[:claim_information] = claim_informat...
require 'devise_couch' require 'devise/orm/couchrest_model/date_time' require 'orm_adapter_couchrest_model/couchrest_model' require 'devise/strategies/database_authenticatable' module Devise module Orm module CouchrestModel module Hook def devise_modules_hook! create_authentication_views ...
require 'elasticsearch/model' class Question < ActiveRecord::Base include Elasticsearch::Model include Elasticsearch::Model::Callbacks include IndexUpdater belongs_to :subject, polymorphic: true has_many :answers has_many :taggings, as: :taggable has_many :tags, through: :taggings has_ma...
require 'spec_helper' describe MoviesController do describe 'easy stuff' do before :each do @testMovie = mock(Movie, :title => "Up", :id => "1") Movie.stub(:find).with("1").and_return(@testMovie) end it 'should create a new movie' do Movie.stub(:create!).and_return(@testMovie) post(:create) respo...
class MediaFormatDatatable delegate :current_user, :content_tag, :check_box_tag, :params, :link_to, to: :@view delegate :url_helpers, to: 'Rails.application.routes' delegate :session, to: :@view include ApplicationHelper def initialize(view) @view = view end def as_json(options = {}) { ...
describe User do describe "attributes" do it { is_expected.to respond_to(:username) } it { is_expected.to respond_to(:access_token) } it { is_expected.to respond_to(:google_id) } it { is_expected.to respond_to(:google_token) } end describe 'relations' do it { is_expected.to respond_to(:proje...
describe 'Place (feature)', type: :feature do CTA_TEXT = 'Besuch anlegen' context 'new view' do it 'is accessible from the homepage' do visit root_path click_link 'Neuer Eintrag' expect(page).to have_current_path(new_place_path) end it 'can be left to the homepage' do visit new_...
class FontHeptaSlab < Formula head "https://github.com/google/fonts/raw/main/ofl/heptaslab/HeptaSlab%5Bwght%5D.ttf", verified: "github.com/google/fonts/" desc "Hepta Slab" homepage "https://fonts.google.com/specimen/Hepta+Slab" def install (share/"fonts").install "HeptaSlab[wght].ttf" end test do end ...
require 'test_helper' class ApiKeyTest < ActiveSupport::TestCase test '#generate_key' do ak = ApiKey.new assert_nil ak.key ak.generate_key assert ak.key.size > 30 end test '#expire!' do ak = ApiKey.new(organization: Organization.first) ak.generate_key ak.save refute ak.expired ...
require 'test_helper' class PeoplePlansControllerTest < ActionController::TestCase setup do @people_plan = people_plans(:one) end test "should get index" do get :index assert_response :success assert_not_nil assigns(:people_plans) end test "should get new" do get :new assert_respons...
# frozen_string_literal: true module UserListHelper def user_actions(user) return content_tag(:div, class: 'actions') { unlock_link(user[:id]) } if user[:locked] content_tag(:div, class: 'actions') do profile_links(user[:id]) invitation_link(user) lockable_link(user) end end private...
# # Author:: Joe Williams (<j@boundary.com>) # Cookbook Name:: apps # Definition:: ruby # # Copyright 2011, Boundary # # 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....
require 'rails_helper' require 'functions/combination_images' RSpec.describe CombinationImages, type: :job do include CombinationImages include ActiveJob::TestHelper let(:image_1) { Rails.root.join("spec/dummy/public/images/1.jpg") } let(:image_2) { Rails.root.join("spec/dummy/public/images/2.jpg") } let(:i...
# Require config/environment.rb. This loads app/models, etc. require ::File.expand_path('../config/environment', __FILE__) ### TEST HELPERS ### def clean_up_data # Clean up data between tests to prevent cross talk Person.destroy_all! Skill.destroy_all! end # DO NOT CHANGE BELOW THIS LINE. FEEL FREE TO WR...
class CreateCourseMusics < ActiveRecord::Migration def self.up create_table :course_musics do |t| t.references :course, :null => false t.integer :seq, :null => false t.references :music, :null => false t.integer :diff, :null => false t.timestamps end change_table :course_musi...
# Generated by jeweler # DO NOT EDIT THIS FILE DIRECTLY # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = %q{ruby-smpp} s.version = "0.6.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_ruby...
require "assert" require 'xmlss/style/base' module Xmlss::Style class BaseTest < Assert::Context desc "Xmlss::Style::Base" before { @bs = Base.new(:test) } subject { @bs } should have_class_method :writer should have_reader :id, :i_d should "know its writer" do assert_equal :style, s...
class Event < ApplicationRecord belongs_to :group belongs_to :spot has_many :comments, dependent: :destroy validates :spot_id, presence: true validates :group_id, presence: true validates :name, presence: true, length: { maximum: 500 } validates :date, presence: true validates :description,...
class Post < ActiveRecord::Base attr_accessible :content, :title, :image has_attached_file :image accepts_uploaded_file_for :image do_not_validate_attachment_file_type :image end
# == Schema Information # # Table name: heading_ad_images # # id :bigint(8) not null, primary key # heading_ad_image :string # x :float # y :float # width :float # height :float # x_in_unit :float # y_in_unit :float # width_i...
module Sesam class Railtie < Rails::Railtie initializer "sesam.initialize" do ActionDispatch::ExceptionWrapper.rescue_responses.merge!( "JSON::Schema::ValidationError" => :bad_request, "ActiveRecord::RecordNotFound" => :not_found, "ActiveRecord::RecordInvalid" => :unprocessable_entit...
class Statement attr_reader :statement_transactions def initialize @statement_transactions = [] end def compile_statement(account_transactions) account_balance = 0 account_transactions.each do |line| if line[1] > 0 @statement_transactions.push(["#{line[0]} || #{line[1]} || || #{accou...
module RedmineGitHosting module Patches module RepositoryPatch unloadable def self.included(base) base.class_eval do extend(ClassMethods) class << self alias_method_chain :factory, :git_extra_init alias_method_chain :fetch_changesets, :disable_updat...
#!/usr/bin/env ruby require_relative 'Node' class Transition < Node def initialize(category, activatable, active_state) super(category, activatable, active_state) @node_type = :transition end def fire if enabled? normal_arcs = input_normal_arcs normal_arcs...
class Post include Mongoid::Document field :title, type: String field :body, type: String field :author, type: String field :publication_date, type: DateTime validates_presence_of :title validates_presence_of :body end
class ShortenedUrlsController < ApplicationController before_action :find_url, only: [:show, :shortened] skip_before_filter :verify_authenticity_token def index @url = ShortenedUrl.new end def show redirect_to @url.sanitize_url end def create @url = ShortenedUrl.new @url.original_url = params[:origin...
# The 'input' modules just get the keystrokes and turn them into a command # string. This takes a command string and actually executes it, # and has all the keybindings and stuff. # # This lets this be subclassed/overridden/etc, require 'config' class Command def initialize driver @driver = driver @c...
class CreateElementsStructure < ActiveRecord::Migration BASE_TYPES = %w(text integer float boolean date datetime) def self.up BASE_TYPES.each do |type| create_table "essence_#{type.pluralize}" do |t| t.belongs_to :element, :null => false t.belongs_to :property, :null => false t.se...
class ProposalsController < ApplicationController before_action :commercial def index @proposal = ProposalsGrid.new(params[:proposals_grid]) do |scope| scope.page(params[:page]) end end def new @proposal = Proposal.new build_proposals end def edit @proposal = Proposal.find params[:id] build_pro...
class User < ApplicationRecord # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable validates :email, presence: true validates :username...
# Problem 367: bozo sort # http://projecteuler.net/problem=367 # # Bozo sort, not to be confused with the slightly less efficient bogo sort, consists out of checking if the input sequence is sorted and if not swapping randomly two elements. This is repeated until eventually the sequence is sorted. # # # If we consi...
#=============================================================================== # # *Variable HUD* # Version: 1.1 # Author: Euphoria # Date: 4/19/2014 # Euphoria337.wordpress.com # ...
class AddCountryIdToVacancy < ActiveRecord::Migration[5.0] def change add_reference :vacancies, :country, foreign_key: true, index: true add_reference :vacancies, :state, foreign_key: true, index: true end end
require 'net/http' require 'uri' require 'json' module Northwestern BASE_URL = 'https://api.asg.northwestern.edu/' class << self def terms(params={}) self.get('/terms', {}) end def schools(params={}) self.get('/schools', {}) end def terms(params={}) self.get('/terms', {}) ...
class AddToken < ActiveRecord::Migration[5] def up add_column :company_admins , :token , :string end def down remove_column :company_admins , :token end end
json.user do json.partial! 'api/v1/users/show', user: @user end
class Url include Mongoid::Document include Mongoid::Timestamps field :url field :clean embedded_in :post end
class RenameDesks < ActiveRecord::Migration def change rename_table :desks, :workstations end end
# -*- encoding: utf-8 -*- require "spec_helper" describe "Login" do context "with valid credentials" do let!(:user){ User.create!({ :name => "John Joe", :email => "john@example.com", :password => "test", :password_confirmation => "test" }) } before do ...
module Cultivation class CalculateTaskActualCostAndHours prepend SimpleCommand attr_reader :args, :breakdown def initialize(time_log, user, breakdown = false) @time_log = time_log @user = user @breakdown = breakdown end def call # Time log is recorded at # - tim...
class Song < ActiveRecord::Base attr_accessible :album, :artist, :title, :year validates_presence_of :year validates_length_of :year, :minimum => 4, :maximum => 4 end
class Listing < ActiveRecord::Base belongs_to :neighborhood belongs_to :host, :class_name => "User" has_many :reservations has_many :reviews, :through => :reservations has_many :guests, :class_name => "User", :through => :reservations validates :address, presence: :true validates :listing_type, presenc...
class MNumber def initialize(size, seq) @size = size @seq_order = seq.sort #order to seq end def find_missing_number_in_sequence generate_array_elements end private def generate_array_elements html='' @seq_order.each_with_index do |element, index| if element.to_i != (index+1)...
module Naf # # Things you should know about jobs # new jobs older than 1.week will not be searched in the queue. You should not run programs # for more than a 1.week (instead, have them exit and restarted periodically) # class HistoricalJob < ::Partitioned::ById class JobPrerequisiteLoop < StandardErro...
class CreateTacos < ActiveRecord::Migration def change create_table :tacos do |t| t.string :taco_name t.string :taco_price t.timestamps end end end
require 'serverspec' include Serverspec::Helper::Exec include Serverspec::Helper::DetectOS RSpec.configure do |c| c.before :all do c.os = backend(Serverspec::Commands::Base).check_os c.path = '/sbin:/usr/sbin' end end # Arch specific packages dev_packages = case os[:family] when 'RedHat' ...
class InvoicesController < ApplicationController before_filter :get_account before_filter :inner_navigation before_filter :restrict_access, :except => [:index, :show] before_filter :restrict_invoice_access, :except => [:index] before_filter :restrict_account_access, :except => [:index, :new, :create] def i...
Rails.application.routes.draw do get 'cover/:name', to: 'proxy#cover' get 's/:search', to: 'galleries#search' get 's/:search/:page', to: 'galleries#search' get 'g/:gid/:token', to: 'galleries#show' get 'p/:gid', to: 'pictures#index' get 'p/:gid/:page', to: 'pictures#show' root to: 'galleries#index...
class VehicleMaintenanceAttachment < ActiveRecord::Base attr_accessor :delete_attachment, :attachment_present belongs_to :vehicle_maintenance validates_presence_of :name before_save :check_if_attachment_deleted VALID_IMAGE_TYPES = [ 'image/png','image/jpg','image/jpeg','image/gif','image/bmp','app...
# frozen_string_literal: true module ApplicationHelper def signup_path? return true if request.original_url.include?('users/sign_up') false end end
class UnexpectedTokenError < StandardError attr_reader :i, :j def initialize(i,j,msg="Unexpected Token") @i = i @j = j super(msg) end end
class CareType < ApplicationRecord validates :name, presence: true has_many :dog_cares, dependent: :destroy end
class UserIdentificationsController < ApplicationController include SetUser include UserConfirmation include UserSignedIn before_action :user_signed_in before_action :set_user before_action :user_confirmation #本人情報編集機能 def update if @user.update(user_identification_params) flash[:notice] = "変...
Sequel.migration do up do create_table :authentications do primary_key :id foreign_key :user_id, :users foreign_key :identity_id, :identities end end end
class CreateAppTables < ActiveRecord::Migration def up create_table :app_types do |t| t.string :name t.timestamps end add_index :app_types, :name, unique: true create_table :apps do |t| t.string :name t.string :address t.string :latlong t.string :search_words ...
# Creates the initial "holdings" table, these are later renamed to "InventoryItems" class CreateHoldings < ActiveRecord::Migration[5.0] def change create_table :holdings do |t| t.integer :inventory_id t.integer :item_id t.integer :quantity t.timestamps end end end
class CartItem < ActiveRecord::Base acts_as_shopping_cart_item_for :cart belongs_to :products validates :quantity, presence: true def total_price self.quantity * self.price_cents end end
require 'rails_helper' describe RepoSynchronization do describe '#start' do it 'saves privacy flag' do stub_github_api_repos( repo_id: 456, owner_id: 1, owner_name: 'thoughtbot', repo_name: 'user/newrepo' ) user = create(:user) synchronization = RepoSynchro...
class ListsController < ApplicationController # skip_before_action :require_login, only: [:index] before_action :require_logged_in def time raise params.inspect end def index if @user = User.find_by(id: session[:user_id]) @list = List.new # item for form to wrap around @lists = @user.li...
class TodoList attr_reader :tasks def initialize @tasks = [] end def add_task(new_task) @tasks.push(new_task) end def delete_task(task_id) @tasks = @tasks.delete_if do |task| task.id == task_id end end end
Rails.application.routes.draw do root 'home#show' resources 'jobs', only: [:index, :show, :destroy] post 'create_job', to: 'jobs#create' # post 'destroy_job/:id', to: 'jobs#destroy' resources 'events', only: [:index, :show, :create, :destroy] resources 'sessions', only: :create get 'login', to: 'sessi...
module GrapeWarden class User USERS = { 1 => "Susan", 2 => "Bob" } attr_reader :name attr_reader :id def initialize(id, name) @id = id @name = name end class << self def get(id) User.new(id, User::USERS[id]) end def authenti...
require 'spec_helper' describe Puppet::Type.type(:rbac_role) do subject { Puppet::Type.type(:rbac_role).new(:name => 'tacocat') } # not really a lot we can test here it 'should accept ensure' do subject[:ensure] = :present expect(subject[:ensure]).to eq :present end end
ActiveAdmin.register AdminUser do permit_params :email, :password, :password_confirmation, :name index do selectable_column id_column column :name column :email column :current_sign_in_at column :sign_in_count column :created_at actions end filter :name filter :email filter :...
# == Schema Information # # Table name: questions # # id :integer not null, primary key # question :string not null # created_at :datetime not null # updated_at :datetime not null # polls_id :integer not null # class Question < ActiveRecord::Base has_many ...
require 'spec_helper' describe ByteBuffer::Buffer do let(:initial_capacity) {ByteBuffer::Buffer::DEFAULT_PREALLOC_SIZE} describe "preallocation" do it "preallocates internal buffer" do buffer = described_class.new expect(buffer.capacity).to eq initial_capacity end it "preallocates interna...
require_relative 'node' require './exceptions/not_found_exception' class DoubleLinkList attr_accessor :head def initialize @head = nil @tail = nil end def push(data) new_node = Node.new(data) new_node.next = @head if @head.nil? @tail = new_node @head = new_node ...
# frozen_string_literal: true require 'test_helper' module Vedeu module Cells describe Vertical do let(:described) { Vedeu::Cells::Vertical } let(:instance) { described.new } describe '#as_html' do subject { instance.as_html } it { subject.must_equal('&#x2502;') } e...
require './f5' require 'optparse' require 'pp' require 'ostruct' class Optparser def self.parse(args) options = OpenStruct.new opts = OptionParser.new do |opts| opts.banner = "Usage: f5_gtm_wideip_get_list.rb [options]" opts.separator "" opts.separator "Specific options:" ...
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe Blueprints::Blueprint do describe "backtrace" do before do blueprint { raise 'error' } end it "should rewrite trace" do begin blueprint.build(stage) rescue RuntimeError => e e.backtrace[0].should...
class PostSerializer < ActiveModel::Serializer # attributes :id, :title, :new_function, :custom_key, :method_custom_in_model attributes :id, :title, :num_comments, :comments # has_many :comments def num_comments object.comments.count(:id) end # custom key for version < 0.10.0 def custom_key ob...
# frozen_string_literal: true require 'open-uri' require 'json' # 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.cre...
module AnnualReports module Create class Service private attr_reader :timestamp, :builder public def initialize(timestamp, builder = nil) @timestamp = timestamp @builder = builder || Builder.new(timestamp: timestamp) end def call annual_repor...
class PostsController < ApplicationController before_action :require_user, only: [:create] before_action :choose_random_post, only: [:index, :show] before_action :new, only: [:index, :show, :vote] before_action :set_post, only: [:show, :vote, :down_votes] DOWN_VOTES_TO_DELETE = 10 def index end def s...
require "chandler/configuration" require "chandler/logging" require "chandler/version" require "optparse" module Chandler class CLI class Parser include Logging attr_reader :args, :config def initialize(args, config=Chandler::Configuration.new) @args = args @config = config ...
require 'lib/spec_helper' require 'graph/node_edges' require 'graph/edge_nodes' module FakeEdge def nodes @nodes ||= Graph::EdgeNodes.new self end end module FakeNode def edges @edges ||= Graph::NodeEdges.new self end end describe Graph do context 'two nodes' do let(:edge) { stub('edge').ext...
class TagsGenerator def self.generate(object) tags = separators(object.tags) tags = tags.split if tags.is_a?(String) tags end def self.separators(tags) [', ', ',', '; ', ';'].each do |separator| if tags.include?(separator) tags = tags.split(separator) break end e...
# == Schema Information # # Table name: message_groups # # id :bigint not null, primary key # name :string # created_at :datetime not null # updated_at :datetime not null # owner_id :bigint not null # participant_id :bigint # # Indexes # # i...
class SetSendAtOnMessages < ActiveRecord::Migration[5.0] def change Message.all.each do |message| message.update(send_at: message.created_at) if message.send_at.nil? end change_column :messages, :send_at, :datetime, null: false end end
class Entry < ActiveRecord::Base belongs_to :organization belongs_to :credit belongs_to :debit end
# frozen_string_literal: true require 'rails_helper' RSpec.describe Account, type: :model do it { is_expected.to respond_to :name } it { is_expected.to validate_presence_of :name } it { is_expected.to validate_length_of(:name).with_maximum(100) } it { is_expected.to respond_to :description } it { is_expect...
# encoding: utf-8 # # © Copyright 2013 Hewlett-Packard Development Company, L.P. # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights #...
class Post < ApplicationRecord validates :title, length: { maximum: 20 }, presence: true validates :content, length: { maximum: 2000 }, presence: true belongs_to :user has_many :responses has_many :post_category_relations has_many :categories, through: :post_category_relations end
class Section < ApplicationRecord has_many :food_items, dependent: :destroy def self.generate_defaults %w(Breakfast Lunch Dinner Drinks).each do |name| Section.find_or_create_by!(name: name) end end end
require_relative 'journey' class Oystercard attr_reader :balance, :entry_station, :exit_station attr_accessor :journey MAX_BALANCE = 90 MIN_FARE = 2 def initialize(journey = Journey.new) @balance = 0 @journey = journey end def top_up(amount) message = "Card violation: cannot exceed £#{MAX...
require 'twitter' require 'tzinfo' require 'csv' require_relative 'airport_timezones' include AirportTimezones def setup @all_tweets = [] @client = Twitter::REST::Client.new do |config| config.consumer_key = ENV['TWITTER_KEY'] config.consumer_secret = ENV['TWITTER_SECRET'] config.access_to...
# Write a method that takes an Array as an argument, and returns two Arrays (as a pair of nested Arrays) that contain the first half and second half of the original Array, respectively. If the original array contains an odd number of elements, the middle element should be placed in the first half Array. def halvsies(a...
# -*- coding: utf-8 -*- class Pokemon include Memoizable attr_accessor :page, :stats def initialize(html) @page = html @stats = Stat.new(stat_table) end def name page.search('.pagetitle').first.search('h1').text.strip end def pokedex_number catch (:pokedex_number) { # Sign ...
module MerchantAnalyst def calculate_total_revenue(invoice_list) invoice_list.reduce(0) do |total_revenue, invoice| total_revenue + invoice.total end end def total_revenue_by_date(date) invoices_by_date = @engine.invoices.find_all_by_date(date) calculate_total_revenue(invoices_by_date) e...
class Genre < ActiveRecord::Base has_many :songs has_many :artists, through: :songs def song_count self.songs.size end def artist_count self.artists.size end def all_artist_names ists = [] art = self.artists art.each do |a| ists << a.name end ists end end
module Vehicles class Create attr_reader :vehicle_attrs def initialize(vehicle_attrs) @vehicle_attrs = vehicle_attrs end def call vehicle = Vehicle.new(vehicle_attrs) vehicle.active = true vehicle.save vehicle end end end
class CategorySearch < Searchlight::Search def base_query Category.all.order(id: :desc) end def search_name query.joins('INNER JOIN categories AS parents ON parents.id = categories.parent_id') .where('categories.id = :id OR categories.name ilike :name OR parents.name ilike :name', id: name.to_i, na...
class User < ApplicationRecord has_and_belongs_to_many :friendships, class_name: "User", join_table: :friendships, foreign_key: :user_id, association_foreign_key: :friend_user_id has_and_belongs_to_many :bookmarks # Include default devise modules. Others available are: # :confirmable, :...
# frozen_string_literal: true require 'fileutils' require 'fastlane/action' require 'fastlane' import 'Base/BuildType.rb' class BuildTypeEnterprise < BuildType def perform_post_build_procedures copy_artifacts( target_path: 'CircleArtifacts/Enterprise', artifacts: [ "~/Library/Logs/gym/#{@pr...
module HerokuJobGovernator module Interfaces class Resque < HerokuJobGovernator::Interfaces::Interface def self.enqueued_jobs(queue) queued = ::Resque.size(queue.to_s) working = ::Resque.working.map(&:job).count { |j| j["queue"] == queue.to_s } queued + working end end en...
class Admin::ProductCategoriesController < Admin::BaseController before_action :find_product_category, only: [:show, :edit, :update, :destroy, :all] def index @product_categories = ProductCategory.paginate(page: params[:page]) end def show @products = @product_category.products end def new @p...