text stringlengths 10 2.61M |
|---|
require 'rails_helper'
RSpec.describe Item, type: :model do
before do
@item = FactoryBot.build(:item)
end
describe '商品の出品' do
context '商品が出品できる場合' do
it '全ての項目が埋まっている' do
expect(@item).to be_valid
end
end
context '商品が出品できない場合' do
it '商品画像が選択されていない' do
@item.ima... |
# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.
module NapakalakiGame
class CultistPlayer < Player
@@totalCultistPlayers = 0
def initialize(p,c)
Playercopia(p)
@cultist =... |
class AddStudentIdToUser < ActiveRecord::Migration
def self.up
add_column :users, :studentId, :int
add_column :users, :realName, :string
end
def self.down
end
end
|
require 'json'
require 'json_message'
require 'vcap_services_base'
module VCAP
module Services
module Backup
end
end
end
class VCAP::Services::Backup::JobCleaner
include VCAP::Services::Base::AsyncJob
include VCAP::Services::Backup::Util
def initialize(manager, options, services_redis)
@manager... |
require 'test_helper'
describe Api::ProjectsController do
before {
@project1 = FactoryGirl.create :project1
@tester1 = FactoryGirl.create :tester1
@project1.users << @tester1
# tester1 is administrator of project1
@project1.administrator_id = @tester1.id
@project1.save
}
after {
}
... |
# -*- encoding: utf-8 -*-
$: << File.expand_path("../lib", __FILE__)
require "landlord/version"
Gem::Specification.new do |s|
s.name = %q{landlord}
s.version = Landlord::VERSION
s.authors = ["Andrew J. Ayers", "Ryan Brunner", "Brad Robertson"]
s.summary = %q{A Ruby gem for multitenant rails applic... |
require 'yaml'
class YamlToEnv
def yaml_to_env(yaml_content)
hash = YAML.load yaml_content
iterate_on_yaml hash, nil
end
private
def iterate_on_yaml(hash, prefix)
output = ''
hash.each do |k,v|
if v.is_a? Array
raise 'Hash in Array not defined' if v.find { |element| element.i... |
require 'rails'
module RwDepotTheme
module Generators
class InstallGenerator < ::Rails::Generators::Base
source_root File.expand_path("../../../../../app/views", __FILE__)
desc "This generator will create all the views for the depot front-end"
def copy_layout
say_status("c... |
# frozen_string_literal: true
require 'rails_helper'
describe DiscourseBackupUploadsToS3::FileEncryptor do
let(:secret_key) { 'U6ocWTLaXcvIvX5nSCYch5jV02Z+H9YQXaaIo8aNV/E=\n' }
subject { described_class.new(secret_key) }
def encrypt_and_decrypt_file(file, compress: false)
begin
source = file.path
... |
class CreateSegmentTimings < ActiveRecord::Migration
def change
create_table :segment_timings do |t|
t.string :timing
t.datetime :date
t.belongs_to :trip_segment, index: true, foreign_key: true
t.string :hotel
t.text :address
t.timestamps null: false
end
end
end
|
require "i18n"
class Food < ActiveRecord::Base
has_many :aliases, class_name: 'FoodAlias'
has_many :ingredients
has_many :meals, through: :ingredients
before_save do |food|
if food.name_changed?
new_slug = food.name.downcase
new_slug = I18n.transliterate(new_slug)
food.slug = new_slug
... |
class UpnpEventHandler
def initialize(zonePlayer)
@services = {}
@zp = zonePlayer
end
def add_service(sid, serviceClass)
@services[sid] = serviceClass.new(@zp)
end
def remove_service(sid)
@services.delete(sid)
end
def handleEvent(sid, eventData)
@services[sid].handle(eventDa... |
require 'rails_helper'
RSpec.describe 'Register User API', :type => :request do
describe 'register user endpoint' do
it 'recieves user info and responds with an api key' do
User.destroy_all
body = {
"email": "whatever@example.com",
"password": "password",
"password_confirmatio... |
require 'test_helper'
class MessageTest < ActiveSupport::TestCase
def setup
@message = messages(:leave_message)
@buy_iphone_message = messages(:buy_iphone_message)
end
test "should not save message without content" do
@message.content = nil
assert_not @message.save
end
test "should not save... |
class CreateCampaigns < ActiveRecord::Migration
def change
create_table :campaigns do |t|
t.string :name
t.text :countries
t.timestamps
end
add_start_at_column_sql = 'ALTER TABLE campaigns ADD COLUMN start_at timestamp with time zone;'
add_end_at_column_sql = 'ALTER TABLE campaigns... |
class AddStateToServices < ActiveRecord::Migration
def change
add_column :services, :state, :string, default: "active"
end
end
|
=begin
Glassomium - web-based TUIO-enabled window manager
http://www.glassomium.org
Copyright 2012 The Glassomium Authors
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
h... |
class AddSourceToQuestions < ActiveRecord::Migration
def change
add_column :questions, :source, :string
end
end
|
class CreateAdoptionRequests < ActiveRecord::Migration
def change
create_table :adoption_requests do |t|
t.belongs_to :tree
t.timestamps
end
end
end
|
class AddBlocklinkToPlacetextblock < ActiveRecord::Migration
def change
add_column :placetextblocks, :blocklink, :text
end
end
|
# frozen_string_literal: true
require 'test_helper'
class LikeTest < ActiveSupport::TestCase
def setup
@user = users(:maymie)
@likeable = status_updates(:first)
@like = Like.new(user: @user, likeable: @likeable)
end
test 'should be valid' do
assert @like.valid?
end
test 'user can\'t like s... |
# == Schema Information
#
# Table name: complex_buildings
#
# id :bigint not null, primary key
# owner :string default("")
# address :string default("")
# units :bigint default(0)
# sqmt :bigint default(0)
# price :decimal(, ) ... |
class ArticlesController < ApplicationController
before_action :set_category
def index
@articles = @category.articles.limit(6)
end
def show
@article = Article.find(params[:id])
@related_articles = Article.all
end
private
def set_category
@category = Category.find(params[:category_id... |
#
#= トップページ表示用コントローラのアクションを定義するモジュール
#
module Concerns::Susanoo::DashboardsController
extend ActiveSupport::Concern
included do
before_filter :login_required, only: %w(index)
#
#== トップページを表示する
#
def index
@infos = ::Info.order(last_modified: :desc).all
@top_genre_id = Genre.top_gen... |
# valid: :swauth or :keystone
default["swift"]["audit_hour"] = "5" # cluster_attribute
default["swift"]["service_tenant_name"] = "service" # node_attribute
default["swift"]["service_user"] = "swift" # node_attribute
default... |
Gem::Specification.new do |spec|
spec.name = "truth_or_dare"
spec.version = "0.0.3"
spec.authors = ["Julie Graceffa"]
spec.email = ["julie.graceffa@gmail.com"]
spec.summary = %q{Truth or dare game}
spec.description = %q{Allows user to play truth or dare game and pick t... |
class Api::V1::MoviesController < ApplicationController
respond_to :json, :html
def index
movies = Movie.all
render json: movies
end
def find
movie = Movie.find_by_title(params[:title])
render json: movie
end
private
def serialize(movies)
objects = []
movies.each do |movie|
... |
class UsersController < ApplicationController
before_filter :require_no_user, :only => [:new, :create]
before_filter :require_user, :only => [:show, :edit, :update]
before_filter :require_admin, :only => [:index, :disable, :enable, :request_reset_password]
def index
@users = User.paginate :page => params[:... |
# frozen_string_literal: true
module Files
class Release
attr_reader :options, :attributes
def initialize(attributes = {}, options = {})
@attributes = attributes || {}
@options = options || {}
end
# string - Native release description
def description
@attributes[:description]
... |
module Smsinabox
class Reply
class << self
# Generate a reply from the nokogiri response fragment
def from_response( nokogiri_xml )
reply = new
reply.id = nokogiri_xml.xpath('./replyid/text()').to_s.to_i
reply.event_id = nokogiri_xml.xpath('./eventid/text()').to_s.to_i
... |
class VirtualTownMember < ActiveRecord::Base
attr_accessible :user_id, :active
belongs_to :user
belongs_to :virtual_town
#validates :uniq_request
def posts
posts = []
user.posts.each do |post|
if post.type = "GeolocationPost"
posts << post if post == user.geolocation_post
else
... |
require 'tokyocabinet'
module StrokeDB
module Views
module TokyoCabinetView
include TokyoCabinet
attr_accessor :tc_path, :tc_bdb, :tc_bdbcur
C = "".freeze
# Opens a view with the options.
def open(options)
OptionsHash!(options)
@tc_path = options.require... |
require 'rails_helper'
RSpec.describe Post, type: :post do
describe 'アルバム新規登録' do
before do
user = FactoryBot.create(:user)
content = FactoryBot.create(:content, user_id: user.id)
@post = FactoryBot.build(:post,content_id: content.id,user_id: user.id)
end
context '内容に問題がない場合' do
... |
# frozen_string_literal: true
require 'rails_helper'
describe UserDashboardFacade do
before :each do
user = create(:user)
user.token = Token.create(github_token: ENV['GITHUB_API_KEY'])
@test_facade = UserDashboardFacade.new(user)
end
it 'exists' do
# TODO: update with Oauth token
expect(@te... |
#! /usr/bin/env ruby
# Overloading - refers to invoking different behavior of a method of class depending on it's arguments.
# e.g the method behaves different depending on it's invoked arguments.
def overloading(*args)
if args.empty?
puts "Hi I'm empty!"
else
puts "I'm not empty!"
end
end
overloading
o... |
require 'rails_helper'
RSpec.describe Item, type: :model do
before do
@item = FactoryBot.build(:item)
end
describe '商品出品機能' do
context '出品登録がうまくいくとき' do
it '全項目が正しく入力されている' do
expect(@item).to be_valid
end
it 'category_id,status_id,cost_id,area_id,send_day_idのidが0以外である' do
... |
module Spree
class BestSellingProductsReport < Spree::Report
DEFAULT_SORTABLE_ATTRIBUTE = :sold_count
HEADERS = { sku: :string, product_name: :string, sold_count: :integer }
SEARCH_ATTRIBUTES = { start_date: :orders_completed_from, end_date: :orders_completed_to }
SORTABLE_ATTRIBUTES = [:product_name,... |
require 'digest/sha1'
class User < ActiveRecord::Base
set_table_name 'mst_users'
# Virtual attribute for the unencrypted password
# attr_accessor :password
before_save :encrypt_password
# prevents a user from submitting a crafted form that bypasses activation
# anything else you want your user to chang... |
class Car < ApplicationRecord
# ALLOWED_SYMBOLS_TABLE=["a","b","e","k","m","h","o","p","c","t","y","x"].freeze
# ALLOWED_FIGURES_TABLE = ["0","1","2","3","4","5","6","7","8","9"].freeze
ALLOWED_SYMBOLS_TABLE = %w[a b e k m h o p c t y x].freeze
ALLOWED_FIGURES_TABLE = %w[0 1 2 3 4 5 6 7 8 9].freeze
ENGLETTER... |
# 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 AddAttachmentJournalThumbnailToJournals < ActiveRecord::Migration
def self.up
change_table :journals do |t|
t.attachment :journal_thumbnail
end
end
def self.down
remove_attachment :journals, :journal_thumbnail
end
end
|
FactoryGirl.define do
factory :track do
title { Faker::Name.title }
length 'one minute and 40 seconds'
end
factory :track_1, parent: :track do
length 'one minute and 40 seconds'
end
factory :track_2, parent: :track do
length '27 minutes and 12 seconds'
end
factory :invalid_track, paren... |
module Concerns::Section::Method
extend ActiveSupport::Concern
included do
CONTENTS_PATH = /\A\/contents\//
Settings.section.features.each do |name, value|
define_method("#{name}?") do
self.feature == Settings.section.features[name]
end
end
#
#=== 所属のトップフォルダの作成
#
d... |
class AddCutoffToPredictions < ActiveRecord::Migration
def change
add_column :predictions, :cutoff, :string
end
end
|
# == Schema Information
#
# Table name: categories
#
# id :bigint(8) not null, primary key
# description :string
# created_at :datetime not null
# updated_at :datetime not null
#
class Category < ApplicationRecord
has_paper_trail
has_many :categorizations
has_many :services... |
class InesitaCLI < Thor
include Thor::Actions
check_unknown_options!
namespace :build
desc 'build [OPTIONS]', 'Build Inesita app'
method_option :force,
aliases: ['-f'],
default: false,
desc: 'force overwrite'
method_option :destination,
al... |
class Comment < ActiveRecord::Base
belongs_to :truck
validates :author, :comment, :presence => true
end
|
#!/usr/bin/env ruby
# Programmer: Chris Bunch
require 'rubygems'
require 'json'
require 'babel'
require 'common_functions'
require 'custom_exceptions'
require 'exodus_task_info'
# Exodus provides further improvements to Babel. Instead of making users tell
# us what compute, storage, and queue services they want t... |
class JokesController < ApplicationController
def index
@jokes = Joke.all
end
def new
@joke = Joke.new
end
def create
@user = session[:user_id]
@joke = Joke.create(joke_params)
if @joke.valid?
redirect_to user_path(@joke.user)
else
... |
class ProjectsController < ApplicationController
# GET /projects
# GET /projects.json
skip_before_filter :authorize, only: [:show, :index]
include ApplicationHelper
include ActionView::Helpers::DateHelper
def index
@params = params
# Main List
if !params[:sort].nil? and ['like_count', 'views'... |
# 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).
require 'activerecord-import'
ActiveRecord::Import.require_adapter(ActiveRecord::Base.configurations[Rails.env]['adapte... |
Rails.application.routes.draw do
# Comment Routes
get 'comments/new'
get 'comments/create'
get 'comments/edit'
get 'comments/update'
root to: 'sessions#new'
post '/auth/:provider/callback', to: 'sessions#create'
get 'auth/:provider/callback', to: 'sessions#create'
get 'auth/failure', to: redirect('/'... |
class Comment < ActiveRecord::Base
include DateTimeConverter
include IndexCheck
belongs_to :user
belongs_to :task
validates :content, presence: true
end
|
require 'pry'
class Song < ActiveRecord::Base
belongs_to :artist
belongs_to :genre
has_many :notes
def artist_name=(name)
self.artist = Artist.find_or_create_by(name:name)
end
def artist_name
self.artist.name if self.artist
end
def genre_name=(name)
self.genre ... |
# Path to root of plugin dir
plugin_root = File.join(File.dirname(__FILE__), '..', '..', '..')
$:.unshift(File.join(plugin_root, 'lib'))
RAILS_ENV = 'test'
RAILS_ROOT = File.join(plugin_root, 'test', 'iq', 'storage', 'rails_root')
# Use vendor rails if possible
if File.directory?(rails_dir = File.join(plugin_root, '.... |
class RemoveIndex < ActiveRecord::Migration
def up
add_index :follows, [:follower_id, :followed_id], unique: true
end
def down
remove_index(:follows, :name => "index_follows_on_follower_id_and_followed_id")
end
end
|
class EventMailer < ApplicationMailer
def event_paid event
@event = event
mail(to: event.user.email, subject: "⚽️ Bookingsports: Заказ оплачен!")
end
def event_paid_notify_coach event
@event = event
mail(to: @event.coach.user.email, subject: "⚽️ Bookingsports: Заказ оплачен!")
end
def event_... |
class PortfoliosController < ApplicationController
layout 'portfolio'
#this is generally used when you want to list out a number of items
def index
#class variable =
#model veiw controller
#calling the model(Portfolio.all) inside of the controller(this file)
#portfolio items now available to the... |
class User
include MongoMapper::Document
key :name, String
key :email, String
many :selections
validates :name, :presence => true
validates :email, :presence => true
validates :email, :uniqueness => { :message => " has already been registered" }
end
|
# Problem 108: Diophantine reciprocals I
# http://projecteuler.net/problem=108
# In the following equation x, y, and n are positive integers.
#
# 1/x
# +
# 1/y
# =
# 1/n
#
# For n = 4 there are exactly three distinct solutions:
#
# 1/ 5
# +
# 1/ 20
# =
# 1/ 4
# 1/ 6
# +
# 1/ 12
# =
# 1/ 4
# 1/ 8
# +
#... |
class ResponseHandler
def send_response(page_view, client, verb, response_code, redirect_path)
puts "Sending response."
client.puts headers(output(page_view), verb, response_code, redirect_path)
client.puts output(page_view) if verb == "GET"
puts ["Wrote this response:", headers(output(page_v... |
module Commonsense
module Core
class Document < ActiveRecord::Base
has_many :incoming_document_relations,
:class_name => "DocumentRelation",
:foreign_key => "destination_id",
:dependent => :destroy
has_many :outgoing_document_relations,
... |
class SongRequestsController < ApplicationController
before_action :set_song_request, only: [:show]
# GET /song_requests
# GET /song_requests.json
def index
@song_requests = SongRequest.all
end
# GET /song_requests/1
# GET /song_requests/1.json
def show
render layout: false
end
# GET /son... |
# == Schema Information
#
# Table name: votes
#
# id :integer not null, primary key
# value :integer
# votable_id :integer
# votable_type :string
# created_at :datetime not null
# updated_at :datetime not null
# user_id :integer
# comment_id :integer
# pos... |
class Page < ActiveRecord::Base
has_many :users, through: :user_pages
belongs_to :page
has_many :pages
has_many :sections
belongs_to :setting
attr_accessible :name, :order, :page_id, :setting_id
def self.first_level
where(page_id: nil)
end
def self.second_level(id)
where(page_id: id)
end
... |
Rails.application.routes.draw do
devise_for :users, :controllers => { registrations: 'registrations' }
#Create the resources route for the posts controller
resources :posts
#Set the index action in the PostsController to be the root route
root 'posts#index'
resources :posts do
resources :comments
e... |
# frozen_string_literal: true
module Jobs
class RemoveUploadFromS3 < ::Jobs::Base
sidekiq_options queue: 'low'
def execute(args)
upload_id = check_args(args, :upload_id)
path = check_args(args, :path)
DiscourseBackupUploadsToS3::Utils.s3_helper.remove(path, true)
PluginStore.remove... |
class AddCvvToFunds < ActiveRecord::Migration
def change
add_column :funds, :cvv, :string
end
end
|
require 'rails_helper'
def log_user_in
user = FactoryGirl.create(:user, :email => "will@example.com", :password => "password")
visit '/users/sign_in'
fill_in "Email", :with => "will@example.com"
fill_in "Password", :with => "password"
click_button "Log in"
end
describe "the registration process", :type => :f... |
class CalendarEventsGrid
include Datagrid
Datagrid.configure do |config|
# Defines date formats that can be used to parse date.
# Note that multiple formats can be specified but only first format used to format date as string.
# Other formats are just used for parsing date from string in case your A... |
class UsersController < ApplicationController
skip_before_filter :verify_authenticity_token
def index
@users = User.all
end
def show
current_user = authenticate_token
@user = User.find(params[:id])
@follower_stat = @user.user_followers.count
@followed_stat = @user.user_followed.count
... |
require 'spec_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by the Rails when you ran the scaffold generator.
describe SalesController do
def mock_sale(stubs={})
@mock_sale ||= ... |
class Hero
attr_accessor :name , :power, :bio, :team
@@all = []
def initialize(name,power,bio)
@name = name
@power = power
@bio = bio
end
def self.all
@@all
end
end
|
require 'lib/model.rb'
require 'lib/commands.rb'
Scrummy::Sprint.define "09:06" do
schedule "2009-05-04", "2009-05-29",
:exclude_weekends => true,
:exclude_dates => %w(2009-05-21 2009-05-22)
goal "To be able to start developing flash game on the new GDK 2.0"
participants :engand, :erifre, :norhel
story "... |
class OfficeSerializer < ActiveModel::Serializer
attributes :id, :city, :name, :state, :country
end
|
class Part < ApplicationRecord
has_and_belongs_to_many :boxes
serialize :external_ids, Hash
validates :part_sku, uniqueness: true
end
|
# frozen_string_literal: true
module UserService
class Register < Base
def initialize(user_id:, role:)
@user_id = user_id
@role = role
@token = get_token
end
def execute
role_id = get_role_id
assign_role(role_id)
end
private
def get_role_id
url = URI("h... |
module Susanoo
module Exports
module Creator
#
#= Exportの各ファイル作成クラスの基底クラス
#
class Base
include Exports::Helpers::Logger
include Exports::Helpers::PathHelper
include Exports::Sync::Rsync
include Helpers::ServerSyncHelper
#
#=== ActionDispatc... |
class AddAttributesForWorks < ActiveRecord::Migration[5.2]
def change
add_column :works, :name, :string
add_column :works, :description, :string
add_column :works, :creator, :string
add_column :works, :publication_year, :date
add_column :works, :category, :string
end
end
|
# frozen_string_literal: true
# This is the user model
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable
validates :em... |
class CreateTransfers < ActiveRecord::Migration[6.0]
def change
create_table :transfers do |t|
t.references :source_account, null: false, foreign_key: { to_table: :accounts }
t.references :destination_account, null: false, foreign_key: { to_table: :accounts }
t.references :source_event, null: fa... |
class BugRequest < ApplicationRecord
belongs_to :project, class_name: "Project", foreign_key: "project_id"
belongs_to :hunter, class_name: "Hunter", foreign_key: "hunter_id"
end |
class AddQueryIdToCmItems < ActiveRecord::Migration
def change
add_column :cm_items, :query_id, :integer
end
end |
#
# Cookbook Name:: anyenv
# Recipe:: system_install
#
# Copyright 2015, uzyexe
#
# All rights reserved - Do Not Redistribute
#
# install required packages
case node['platform']
when 'debian', 'ubuntu'
install_packages = %w{
git
gcc
make
openssl
libssl-dev
libbz2-dev
libffi-dev
librea... |
json.array!(@water_managers) do |water_manager|
json.extract! water_manager, :id, :state
json.url water_manager_url(water_manager, format: :json)
end
|
# frozen_string_literal: true
require_relative '../spec_helper'
require_relative '../../lib/natra'
RSpec.describe Natra::VERSION do
subject { Natra::Generators::AppGenerator }
describe 'source_root' do
it 'should return with a full path' do
pwd = File.dirname(__FILE__)
template_path = pwd... |
# NestedSortable
module NestedSortable
module Controller
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
public
def nested_sortable_data_source_for(model, options = {})
include NestedSortable::ExtendedController
class <<self
... |
class Review < ActiveRecord::Base
belongs_to :book, touch: true
belongs_to :user
end
|
# frozen_string_literal: true
module JwtAuthenticatable
extend ActiveSupport::Concern
include ActionController::HttpAuthentication::Token::ControllerMethods
included do
before_action :authenticate_device!
end
attr_reader :current_user
private
def authenticate_device!
authenticate_token || re... |
require 'rails_helper'
RSpec.describe TasksController, type: :controller do
let(:valid_attributes) do
{ name: "Dismantle the trash in the apartment.", slug: "cleaning" }
end
let(:invalid_attributes) do
{ name: '' }
end
let!(:task) { create(:task) }
describe "GET #index" do
it "returns a succ... |
require 'rails_helper'
RSpec.describe "reviewes/edit", type: :view do
before(:each) do
@reviewe = assign(:reviewe, Reviewe.create!())
end
it "renders the edit reviewe form" do
render
assert_select "form[action=?][method=?]", reviewe_path(@reviewe), "post" do
end
end
end
|
names = ["Janet Evans", "Simone Biles", "Deena Kastor"]
def my_collect(array)
i = 0
name_collection = []
while i < array.length
name_collection << yield(array[i])
i += 1
end
name_collection
end
my_collect(names) {|i| i.split(" ").first}
|
class RemoveContactInformationFromSuppliers < ActiveRecord::Migration
def change
remove_column :suppliers, :phone
remove_column :suppliers, :email
end
end
|
class PhotosController < ApplicationController
before_action :authenticate_user!
def create
@entry = Entry.find(params[:entry_id])
@entry.photos.create(photo_params)
redirect_to entry_path(@entry)
end
private
def photo_params
params.require(:photo).permit(:picture, :caption)
end
end
|
module Refinery
module Properties
class AreaCode < Refinery::Core::BaseModel
attr_accessible :name, :position
acts_as_indexed :fields => [:name]
validates :name, :presence => true, :uniqueness => true
has_many :property, :class_name => '::Refinery::Properties::Property'
end
end
en... |
require "spec_helper"
describe Audio do
describe 'enco information validation' do
context "#enco_info_is_present_together" do
it "fails if enco_number present but not enco_date" do
audio = build :audio, enco_date: nil, enco_number: 999
audio.should_not be_valid
audio.errors.keys.sho... |
class Comment < ActiveRecord::Base
belongs_to :idea
validates_presence_of :user_name, :body
end
|
class SearchController < ApplicationController
before_action :authenticate_teacher!
def index
@searches = Paginate.get_records(
relation_object: current_teacher.searches,
page: params[:page],
per_page: params[:per_page]
)
respond_to do |format|
format.js {
rende... |
class HAStats::Actions::Base
attr_accessor :socket, :options
def initialize(socket, options={})
self.socket = socket.is_a?(HAStats::Socket) ? socket : HAStats::Socket.new(socket)
self.options = options
end
def run(*args)
response.new socket.run(command(*args))
end
def response
HAStats::R... |
# frozen_string_literal: true
require 'open-uri'
require 'nokogiri'
require 'fox16'
include Fox
class CategoryList < FXGroupBox
def initialize(p, y)
@selected = []
super(p, "Choose Category: ", :opts => LAYOUT_FILL_X | FRAME_RIDGE | LAYOUT_FIX_Y,
:y => y)
@list = FXList.new(self, opts: LIST_MUL... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.