Forgot your password? You can reset your password here.\"\n redirect_to login_path and return\n end\n \n # setup promo code from params\n if !params[:referral_code].blank? and PromotionCode.exists?(:code => params[:referral_code])\n @promotion_code = PromotionCode.find_by_code(params[:referral_code])\n elsif !session[:stored_promotion_code_id].blank? and PromotionCode.find(session[:stored_promotion_code_id])\n @promotion_code = PromotionCode.find(session[:stored_promotion_code_id])\n else\n @promotion_code = nil\n end\n\n # quiet create extras\n if @quietly_create\n # @user.email_confirmation = @user.email if @user.email_confirmation.blank?\n @user.password = @user.temporary_password\n @user.password_confirmation = @user.password\n @user.quietly_created = true\n @user.customer.quietly_created = true\n end\n\n # add survey question if present\n session[:survey_question_value] = params[:survey_question_value] unless params[:survey_question_value].blank?\n \n # update subscriptions and tracking analytics\n if @user.update_subscriptions(request.referrer, nil, true)\n session[:new_subscriber] = true\n session[:new_subscriber_email] = @user.email\n end\n \n \n # check promo code and attempt to save user\n if !@promotion_code.nil? and !@promotion_code.redeemable?\n flash[:error] = 'Sorry, but that promo code is not redeemable!'\n render :action => 'new'\n elsif @user.save \n flash[:notice] = \"Success! You're officially part of the WTD family.\" unless @quietly_create\n \n # trigger analytics to track\n session[:new_user] = true\n session[:new_subscriber_user_id] = @user.id\n\n # check referrals and credits\n unless @promotion_code.nil?\n unless @promotion_code.bad_referral?(@user.id)\n @credit = Credit.new\n @credit.promotion_code_id = @promotion_code.id\n @credit.value = @promotion_code.value\n @credit.user_id = @user.id\n @credit.referrer_user_id = @promotion_code.user_id\n @credit.save\n else\n flash[:error] = \"Sorry, but there seems to be something wrong with your referral. Please check back in an hour or email us at support@sowhatsthedeal.com.\"\n end\n end\n \n flash[:notice] = params[:flash_notice] || \"Welcome, you are now officially part of the WTD family!\"\n flash[:notice] += \"
Please choose a password to complete your WTD account.\" if @user.quietly_created?\n flash[:notice] = \"Thanks for signing up for Half Price DC\" if partner == 3\n redirect_to session[:return_to] ? session[:return_to] : my_account_path\n else\n @user.password = \"\"\n @user.password_confirmation = \"\"\n flash[:error] = \"Be sure to include your first name, last name and a valid email address.
Remember, If you subscribed to our newsletter, you already have an account. Forgot your password? You can reset your password here.\" if @user.errors.empty?\n session[:return_to] ? redirect_to(session[:return_to]) : render(:action => 'new')\n end\n end","def create\n customer = StripeTool.create_customer(email: params[:stripeEmail], stripe_token: params[:stripeToken])\n\n\tcharge = StripeTool.create_charge(customer_id: customer.id, amount: @amount, description: @description)\n\n current_user.stripe_id = customer.id\n\n\treceipt = Charge.new charge_stripe_token: charge.id, price: @amount, description: @description)\n\n\tif Charge.save\n\n\telse\n\n\tend","def create_stripe_customer_and_subscription(user)\n begin\n s_customer = Stripe::Customer.create(description: user.first_name, card: self.stripe_card_token, email: user.email)\n stripe_customer = StripeCustomer.create(object: s_customer.object, description: s_customer.description, livemode: s_customer.livemode, created_timestamp: s_customer.created, reference_id: s_customer.id, user_id: self.user_id)\n customer = Stripe::Customer.retrieve(stripe_customer.reference_id)\n \n if user.plan_name == \"school_closing_date\" && user.plan == \"daily\"\n stripe_charge = Stripe::Charge.create(amount: stripe_charge_amount(user), currency: \"usd\", customer: s_customer.id, description: \"school_closing daily\")\n user.stripe_charges.create(amount: stripe_charge_amount(user), currency: \"usd\", description: \"test\", stripe_customer_id: stripe_customer.id)\n elsif user.plan_name == \"school_closing_date\" && user.plan == \"all_days\"\n stripe_charge = Stripe::Charge.create(amount: stripe_all_dates, currency: \"usd\", customer: s_customer.id, description: \"school_closing all days\")\n user.stripe_charges.create(amount: stripe_all_dates, currency: \"usd\", description: \"test\", stripe_customer_id: stripe_customer.id)\n elsif user.plan_name == \"christmas_break\" && user.plan == \"daily\"\n stripe_charge = Stripe::Charge.create(amount: stripe_charge_amount(user), currency: \"usd\", customer: s_customer.id, description: \"xmas daily\")\n user.stripe_charges.create(amount: stripe_charge_amount(user), currency: \"usd\", description: \"test\", stripe_customer_id: stripe_customer.id)\n elsif user.plan_name == \"christmas_break\" && user.plan == \"all_days\"\n stripe_charge = Stripe::Charge.create(amount: stripe_all_dates, currency: \"usd\", customer: s_customer.id, description: \"Xmas all days\")\n user.stripe_charges.create(amount: stripe_all_dates, currency: \"usd\", description: \"test\", stripe_customer_id: stripe_customer.id) \n elsif user.plan_name == \"spring_break\" && user.plan == \"daily\"\n stripe_charge = Stripe::Charge.create(amount: stripe_charge_amount(user), currency: \"usd\", customer: s_customer.id, description: \"spring break daily\")\n user.stripe_charges.create(amount: stripe_charge_amount(user), currency: \"usd\", description: \"test\", stripe_customer_id: stripe_customer.id)\n elsif user.plan_name == \"spring_break\" && user.plan == \"all_days\"\n stripe_charge = Stripe::Charge.create(amount: stripe_all_dates, currency: \"usd\", customer: s_customer.id, description: \"spring break all days\")\n user.stripe_charges.create(amount: stripe_all_dates, currency: \"usd\", description: \"test\", stripe_customer_id: stripe_customer.id) \n elsif user.plan_name == \"charlotte\" || user.plan_name == \"noresmen_cheer\"\n \n stripe_charge = Stripe::Charge.create(amount: stripe_football_amount(user), currency: \"usd\", customer: s_customer.id, description: \"Charge For Charlotte\")\n user.stripe_charges.create(amount: stripe_football_amount(user), currency: \"usd\", description: \"Charlotte\", stripe_customer_id: stripe_customer.id)\n \n elsif user.plan_name == \"eden\" || user.plan_name == \"noresmen_cheer\"\n \n stripe_charge = Stripe::Charge.create(amount: stripe_football_amount(user), currency: \"usd\", customer: s_customer.id, description: \"Charge for Eden\")\n user.stripe_charges.create(amount: stripe_football_amount(user), currency: \"usd\", description: \"Eden\", stripe_customer_id: stripe_customer.id)\n\n elsif user.plan_name == \"early_bird\" || user.plan_name == \"norsemen_baseball\"\n stripe_charge = Stripe::Charge.create(amount: stripe_early_bird_amount(user), currency: \"usd\", customer: s_customer.id, description: \"EarlyBird\")\n user.stripe_charges.create(amount: stripe_early_bird_amount(user), currency: \"usd\", description: \"EarlyBird\", stripe_customer_id: stripe_customer.id) \n \n elsif user.plan_name == \"wffull\" || user.plan_name == \"norsemen_baseball\"\n stripe_charge = Stripe::Charge.create(amount: stripe_wffull_amount(user), currency: \"usd\", customer: s_customer.id, description: \"WFF FULL DAY\")\n user.stripe_charges.create(amount: stripe_wffull_amount(user), currency: \"usd\", description: \"WFF FULL\", stripe_customer_id: stripe_customer.id) \n\n elsif user.plan_name == \"wffhalf\" || user.plan_name == \"norsemen_baseball\"\n stripe_charge = Stripe::Charge.create(amount: stripe_wffhalf_amount(user), currency: \"usd\", customer: s_customer.id, description: \"WFF HALF DAY\")\n user.stripe_charges.create(amount: stripe_wffhalf_amount(user), currency: \"usd\", description: \"WFF HALF DAY\", stripe_customer_id: stripe_customer.id) \n \n elsif user.plan_name == \"nonfull\" || user.plan_name == \"norsemen_baseball\"\n stripe_charge = Stripe::Charge.create(amount: stripe_nonfull_amount(user), currency: \"usd\", customer: s_customer.id, description: \"NON FULL DAY\")\n user.stripe_charges.create(amount: stripe_nonfull_amount(user), currency: \"usd\", description: \"NON FULL DAY\", stripe_customer_id: stripe_customer.id) \n \n elsif user.plan_name == \"nonhalf\" || user.plan_name == \"norsemen_baseball\"\n stripe_charge = Stripe::Charge.create(amount: stripe_nonhalf_amount(user), currency: \"usd\", customer: s_customer.id, description: \"NON HALF DAY\")\n user.stripe_charges.create(amount: stripe_nonhalf_amount(user), currency: \"usd\", description: \"NON HALF DAY\", stripe_customer_id: stripe_customer.id) \n\n else\n \n \n subscription = customer.subscriptions.create(:plan => payment_discount(user.plan_name))\n user.subscriptions.create(stripe_card_token: subscription.id,plan_name: user.plan_name, stripe_customer_id: stripe_customer.id)\n end\n rescue Exception => e\n end\n end","def save_with_payment\n if valid?\n customer = Stripe::Customer.create(description: email, plan: plan_id, source: stripe_card_token)\n self.stripe_customer_token = customer.id\n save!\n end\n end","def create\n @user = User.new(user_params)\n\n if @user.save\n @user.update_attribute(:token, SecureRandom.hex(6))\n RegistrationMailer.registration_confirmation(@user, new_email_confirmation_url(token: @user.token)).deliver\n if( @user.account == \"premium\")\n redirect_to new_charge_path :user, @user\n else\n redirect_to root_path, notice: \"An email has been sent to your account. Please click the link in the email to verify address and complete your registration.\"\n end\n else\n flash[:error] = \"Error creating new user. Please try again.\"\n render :new\n end\n\n end","def create_customer\n input_param = params[:user] || params[:customer]\n if input_param\n input_param.delete(:password)\n input_param.delete(:password_confirmation)\n input_param.delete(:username)\n if current_user.is_a?(Referral) && input_param[:profile_attributes].present?\n input_param[:referral_category_id] = current_user.referral_category_id\n input_param[:profile_attributes][:referal_id] = current_user.code\n input_param[:profile_attributes][:referal] = current_user.referral_category.name if current_user.referral_category\n end\n end\n\n @customer = Customer.find_or_initialize_by_email(input_param[:email])\n @membership_order = Membership.find(session[:current_premium_id]) if session[:current_premium_id]\n \n if @customer.update_attributes(input_param)\n order.orderable = @customer\n # CustomerMailer.delay.welcome_email(@customer)\n CustomerMailer.delay.welcome_email_admin(@customer)\n \n if order.save && session[:current_premium_id].present?\n redirect_to extra_manage_orders_path\n else\n redirect_to premium_manage_orders_path\n end\n else\n @customer = Customer.new(input_param)\n flash[:errors] = @customer.errors.full_messages.uniq.join(', ')\n prepare_customer_form\n render :new\n end\n end","def purchase_events_new_stripe_customer\n token = params[:stripeToken]\n @number = params[:number].to_i\n coupon = params[:coupon]\n cost = params[:cost]\n\n if create_customer_and_purchase_existing_user(token, @number, cost, coupon) # this is almost like create_customer_purchase, except have flash.nows in that helper\n #if the customer had a coupon, update that coupon to be inactive, and attach customer's user id to it\n # if !coupon.blank?\n # redeem_single_use_coupon(coupon)\n # end \n redirect_to current_user\n else\n redirect_to existing_user_purchase_path\n end \n\nend","def create\n @new_sign_up = false #don't call alias again, but do call identify from here on\n Stripe.api_key = ENV['STRIPE_SECRET_KEY']\n\n unless ( params[:card].present? && params[:card][:card_number].present? &&\n params[:card][:exp_year].present? && params[:card][:exp_month].present? &&\n params[:card][:cvc].present? && params[:card][:plan_id].present? &&\n params[:phone].present? && params[:customer_card_name].present?\n )\n\n puts \"-----StripeCC - Missing Fields In Form\"\n flash.now[:alert] = \"Missing Details - All Fields are compulsory\"\n @name = params[:customer_card_name]\n @phone = params[:phone]\n render 'users/payment'\n return\n end\n\n \t\t@error = current_user.create_stripe_subscription(subscription_params)\n\n\t \tif @error.present?\n\t \t\tflash.now[:alert] = @error\n\t \t\tlogger.warn(\"=========Stripe Controller - Transaction Failure=========\")\n @transaction = Transaction.new( :user_id => current_user.id,\n :payment_service => \"Stripe\",\n :trans_type => \"Failed\",\n :stripe_callback_data => @error\n )\n unless @transaction.save\n puts \"-----StripeCC - Our Transaction Did Not Save on Stripe Fail\"\n end\n\n # back to payment screen:\n\t \t\trender 'users/payment'\n\n\t \telse #success\n\t \t\tflash.now[:notice] = \"Subscription Successfull\"\n\t \t\tlogger.warn(\"=========Transaction Successfull=========\")\n @transaction = Transaction.where(:user_id => current_user.id).order(\"id DESC\").first\n if @transaction.present?\n @transaction.update_attributes(\n :payment_service => \"Stripe\",\n :trans_type => \"Recurring\"\n )\n else\n puts \"-----StripeCC - Our Transaction Did Not Save on Stripe Success\"\n end\n\n namearray = (params[:customer_card_name]).split(' ', 2)\n save_user = current_user.update_attributes(:phone => (params[:phone]),\n :first_name => namearray.first, :last_name => namearray.last)\n puts \">>> current user did not save email and name.\" if save_user == false\n\n\t \t\tredirect_to submit_bill_path, :notice => \"Subscription Successful.\"\n\t end\n\n end","def create\n @Payment = Payment.new\n @Payment.user_id = current_user\n\n Stripe.api_key = ENV[\"STRIPE_API_KEY\"]\n token = params[:stripeToken]\n\n begin\n charge = Stripe::Charge.create(\n :amount => (25 * 100).floor,\n :currency => \"usd\",\n :card => token\n )\n flash[:notice] = \"Thanks for purchasing!\"\n rescue Stripe::CardError => e\n flash[:danger] = e.message\n end\n\n @Payment.stripe_id = charge.id\n @Payment.amount = charge.amount\n\n if current_user.subscribed != true\n current_user.subscribed = true\n current_user.credit = 25.00\n else\n current_user.credit = current_user.credit + 25.00\n end\n\n current_user.save\n redirect_to caves_path\n end","def purchase_sub_existing_card\n @plan = params[:sub][:plan] #integer corresponding to my_plan_id\n @events_number = params[:sub][:events_number]\n @code = params[:sub][:code]\n @new_price = params[:sub][:new_price]\n\n # retrieve stripe customer object yet again\n if !current_user.customer_id.blank?\n c = Stripe::Customer.retrieve(current_user.customer_id)\n end \n \n if is_valid_sub_coupon(@code) \n\n #create subscription for this customer in stripe (note that update_subscription creates a new subscription for this customer in this case)\n if has_not_trialed?\n c.update_subscription(:plan => @plan, :coupon => @code)\n else\n c.update_subscription(:plan => @plan, :trial_end => (Date.today + 1.day).to_time.to_i, :coupon => @code) \n end \n #create new subscription object in my database\n @sub = Subscription.new(:user_id => current_user.id, :email => current_user.email, :customer_id => c.id, :my_plan_id => @plan, :plan_name => Plan.find_by_my_plan_id(@plan).name, :active => true)\n @sub.events_remaining = @events_number\n @sub.coupon = @code\n @sub.save \n\n #create receipt\n @r = Receipt.new(:user_id => current_user.id, :email => current_user.email, :customer_id => c.id,\n :subscription_id => @sub.id, :sub_my_plan_id => @sub.my_plan_id, :sub_plan_name => @sub.plan_name,\n :sub_events_number => @sub.events_remaining, :sub_reg_monthly_cost_in_cents => Plan.find_by_my_plan_id(@sub.my_plan_id).monthly_cost_cents,\n :sub_actual_monthly_cost_in_cents => @new_price, :sub_coupon_name => @sub.coupon) \n @r.save\n\n #mail receipt\n UserMailer.sub_receipt(current_user, @r).deliver\n\n else\n #create subscription for this customer in stripe (note that update_subscription creates a new subscription for this customer in this case)\n if has_not_trialed?\n c.update_subscription(:plan => @plan)\n else\n c.update_subscription(:plan => @plan, :trial_end => (Date.today + 1.day).to_time.to_i) \n end \n #create new subscription object in my database\n @sub = Subscription.new(:user_id => current_user.id, :email => current_user.email, :customer_id => c.id, :my_plan_id => @plan, :plan_name => Plan.find_by_my_plan_id(@plan).name, :active => true)\n @sub.events_remaining = @events_number\n @sub.save \n\n #create receipt\n @r = Receipt.new(:user_id => current_user.id, :email => current_user.email, :customer_id => c.id,\n :subscription_id => @sub.id, :sub_my_plan_id => @sub.my_plan_id, :sub_plan_name => @sub.plan_name,\n :sub_events_number => @sub.events_remaining, :sub_reg_monthly_cost_in_cents => Plan.find_by_my_plan_id(@sub.my_plan_id).monthly_cost_cents,\n :sub_actual_monthly_cost_in_cents => @new_price, :sub_coupon_name => @sub.coupon) \n @r.save\n\n #mail receipt\n UserMailer.sub_receipt(current_user, @r).deliver\n end \n\n\n flash[:success] = \"Thank you! You are now subscribed to the #{Plan.find_by_my_plan_id(@plan).name.titleize} plan!\"\n redirect_to current_user\n\n #rescue Stripe::StripeError => e # THIS CODE WORKS!!! NEEED TO FIGURE OUT HOW EXACTLY\n # logger.error \"Stripe error while creating subscription w/o active sub for existing user with card on file (purchase_sub_existing_card)\"\n # flash[:error] = \"Something went wrong. Please try again or contact us!\"\n # redirect_to current_user\n\nend","def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n\n Stripe.api_key = ENV[\"STRIPE_SECRET_KEY\"]\n\n stripe_customer = Stripe::Customer.create(\n :email => @user.email,\n )\n @user.stripe_id = stripe_customer.id\n end","def create\n # set up Stripe session\n Stripe.api_key = YAML.load_file(\"#{Rails.root}/config/stripe.yml\")[Rails.env][:secret_key]\n\n @account_type = AccountType.find params[:account_type_id]\n @account = Account.new({ :account_type_id => @account_type.id, name: account_params[:name] })\n\n user = User.new(user_params)\n unless user.valid?\n flash[:notice] = 'User invalid'\n render :new\n return\n end\n\n # Get the credit card details submitted by the form\n customer = create_stripe_customer(params[:stripeToken], user.email)\n\n @account.stripe_customer_id = customer.id\n\n begin\n # Create the charge on Stripe's servers - this will charge the user's card\n subscription = customer.subscriptions.create(:plan => @account_type.stripe_subscription_plan)\n @account.recurrence_at = Time.at(subscription.start.to_i).utc.strftime('%d')\n\n rescue Exception => e\n # The card has been declined\n flash[:notice] = e.message\n render :new\n return\n end\n\n respond_to do |format|\n begin\n @account.save\n user.save\n AccountUser.create({ :account_id => @account.id, :user_id => user.id })\n\n format.html { redirect_to confirm_email_path, notice: 'Account was successfully created.' }\n format.json { render :show, status: :created, location: @account }\n rescue Exception => e\n flash[:notice] = e.message\n format.html { render :new }\n format.json { render json: e.message, status: :unprocessable_entity }\n end\n end\n # respond_to do |format|\n # if @account.save\n # if user.save\n # AccountUser.create({ :account_id => @account.id, :user_id => user.id })\n # else\n # format.html { render :new }\n # format.json { render json: user.errors, status: :unprocessable_entity }\n # end\n # format.html { redirect_to confirm_email_path, notice: 'Account was successfully created.' }\n # format.json { render :show, status: :created, location: @account }\n # else\n # format.html { render :new }\n # format.json { render json: @account.errors, status: :unprocessable_entity }\n # end\n # end\n end","def update_card_and_new_subscription(token, plan, code) # plan is now a my_plan_id\n #should be a customer_id b/c downstream from option in which user has an existing stripe customer id\n c = Stripe::Customer.retrieve(current_user.customer_id)\n \n\n #updates customer with new card\n c.card = token\n c.save\n\n if !code.nil? && is_valid_sub_coupon(code) \n #create subscription for this customer in stripe (note that update_subscription creates a new subscription for this customer in this case)\n if has_not_trialed?\n c.update_subscription(:plan => plan, :coupon => code)\n else #this shouldn't happen b/c in an upstream controller, set code to nil if has_trialed\n c.update_subscription(:plan => plan, :trial_end => (Date.today + 1.day).to_time.to_i, :coupon => code)\n end \n else\n #create subscription for this customer in stripe (note that update_subscription creates a new subscription for this customer in this case)\n if has_not_trialed?\n c.update_subscription(:plan => plan)\n else\n c.update_subscription(:plan => plan, :trial_end => (Date.today + 1.day).to_time.to_i)\n end \n end \n\n rescue Stripe::InvalidRequestError => e\n logger.error \"Stripe error while creating customer: #{e.message}\"\n flash[:error] = \"There was a problem processing your credit card. #{e.message}. Please try again.\"\n false\n \n rescue Stripe::CardError => e\n logger.error \"Stripe error while creating customer: #{e.message}\"\n flash[:error] = \"There was a problem processing your credit card. #{e.message}. Please try again.\"\n false\n\n rescue Stripe::StripeError => e\n logger.error \"Stripe error while creating customer: #{e.message}\"\n flash[:error] = \"There was a problem processing your credit card. #{e.message}. Please try again.\"\n false\n\n end","def create_stripe\n # Order created by promotions#order and passed to merchant/orders/order_form\n # Cases: 1) not a customer; saving card\n # 2) not a customer; not saving card\n # 3) customer; using saved card\n # 4) customer; using new card and saving it\n # 5) customer; using new card and not saving it\n #\n # NOTE: I'm saving the associated user object in the orders controller, instead of trying to do it in the User model\n # I think it makes more sense to isolate all the Stripe stuff here, than have it scattered through models.\n # I also removed Stripe code from the Order model. It is all in the controller and User model (where it belongs).\n\n @stripe_customer = @order.user.stripe_customer_obj\n\n # Calculate total charge, adjusting for macho bucks. Do we need to charge the card?\n total_charge = @order.total_cost - @order.user.total_macho_bucks\n if total_charge > 0\n # We need to charge the credit card \n if @stripe_customer.nil?\n charge_success = false\n \n if params[:save_card] == 'true'\n # case 1\n @stripe_customer = Stripe::Customer.create(:email => @order.email,\n :description => @order.description,\n :card => @order.stripe_card_token)\n \n # Not in attr_accessible for security; must assign explicitly\n @order.user.stripe_id = @stripe_customer.id\n if @order.user.save\n charge_success = charge_customer(@order, @stripe_customer, total_charge)\n else\n flash[:notice] = \"Card could not be saved.\"\n charge_success = charge_card(@order, total_charge)\n end\n else \n # case 2\n charge_success = charge_card(@order, total_charge)\n end\n else\n # get existing customer\n if params[:new_card] == 'true'\n if params[:save_card] == 'true'\n # case 4\n # Update the card information for an existing customer\n @stripe_customer.card = @order.stripe_card_token\n @stripe_customer.save\n \n charge_success = charge_customer(@order, @stripe_customer, total_charge)\n else\n # case 5\n charge_success = charge_card(@order, total_charge)\n end\n else\n # case 3\n charge_success = charge_customer(@order, @stripe_customer, total_charge)\n end\n end\n else\n # No charge necessary\n charge_success = true\n # Validated, so it has to be there\n @order.transaction_id = Order::MACHO_BUCKS_TRANSACTION_ID\n end\n \n # Charge operation should either succeed or throw an exception\n if charge_success\n # If the charge was successful, order will have charge_id (validated on save)\n if @order.save\n # After saving the order, create the associated vouchers using the promotion strategy\n # status defaults to Available; uuid is created upon save\n if @order.promotion.strategy.generate_vouchers(@order)\n flash[:notice] = I18n.t('order_successful')\n \n # If everything worked (voucher(s) saved), send the email\n # Products are handled differently in the mailer\n UserMailer.delay.promotion_order_email(@order)\n @order.user.log_activity(@order)\n \n # Debit the Macho Bucks. Usually 0, but possible they had more bucks than it cost\n # In the pathological case where they have negative macho bucks, the card was charged extra. That has to be cleared as well.\n # So we have to check for != 0, not > 0\n if @order.user.total_macho_bucks != 0\n deduction = @order.user.total_macho_bucks < 0 ? @order.user.total_macho_bucks : [@order.user.total_macho_bucks, @order.total_cost].min\n bucks = @order.build_macho_buck(:user_id => @order.user.id, :amount => -deduction, :notes => \"Credited on order: #{@order.description}\")\n if !bucks.save\n flash[:alert] = 'Unable to apply macho bucks!'\n end\n UserMailer.delay.macho_bucks_order_email(bucks)\n end\n \n redirect_to merchant_order_path(@order) and return\n end\n else\n @order.errors.add :base, \"Could not save order.\"\n end\n end\n\n # Should never get here, put theoretically possible if orders don't validate somehow; avoid template error\n render 'new' \n \n # Don't need a begin inside a def\n rescue Stripe::InvalidRequestError => error\n logger.error \"Stripe error while creating customer: #{error.message}\"\n @order.errors.add :base, \"There was a problem with your credit card. #{error.message}\"\n @promotion = @order.promotion\n render 'promotions/order'\n \n rescue Stripe::CardError => error\n logger.error \"Stripe error: #{error.message}\"\n @order.errors.add :base, \"There was a problem with your credit card. #{error.message}\"\n @promotion = @order.promotion\n render 'promotions/order'\n end","def create_stripe_customer!\n Stripe::Customer.create(\n email: user.email,\n description: store.name,\n source: stripe_source_id\n )\n end","def subscription_checkout\n\n @code = params[:couponCode]\n\n if !@code.blank?\n @discount = @code\n\n if @discount.nil?\n flash[:error] = 'Coupon code is not valid or expired.'\n redirect_to pricing_path\n return\n end\n\n charge_metadata = {\n :coupon_code => @code,\n :coupon_discount => (@discount * 100).to_s + \"%\"\n }\n end\n\n charge_metadata ||= {}\n\n plan_id = params[:plan_id]\n plan = Stripe::Plan.retrieve(plan_id)\n #This should be created on signup.\n customer = Stripe::Customer.create(\n #:description => \"Customer for test@example.com\",\n :source => params[:stripeToken],\n :email => current_user.email\n )\n\n user = current_user\n user.stripe_id = customer.id\n user.subscribed = true\n user.save\n\n # Save this in your DB and associate with the user;s email\n stripe_subscription = customer.subscriptions.create(:plan => plan.id, :coupon => @discount)\n\n flash[:notice] = \"Successfully Subscribed!\"\n redirect_to '/dashboard'\n end","def create\n plan = params[\"payment\"][\"plan\"]\n plan=\"premium_monthly\" if plan.empty?\n stripe_token = params[:payment][:stripe_customer_token]\n cardHolderName = params[\"cardHolderName\"]\n email = params[\"payment\"][\"email\"]\n flag = false\n\n if stripe_token\n begin\n @payment = current_user.payments.new(payment_params)\n customer = current_user.do_transaction(params[:payment_type], stripe_token, plan, cardHolderName, email)\n if customer\n @payment.stripe_customer_token = customer.id\n subcripted_detail = customer.subscriptions[\"data\"][0]\n flash[:notice] = 'Card charged successfully'\n else\n flag = true\n flash[:alert] = 'Some error happened while charging you, please double check your card details'\n end\n rescue Stripe::APIError => e\n flash[:alert] = e\n flag = true\n end\n else\n flag = true\n flash[:alert] = 'You did not submit the form correctly'\n end\n\n if flag\n render new_payment_path({plan: plan, error: e})\n end\n\n respond_to do |format|\n if @payment.save\n plan = Payment.plans[plan]\n current_user.update_attributes(subscription: plan, remaining_days: -1, stripe_customer_id: customer.id, is_paid_user: true)\n NotificationMailer.monthly_subscription_email(current_user, subcripted_detail).deliver_now\n format.html { redirect_to \"/users/edit\", notice: 'Payment made successfully.'}\n format.json { render json: @payment, status: :created, location: @payment }\n end\n end\n\n end","def create\n @payment = Payment.new(payment_params)\n\n @amount = @payment.amount * 100\n\n Stripe.api_key = 'sk_test_CfSPVwqeJbuCxJSnCDcXuKRG';\n\n begin\n if current_user.stripe_customer_id.present?\n @customer = Stripe::Customer.retrieve(current_user.stripe_customer_id) \n else\n card_details = {}\n card_details[:name] = payment_params[:first_name]\n card_details[:number] = payment_params[:credit_card_number]\n card_details[:cvc] = payment_params[:card_security_code]\n card_details[:exp_month] = payment_params[:expiration_month]\n card_details[:exp_year] = payment_params[:expiration_year]\n\n @card = Stripe::Token.create(card: card_details)\n \n @customer = Stripe::Customer.create(\n :email => current_user.email,\n :card => @card.id\n )\n\n if @customer.present?\n current_user.stripe_customer_id = @customer.id\n current_user.save!\n end\n end\n\n\n @charge = Stripe::Charge.create(\n :customer => @customer.id,\n :amount => @amount,\n :description => 'Autopass payment',\n :currency => 'usd'\n )\n\n if @payment.save\n redirect_to success_payment_path(@payment), notice: 'Payment was successfully created. Vender will be notified.'\n end\n rescue Stripe::CardError => e\n redirect_to \"/siteparking/sitepayments/#{@payment.parking.token}\"\n flash[:error] = e.message\n end \n\n\n end","def success\n if params[:reference].present?\n\n paystackObj = Paystack.new(ENV['PAYSTACK_PUBLIC_KEY'], ENV['PAYSTACK_PRIVATE_KEY'])\n\n subscriptions = PaystackSubscriptions.new(paystackObj)\n result = subscriptions.create(\n\n :customer => current_user.email,\n :plan => \"PLN_96ws6ovviw8028d\", #plan id\n :amount => 200000 #in KOBO\n\n \n )\n\n\n u = current_user\n u.subscribed = true\n u.subscription_code = code\n u.email_token = token\n u.save!\n \n else\n redirect_to new_subscription_path, notice: \"Error Making Payment, Try Again\"\n\n end\n end","def create\n params.permit(:interval, :plan, :stripeEmail, :stripeToken)\n if current_user\n @user = current_user\n begin\n customer = Stripe::Customer.create(\n :email => params[:stripeEmail],\n :source => params[:stripeToken],\n :plan => params[:plan]\n )\n if @user.plan.nil? || @user.plan != params[:plan]\n case params[:interval]\n when \"month\"\n active_date_increment = Time.now + 1.month\n when \"year\"\n active_date_increment = Time.now + 1.year\n when \"week\"\n active_date_increment = Time.now + 1.week\n end\n @user.update_attributes!(\n stripe_customer_id: customer.id,\n active_until: active_date_increment,\n plan: params[:plan],\n stripe_token: params[:stripeToken]\n )\n end\n redirect_to @user\n rescue\n puts \"Unable to register customer with Stripe: #{params[:stripeEmail]}\"\n flash[:alert] = \"There was an error processing the payment. Please try again.\"\n redirect_to plan_path(Stripe::Plan.retrieve(params[:plan]))\n end\n end\n end","def postfill!(customer)\n self.price = customer.subscription.plan.amount / 100\n self.stripe_id = customer.id\n self.exp_month = customer.active_card.exp_month\n self.exp_year = customer.active_card.exp_year\n self.last4 = customer.active_card.last4\n self.status = \"active\"\n self.save!\n self\n end","def purchase_events_new_stripe_couple\n token = params[:stripeToken]\n @number = params[:number].to_i\n coupon = params[:coupon]\n cost = params[:cost]\n\n if create_customer_and_purchase_existing_user(token, @number, cost, coupon) # this is almost like create_customer_purchase, except have flash.nows in that helper\n #if the customer had a coupon, update that coupon to be inactive, and attach customer's user id to it\n # if !coupon.blank?\n # redeem_single_use_coupon(coupon)\n # end \n redirect_to current_user\n else\n redirect_to existing_couple_purchase_select_path({:peu => {:number => @number }, :coupon => coupon})\n end \n\nend","def purchase_sub_not_stripe_customer\n token = params[:stripeToken]\n @plan = params[:plan] #integer corresponding to my_plan_id\n @events_number = params[:events_number] #not being used right now because create_customer helper finds the events_number form the plan object via @plan argument\n @code = params[:code] \n @new_price = params[:new_price]\n event_type = \"voicegems\"\n\n if create_customer(token, @plan, @code, @new_price, event_type) #using the same helper as when a new user signs up as a customer\n #record stripe's (?) customer_id for this user\n # this helper is in users helper\n \n redirect_to current_user\n else\n @first_plan = Plan.find_by_my_plan_id(plan_set_one) # sets @first_plan the first plan object ACCORDING TO MY LEGEND (with my_plan_id)\n @second_plan = Plan.find_by_my_plan_id(plan_set_two)\n @third_plan = Plan.find_by_my_plan_id(plan_set_three)\n #These above are required to properly render purchase_sub_existing. Not changing below to redirect because the create_customer helper is creating Flash.nows, not Flashs, and this helper also being used in for totally new customers/users\n render 'purchase_sub_existing'\n end \n\n\nend","def create\n @user.account = Account.new if @user.account.nil?\n\n if @user.account.save_with_stripe(params)\n redirect_to user_url(@user), notice: 'Account was successfully created.'\n else\n handle_account_errors(@user, params)\n render :new\n end\n end","def save_with_payment\n if valid?\n @amount = (amount * 100)\n customer = Stripe::Customer.create(description: email, card: stripe_card_token)\n charge = Stripe::Charge.create(\n :customer => customer.id,\n :amount => @amount,\n :description => 'Food bank donation',\n :currency => 'usd'\n )\n self.stripe_customer_token = customer.id\n save!\n end\n rescue Stripe::InvalidRequestError => e\n logger.error \"Stripe error while creating customer: #{e.message}\"\n errors.add :base, \"There was a problem with your credit card.\"\n false\n end","def process_payment_unlimitess\n customer = Stripe::Customer.create email: email, card: token\n update_stripe_customer_id(customer)\n Stripe::Subscription.create customer: customer.id,\n items: [\n {price: 'price_1IndU1Bje2Voz8401SdrQuM0'},\n ]\n\n# customer = Stripe::Customer.create email: email, card: token\n# Stripe::Charge.create customer: customer.id,\n# amount: 10000,\n# description: 'Premium',\n# currency: 'usd'\n end","def charge_user_via_invoice\n customer_id = stripe_user_customer_id\n return unless customer_id.present?\n\n invoice = create_invoice(customer_id)\n create_invoice_items_for_dpc(customer_id, invoice.id)\n resource.identifier.payment_id = invoice.id\n resource.identifier.payment_type = stripe_user_waiver? ? 'waiver' : 'stripe'\n resource.identifier.save\n invoice.send_invoice\n end","def create_stripe_subscription(card_details)\n @error = \"\"\n\t\tbegin\n\t\t\tcustomer = Stripe::Customer.create(\n\t\t\t\t:email => self.email,\n\t\t \t\t## if you are using the js to fetch the stripe_card_token change the ':card => card_details[\"stripe_card_token\"]' ##\n\t\t \t\t:card => {\n\t\t \t\t\t:number => card_details[\"card_number\"],\n\t\t \t\t\t:exp_month => card_details[\"exp_month\"],\n\t\t \t\t\t:exp_year => card_details[\"exp_year\"],\n\t\t \t\t\t:cvc => card_details[\"cvc\"]\n },\n\t\t\t :plan => card_details[\"plan_id\"]\n )\n\n \t\tputs \"==Customer_id : ====#{customer.id}============\"\n puts \"--------------User Model Stripe Customer Object: \" + customer.inspect\n @transaction = Transaction.new( :user_id => self.id,\n :payment_service => \"Stripe\",\n :trans_type => \"CreateStripeCustomer\",\n :stripe_id => customer.id,\n :last4 => customer.cards.data.first['last4'],\n :brand => customer.cards.data.first['brand'],\n :funding => customer.cards.data.first['funding'],\n :exp_month => customer.cards.data.first['exp_month'],\n :exp_year => customer.cards.data.first['exp_year']\n )\n unless @transaction.save\n puts \"-----UserModel - Stripe - Our Transaction Did Not Save on Stripe Fail\"\n end\n\n\t \trescue Stripe::StripeError => e\n logger.warn(\"====#{e.message}==\")\n puts \"====User-Model - Stripe Transaction Failed Due to #{e.message}=====\"\n @error = (\"card error: \" + e.message)\n # Transaction Error Record Created In Controller\n # @transaction = Transaction.new( :user_id => self.id,\n # :payment_service => \"Stripe\",\n # :trans_type => \"Failed\",\n # :stripe_callback_data => @error\n # )\n # unless @transaction.save\n # puts \"-----UserModel - Stripe - Our Transaction Did Not Save on Stripe Fail\"\n # end\n\t\tend\n\t\treturn @error\n\n end","def subscribe!\n Subscription.transaction do\n subscription = create_stripe_subscription!\n store.subscriptions.create!(\n customer: user,\n stripe_plan_id: stripe_plan_id,\n stripe_id: subscription.id,\n first_date: Date.today,\n status: :active\n )\n end\n end","def create_stripe_customer(token)\n Stripe.api_key = 'sk_test_xvxhe0dUKfbGI2MJOWOg1N8j'\n\n begin \n customer = Stripe::Customer.create(\n card: token,\n description: self.email\n )\n\n self.update(stripe_customer_id: customer.id)\n rescue Stripe::CardError => e\n flash[:error] = e.message\n redirect_to sub_request_path\n end\n end","def update_subscription\n success = stripe_call do\n customer = Stripe::Customer.retrieve(@user.stripe_id)\n subscription = customer.subscriptions.retrieve(@user.stripe_subscription_id)\n subscription.source = @params[:stripeToken] if @params[:stripeToken]\n # Update plan if one is provided, otherwise use user's existing plan\n # TODO providing plan_id is untested\n plan_stripe_id = @params[:plan_id] ? Plan.find(@params[:plan_id]).stripe_id : @user.plan.stripe_id\n subscription.items = [{\n id: subscription.items.data[0].id,\n plan: plan_stripe_id\n }]\n subscription.save\n end\n return false unless success\n user_attributes_to_update = {}\n # This is updated by the stripe webhook customer.updated\n # But we can update it here for a faster optimistic 'response'\n assign_card_details(user_attributes_to_update, @params)\n user_attributes_to_update[:plan_id] = @params[:plan_id].to_i if @params[:plan_id]\n @user.update(user_attributes_to_update) if user_attributes_to_update.any?\n return true if success\n end","def create\n customer = Stripe::Customer.create(\n email: current_user.email,\n card: params[:stripeToken]\n )\n # Changes the user role to premium\n charge = Stripe::Charge.create(\n customer: customer.id, \n amount: amount_for_upgrade,\n description: \"Premium Membership! - #{current_user.email}\",\n currency: 'usd'\n )\n\n # @param: customer, the string representation of the customer id\n # @param: amount, an integer represenation of amount \n # @param: description, the string representation of description \n # @param: currency, the string representation of currancy\n\n current_user.update_attribute(:role, 'premium')\n flash[:notice] = \"Thanks for upgrading your account!, #{current_user.email}! \"\n redirect_to wikis_path(current_user) \n\n# Rescue block catches and displays error \n rescue Stripe::CardError => e\n flash[:error] = e.message\n redirect_to new_charge_path\nend","def create\n @user = User.new(user_params)\n respond_to do |format|\n if @user.save and @user.payment == \"paypal\"\n response = EXPRESS_GATEWAY.setup_purchase(@user.calculate_total_in_cents,\n :ip => request.remote_ip,\n :return_url => new_order_url,\n :cancel_return_url => orders_url,\n :currency => \"USD\",\n :description => \"Sms affirmation service - $#{\"%.2f\" % (@user.calculate_total_in_cents / 100 ) }\",\n )\n\n @user.update(:payment_token => response.token)\n redirect_to EXPRESS_GATEWAY.redirect_url_for(response.token) and return\n format.html { redirect_to new_user_path, notice: 'Your SMS Subscription has been activated.' }\n format.json { render action: 'show', status: :created, location: @user }\n else\n @user.terms = false\n\n format.html { render action: 'new' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end","def pay\n Stripe.api_key = Constants::STRIPE_API_SECRET_KEY\n\n # Get the credit card details submitted by the form\n token = params[:stripeToken]\n\n # Create a charge: this will charge the user's card\n begin\n #Keep this as a sample of basic Stripe payment\n # charge = Stripe::Charge.create(\n # :amount => 500, # Amount in cents\n # :currency => \"usd\",\n # :source => token,\n # :description => \"Example charge\",\n # :metadata => {\"order_id\" => \"6735\"}\n # )\n\n #If the current_user has no stripe_customer_id in the DB, that means this is the first time he provide\n #their bank account info, so let's create a Stripe Customer on the cloud to store their bank info for\n #use it later.\n if current_user.stripe_customer_id.blank?\n customer = Stripe::Customer.create(\n card: token,\n description: \"#{current_user.email}-#{current_user.display_name}\",\n email: current_user.email\n )\n customer_id = customer.id\n else\n customer = Stripe::Customer.retrieve(current_user.stripe_customer_id)\n customer_id = current_user.stripe_customer_id\n end\n # Stripe::Charge.create(\n # amount: cart_total_price, # $15.00 this time\n # currency: 'usd',\n # customer: customer_id\n # )\n\n #TODO I know this is ugly but it can define less functions, we can optimize this later\n @card = {card_number: (\"*****#{params[:card_number][-4..-1]}\" rescue nil) || \"*****#{customer[:sources][:data].first[:last4]}\",\n cvv: params[:cvv] || \"\",\n exp_date: \"#{params[:exp_year] || customer[:sources][:data].first[:exp_year]}-\n #{params[:exp_month] || customer[:sources][:data].first[:exp_month]}\",\n card_holder_name: params[:card_holder_name] || \"\"}\n PaymentMailer.payment_success(current_user, @card).deliver_now\n PaymentMailer.send_essay(current_user, session[:cart]).deliver_now\n session[:cart] = nil\n # save the customer ID in your database so you can use it later\n current_user.update_column(\"stripe_customer_id\", customer_id)\n rescue Stripe::CardError => e\n @transaction_falied = true\n # The card has been declined\n PaymentMailer.payment_failed(current_user, @card).deliver_now\n end\n render 'payment_confirmation'\n end","def create\n @subscription = Subscription.new(subscription_params)\n\n @subscription.sub_create(current_user,subscription_params[:stripe_plan_id],subscription_params[:coupon_code])\n\n # Create a subscription with the following information:\n #\n # 1) Customer Account\n # 2) Subscription Type (GOLD, Silver, etc.)\n # 3) Discount Coupom (if applicable)\n\n if @subscription.save\n redirect_to @subscription, notice: 'Subscription was successfully created.'\n else\n @verrors = @subscription.errors.full_messages\n render 'new'\n end\n end","def create_account\n @customer = Customer.find params[:id]\n fail unless @customer.email == params[:customer][:email]\n @customer.update_attributes!(customer_params)\n @customer_session = Authentication::CustomerSession.new(\n email: @customer.email,\n password: customer_params[:password]\n )\n @customer_session.save!\n end","def charge!\n self.class.transaction do\n return if used_comp?\n if subscriber.blank?\n # something happened where the attached user no longer exists....\n # do not do anything, but log it so the admin can decide what to do?\n Freemium.log_subscription_msg(self, \"Subscriber (id: #{subscriber_id}, type: #{subscriber_type}) is no longer found. Deleting this subscription (id: #{self.id}).\")\n self.destroy\n return\n end\n \n if billing_key.blank?\n expire_after_grace! #if self.expires_on.blank? || self.expires_on <= Date.today\n return \n end\n # attempt to bill (use gateway)\n transaction = Freemium.gateway.charge(billing_key, subscription_plan.rate)\n Freemium.log_subscription_msg(self, transaction)\n transaction.success? ? receive_payment!(transaction.amount) : expire_after_grace!\n end\n end","def charge\r\n if paypal?\r\n if (@response = paypal.get_profile_details(billing_id)).success?\r\n next_billing_date = Time.parse(@response.params['next_billing_date'])\r\n if next_billing_date > Time.now.utc\r\n update_attributes(:next_renewal_at => next_billing_date, :state => 'active')\r\n subscription_payments.create(:subscriber => subscriber, :amount => amount) unless amount == 0\r\n true\r\n else\r\n false\r\n end\r\n else\r\n errors.add(:base, @response.message)\r\n false\r\n end\r\n else\r\n if amount == 0 || (@response = gateway.purchase(amount_in_pennies, billing_id)).success?\r\n update_attributes(:next_renewal_at => self.next_renewal_at.advance(:months => self.renewal_period), :state => 'active')\r\n subscription_payments.create(:subscriber => subscriber, :amount => amount, :transaction_id => @response.authorization) unless amount == 0\r\n true\r\n else\r\n errors.add(:base, @response.message)\r\n false\r\n end\r\n end\r\n end","def changesub_existinguser\n @plan = params[:sub][:plan] # this is an integer corresponding to my_plan_id\n @planobject = Plan.find_by_my_plan_id(@plan)\n @events_number = @planobject.events_number \n @code = params[:sub][:code]\n\n if is_valid_sub_coupon(@code) && !@planobject.nil?\n @coupon = Coupon.find_by_name(@code)\n @new_price = @planobject.monthly_cost_cents * (100 - @coupon.percent_off)/100\n flash.now[:success] = \"Your promo code has been applied!\"\n else #could not find that coupon\n @code = nil \n @coupon = nil \n @new_price = nil\n end\n\n if !current_user.customer_id.blank?\n c = Stripe::Customer.retrieve(current_user.customer_id)\n @last4 = c.cards.data.first.last4\n @cardtype = c.cards.data.first.type\n end \n\n render action: 'purchase_sub_existing_choose'\n\nend","def create_stripe_account\n unless stripe_token.present? || Rails.env.test?\n customer = Stripe::Customer.create(description: \"User ID: #{id}\", email: email)\n update_columns(stripe_token: customer.id)\n end\n end","def purchase_sub_new_card\n token = params[:stripeToken]\n @plan = params[:plan] #integer corresponding to my_plan_id\n @events_number = params[:events_number] \n @code = params[:code]\n @new_price = params[:new_price]\n\n if update_card_and_new_subscription(token, @plan, @code)\n c = Stripe::Customer.retrieve(current_user.customer_id)\n \n #create new subscription object in my database\n @sub = Subscription.new(:user_id => current_user.id, :email => current_user.email, :customer_id => c.id, :my_plan_id => @plan, :plan_name => Plan.find_by_my_plan_id(@plan).name, :active => true)\n @sub.events_remaining = @events_number\n @sub.coupon = @code \n @sub.save \n\n #create receipt\n @r = Receipt.new(:user_id => current_user.id, :email => current_user.email, :customer_id => c.id,\n :subscription_id => @sub.id, :sub_my_plan_id => @sub.my_plan_id, :sub_plan_name => @sub.plan_name,\n :sub_events_number => @sub.events_remaining, :sub_reg_monthly_cost_in_cents => Plan.find_by_my_plan_id(@sub.my_plan_id).monthly_cost_cents,\n :sub_actual_monthly_cost_in_cents => @new_price, :sub_coupon_name => @sub.coupon) \n @r.save\n\n #mail receipt\n UserMailer.sub_receipt(current_user, @r).deliver\n\n flash[:success] = \"Thank you for subscribing to the #{Plan.find_by_my_plan_id(@plan).name.titleize} plan!\"\n redirect_to current_user\n\n else\n redirect_to purchase_sub_existing_path\n end \n\n\nend","def subscribe!(params)\n raise Errors::AlreadySubscribedError if subscribed?\n raise Errors::StripeCustomerExistsError if stripe_customer_id\n\n customer = ::Stripe::Customer.create(\n source: params[:stripe_token],\n plan: params[:subscription_plan_id] || SlackRubyBotServer::Stripe.config.subscription_plan_id,\n email: params[:stripe_email],\n metadata: {\n id: id,\n team_id: team_id,\n name: name,\n domain: domain\n }\n )\n\n update_attributes!(\n subscribed: true,\n subscribed_at: Time.now.utc,\n stripe_customer_id: customer['id'],\n subscription_expired_at: nil,\n subscription_past_due_at: nil,\n subscription_past_due_informed_at: nil\n )\n\n customer\n end","def update_card_and_subscription(token, plan) # plan is now a my_plan_id\n \n c = Stripe::Customer.retrieve(current_user.customer_id) #have this in the enveloping controller action as well, because of the 'undefined variable c' error i was getting from the 4000000000000341 card test\n\n #updates customer with new card\n c.card = token\n c.save\n\n #updates subscription plan in stripe \n c.update_subscription(:plan => plan, :prorate => true)\n\n rescue Stripe::InvalidRequestError => e\n logger.error \"Stripe error while creating customer: #{e.message}\"\n flash[:error] = \"There was a problem processing your credit card. #{e.message}. Please try again.\"\n false\n \n rescue Stripe::CardError => e\n logger.error \"Stripe error while creating customer: #{e.message}\"\n flash[:error] = \"There was a problem processing your credit card. #{e.message}. Please try again.\"\n false\n\n rescue Stripe::StripeError => e\n logger.error \"Stripe error while creating customer: #{e.message}\"\n flash[:error] = \"There was a problem processing your credit card. #{e.message}. Please try again.\"\n false\n\n end","def create\n\n # @stripe_account = StripeAccount.new(stripe_account_params)\n # @user = User.find(params[:user_id])\n # @stripe_account.user_id = current_user.id\n\n @user = (current_user || current_affiliate)\n @stripe_account = @user.build_stripe_account(stripe_account_params)\n\n\n\n acct = Stripe::Account.create({\n :country => \"US\",\n :type => \"custom\",\n legal_entity: {\n first_name: stripe_account_params[:first_name].capitalize,\n last_name: stripe_account_params[:last_name].capitalize,\n type: stripe_account_params[:account_type],\n dob: {\n day: stripe_account_params[:dob_day],\n month: stripe_account_params[:dob_month],\n year: stripe_account_params[:dob_year]\n },\n address: {\n line1: stripe_account_params[:address_line1],\n city: stripe_account_params[:address_city],\n state: stripe_account_params[:address_state],\n postal_code: stripe_account_params[:address_postal]\n },\n ssn_last_4: stripe_account_params[:ssn_last_4]\n },\n tos_acceptance: {\n date: Time.now.to_i,\n ip: request.remote_ip\n }\n\n })\n\n @stripe_account.acct_id = acct.id\n # @user.stripe_token = acct.id\n\n\n\n respond_to do |format|\n\n # @user = User.find(params[:id])\n\n if @stripe_account.save!\n # && @user.save\n\n\n\n\n format.html { redirect_to new_bank_account_path, notice: 'Stripe account was successfully created.' }\n format.json { render :show, status: :created, location: @stripe_account }\n\n\n else\n format.html { render :new }\n format.json { render json: @stripe_account.errors, status: :unprocessable_entity }\n end\n end\n end","def save_with_payment discount_code\n if valid?\n customer = Stripe::Customer.create(description: user.name, email: user.email, plan: plan.name.parameterize.underscore, card: stripe_card_token, coupon: discount_code.try(:code))\n user.update_column(:stripe_customer_token, customer.id)\n user.create_discount_code_user(discount_code_id: discount_code.id) unless discount_code.nil?\n save!\n end\n rescue Stripe::InvalidRequestError => e\n logger.error \"Stripe error while creating customer: #{e.message}\"\n errors.add :base, \"There was a problem with your credit card.\"\n false\n end","def pay\n # Find the user to pay.\n captain = User.find( params[:id] )\n\n # Charge amount owed over .971 to account for Stripe fee. This needs to be done here because the fee is being charged to the captain, so he needs to charge his players extra to account for the money being taken out of his take.\n amount = session[:amount_owed]/0.971\n # Calculate the fee amount that goes to the application.\n fee = (amount * Rails.application.secrets.fee_percentage).to_i\n\n begin\n charge_attrs = {\n amount: amount,\n currency: user.currency,\n source: params[:token],\n description: \"Test Charge via Stripe Connect\",\n application_fee: fee,\n destination: captain.stripe_user_id\n }\n\n # case params[:charge_on]\n # when 'connected'\n # p charge_attrs\n # # Use the user-to-be-paid's access token\n # # to make the charge directly on their account\n # charge = Stripe::Charge.create( charge_attrs, user.secret_key )\n # when 'platform'\n # # Use the platform's access token, and specify the\n # # connected account's user id as the destination so that\n # # the charge is transferred to their account.\n # charge_attrs[:destination] = user.stripe_user_id\n charge = Stripe::Charge.create( charge_attrs )\n # end\n\n flash[:notice] = \"Charged successfully! View in dashboard »\"\n\n rescue Stripe::CardError => e\n error = e.json_body[:error][:message]\n flash[:error] = \"Charge failed! #{error}\"\n end\n\n redirect_to session[:saved_url]\n end","def create_subscription(credit_card, options = {})\n\n u = self.user\n options[:order_id] = number # currently just loading a date\n options[:email] = u.email\n options[:address] = {\n :first_name => u.first_name,\n :last_name => u.last_name,\n :address1 => u.street_address1,\n :address2 => (u.street_address2 || \"\"),\n :company => (u.company || \"\"),\n :city => u.city,\n :state => u.us_state,\n :zip => u.zip,\n :country => 'United States',\n :phone => u.primary_phone\n }\n\n subscription = OrderTransaction.generate_yearly_subscription(credit_card, options)\n self.save!\n order_transactions << subscription\n\n if subscription.success?\n self.payment_captured!\n else\n self.transaction_declined!\n end\n\n subscription\n end","def create\n # Amount in cents\n @amount = params[:price].to_i * 100\n \n customer = Stripe::Customer.create(\n :email => params[:stripeEmail],\n :source => params[:stripeToken]\n )\n \n charge = Stripe::Charge.create(\n :customer => customer.id,\n :amount => @amount,\n :description => 'Rails Stripe customer',\n :currency => 'aud'\n )\n \n set_available_to_false(params[:product_id])\n add_user_balance(params[:price])\n redirect_to root_path\n\n rescue Stripe::CardError => e\n flash[:error] = e.message\n redirect_to new_charge_path\n end","def create\n payer_email = params[:payer_email]\n txn_type = params[:txn_type] # subscr_failed, subscr_cancel, subscr_payment, subscr_signup, subscr_eot, subscr_modify\n \n if params[:reason_code] == 'refund'\n # TODO: just notify me that somebody refunded, keep their is_customer flag set to true\n else\n # add/flag customer\n u = User.find_or_create_by_email(payer_email)\n u.first_name = params[:first_name] # overwrite whatever we've got with Paypal's info\n u.last_name = params[:last_name]\n u.password = 'temporary'\n u.is_customer = true\n u.save\n CustomerMailer.deliver_purchase_complete(u) # send them a link\n AdminMailer.deliver_purchase_notification(u) # let me know they were added\n subject = 'Customer added'\n end\n \n render :text => 'OK'\n end","def create\n tpauth = Authentication.find session[:customer_oauth_id]\n if tpauth\n @customer = Customer.new(params[:customer])\n if Customer.count == 0\n # The first customer has administrative privileges.\n @customer.add_roles([:admin])\n end\n @customer.authentications << tpauth\n @customer.save\n session[:customer_id] = @customer.id\n redirect_to edit_customer_registration_path(@customer), :notice => \"Signed In!\"\n else\n redirect_to customer_sign_in_path, \"You need to authenticate first.\"\n end\n end","def create\n sub_id = params[:spree_user][:sub_type].blank? ? \"1\" : params[:spree_user][:sub_type]\n coupon_code = params[:spree_user][:coupon_code]\n @cart = Cart.new\n @user = build_resource(user_params_list)\n\n credit_card_params = params[:spree_user][:creditcards_attributes][\"0\"]\n respond_to do |format|\n format.js do\n if @user.valid?\n billing_address = @user.addresses.last\n result = Creditcard.create_customer_and_creditcard_over_braintree(billing_address, @user.email,credit_card_params)\n @success = result.success? ? true : false\n puts \"i am in user success with params#{@success} and #{billing_address}\"\n\n\n if @success && @user.save\n customer =result.customer\n @credit_card_details = Creditcard.update_creditcard(customer.credit_cards.first, @user.id)\n @user.push_subscription_and_customer_id(sub_id, customer.id)\n @cart.prepare_cart(@user.id, sub_id)\n @user.update_bill_and_ship_address_details\n @user.update_address_type_and_name_fields\n\n #####code for creating new orders#####\n # first order\n plan_price = Subscription.where(id: sub_id).first.plan_price.to_f\n @order_1 = place_order_registration(sub_id, FIRST_DELIVERY_DAYS.days.from_now, @user, @credit_card_details.id, request.remote_ip, plan_price)\n new_token_1 = @order_1.get_unique_ID\n new_token_subscr = Spree::Order.get_unique_subscription_token\n #entry in user subscription\n\n coupon = Coupon.get_briantree_discount_id_and_calculate_final_amount(plan_price, coupon_code)\n\n if coupon.present?\n user_subscription_id = UserSubscription.create_user_subscription(sub_id, @user.id, new_token_subscr, coupon[\"id\"])\n sub_result = Subscription.place_subscription_with_coupon(@order_1.delivery_date, @order_1.subscription_id, @credit_card_details.id, new_token_subscr, coupon)\n @order_1.update_attributes(coupon_id: coupon[\"id\"])\n Coupon.raise_counter(coupon[\"id\"])\n else\n user_subscription_id = UserSubscription.create_user_subscription(sub_id, @user.id, new_token_subscr)\n sub_result = Subscription.place_subscription_without_coupon(@order_1.delivery_date, @order_1.subscription_id, @credit_card_details.id, new_token_subscr)\n end\n\n @order_1.update_attributes(number: new_token_1, user_subscription_id: user_subscription_id, subscription_token: new_token_subscr)\n\n # second order\n @order_2 = place_order_registration(sub_id, SECOND_DELIVERY_DAYS.days.from_now, @user, @credit_card_details.id, plan_price)\n new_token_2 = @order_2.get_unique_ID\n @order_2.update_attributes(number: new_token_2, subscription_token: new_token_subscr, user_subscription_id: user_subscription_id)\n\n # third order\n @order_3 = place_order_registration(sub_id, THIRD_DELIVERY_DAYS.days.from_now, @user, @credit_card_details.id, plan_price)\n new_token_3 = @order_3.get_unique_ID\n @order_3.update_attributes(number: new_token_3, subscription_token: new_token_subscr, user_subscription_id: user_subscription_id)\n\n #creating new line-items-default\n\n create_new_line_items(sub_id,@order_1)\n create_new_line_items(sub_id,@order_2)\n create_new_line_items(sub_id,@order_3)\n\n @order_1.update_total_and_item_total #reupdated total & item_total as its changed by is_pushed = 1 , in push notification method.\n @order_2.update_total_and_item_total\n @order_3.update_total_and_item_total\n ######################################\n\n sign_in(:spree_user, @user)\n session[:spree_user_signup] = true\n #MyMailer.notify_user_after_registration(current_user).deliver\n result = signup_mail_params(@order_1)\n VeganMailer.signup_email(result).deliver\n\n result = vendor_email_params(@order_1)\n VeganMailer.vendor_email(result).deliver\n\n render js: %(window.location.href="https://huggingface.co/spree/orders/snack_queue") and return\n\n else\n @user.destroy\n @user.remove_errormessages_added_by_spree\n @user.errors.add(:creditcards,\"invalid credit card details\")\n end\n else\n \n end\n end\n end\n\n end","def create\n \n @customer = Customer.new(customer_params)\n @user = current_user\n respond_to do |format|\n if @customer.save\n @customer.update!(user_id: @user.id)\n format.html { redirect_to customers_path, notice: 'Customer was successfully created.' }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render :new }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n #create a random key to identify the new customer\n customer_id = Array.new(8/2) { rand(256) }.pack('C*').unpack('H*').first\n\n # The APP_CONFIG value comes from app_config.yml in the Config dir\n @subscription = Subscription.new(params[:subscription])\n\n #maybe this should be in the model?\n @subscription.plan_id = APP_CONFIG[:subscription_token]\n @subscription.customer_id = customer_id\n @subscription.sub_id = \"#{Time.now.strftime(\"%Y%m%d%H%M%s\")}\"\n # First try to create the customer in BrainTree's vault, if successful then save the subscription record.\n # I'd like this process improved to so it's using error handling instead of flash messages\n @result = Braintree::Customer.create(\n :id => customer_id,\n :first_name => params[:subscription][\"billing_first_name\"],\n :last_name => params[:subscription][\"billing_last_name\"],\n :company => params[:subscription][\"billing_company\"],\n :credit_card => {\n :cardholder_name => params[:subscription][\"credit_card_name\"],\n :number => params[:subscription][\"credit_card_number\"],\n :token => @subscription.sub_id,\n :expiration_date => \"#{params[:subscription][\"credit_card_month\"]}/#{params[:subscription][\"credit_card_year\"]}\",\n :cvv => params[:subscription][\"credit_card_cvv_code\"],\n :billing_address => {\n :street_address => params[:subscription][\"billing_address\"],\n :extended_address =>params[:subscription][\"billing_address2\"],\n :locality => params[:subscription][\"billing_city\"],\n :region => params[:subscription][\"billing_state\"],\n :postal_code => params[:subscription][\"billing_zipcode\"],\n :country_code_numeric => params[:subscription][\"billing_country\"]\n }\n }\n )\n if @result.success?\n if create_subscription( @subscription.sub_id, params[:subscription][\"fee\"])\n @merchant = Merchant.find(session[:merchant_id])\n @merchant.update_attributes(:customer_id => customer_id)\n # I removed all the respond_to code, I don't think I'll be using XML formating, shoudl all the respond_do code be removed?\n if @subscription.save\n redirect_to(:controller => 'subscriptions', :action => 'index', :notice => 'Subscription was successfully created.')\n else\n render :action => \"new\"\n end\n else\n render :action => \"new\"\n end\n else\n #was not able to create the customer, display error messages\n render :action => \"new\"\n end\n end","def purchase_events_existing_card\n\n @number = params[:peu][:number]\n coupon = params[:peu][:coupon] # this is the coupon name/code, a string\n cost = params[:peu][:cost] #in cents\n\n # retrieve stripe customer object (downstream from user having a customer_id)\n c = Stripe::Customer.retrieve(current_user.customer_id)\n \n if existing_customer_purchase_events_existing_card(@number, cost, coupon)\n #if the customer had a coupon, update that coupon to be inactive, and attach customer's user id to it\n #if !coupon.blank?\n # redeem_single_use_coupon(coupon)\n #end \n flash[:success] = \"Thank you! You have purchased an additional #{@number} event pages.\"\n redirect_to current_user\n else #errors in processing the card shouldn't usually happen, because the card was originally ok. Can test by using stripes card number that binds to customer but does not charge correctly.\n # YES THE REDIRECT WORKS WITH THAT STRIPE TESTING NUMBER\n redirect_to existing_user_purchase_path\n end \n\n\n \nend","def create\n @return_path = new_subscription_path\n\n redirect_to subscriptions_path and return unless current_plan\n render 'new' and return unless current_user\n\n current_user.update_stripe_card!(params[:stripe_card_token]) unless params[:stripe_card_token].blank?\n current_user.apply_coupon!(current_coupon.id) if current_coupon\n current_user.set_offer_and_subscription_plan!(current_offer, current_plan) if current_offer && current_plan\n\n unless current_user.stripe_subscription_active?\n Rails.logger.debug \"current_user.stripe_subscription_active? is false\"\n render 'new' and return\n end\n\n Resque.enqueue(UpdateMailChimp, current_user.email, :subscriber)\n\n Rails.logger.info \"Subscription updated.\"\n \n clear_subscription_data\n process_new_subscription_analytics\n\n redirect_to subscription_confirm_path\n\n rescue Stripe::StripeError => e\n error = e.json_body[:error]\n\n # this POST happens twice. The first time through, the user hasn't entered any form data and we don't want to show bogus errors.\n unless params[:stripe_customer_id].nil? # first pass through won't include stripe_customer_id as a param\n Rails.logger.error error[:message]\n flash.alert = error[:message]\n end\n \n render 'new'\n\n rescue => e\n Rails.logger.error e.message\n flash.alert = \"M2222\"#e.message\n\n render 'new'\n\n end","def thank_you\n user = session[:user]\n user.zip = params[:zip]\n \n start_date = Date.today\n start_date += 61\n \n response = create_autorrecuring_subscription(start_date, user, params[:card_number], params[:month], params[:year], \n params[:cvc], params[:card_type], params[:city], params[:state],\n params[:billing_address_1], params[:billing_address_2])\n if response.success?\n session[:errors] = nil\n session[:user] = nil\n user.arb_subscription_id = response.subscription_id\n user.arb_status = AuthorizeNet::ARB::Subscription::Status::ACTIVE\n user.billing_information_id = user.add_billing_information(params[:fullname], params[:billing_address_1] ,\n params[:billing_address_2], params[:city], params[:state],\n params[:zip]).id\n user.save\n else\n puts \"Failed to make purchase. \" + response.response_reason_code + \" - \" + response.response_reason_text\n user.errors.clear()\n user.errors.add(:transaction, response.response_reason_text)\n session[:errors] = user.errors\n redirect_to admin_signup_step3_path\n end \n\n \n end","def save_with_stripe(params)\n account_valid = true\n begin\n\n if (account_valid = is_valid(params))\n # Create a stripe customer\n Stripe.api_key = ENV['API_KEY']\n\n customer = Stripe::Customer.create(\n :description => \"#{ACCOUNT_NAME} customer account.\",\n :card => params[:account][:stripe_cc_token],\n :email => params[:cardholder_email]\n )\n\n load_customer_info(customer)\n self.status = ACTIVE\n\n # Attempt to save the record\n account_valid = self.save ? true : false\n end\n\n rescue Stripe::StripeError => stripe_error\n account_valid = stripe_error_handler(stripe_error, INACTIVE)\n end\n\n return account_valid\n end","def new_customer\n @org = Organisation.find_by(permalink: params[:organisation_id])\n @customer = Customer.new\n\n Stripe.api_key = ENV[\"STRIPE_SECRET_KEY\"]\n end","def create_as_stripe_customer(options = {})\n raise Reji::CustomerAlreadyCreatedError.exists(self) if stripe_id?\n\n options[:email] = stripe_email if !options.key?('email') && stripe_email\n\n # Here we will create the customer instance on Stripe and store the ID of the\n # user from Stripe. This ID will correspond with the Stripe user instances\n # and allow us to retrieve users from Stripe later when we need to work.\n customer = Stripe::Customer.create(\n options, stripe_options\n )\n\n update({ stripe_id: customer.id })\n\n customer\n end","def create_customer(customer_data)\n ::Stripe::Customer.create(customer_data)\n end","def purchase_events_new_card\n token = params[:stripeToken]\n @number = params[:number].to_i\n coupon = params[:coupon]\n cost = params[:cost] #in cents\n\n if update_card_and_purchase(token, @number, cost, coupon)\n #if the customer had a coupon, update that coupon to be inactive, and attach customer's user id to it\n # if !coupon.blank?\n # redeem_single_use_coupon(coupon)\n # end \n flash[:success] = \"Thank you! You have purchased an additional #{@number} event pages.\"\n redirect_to current_user\n else\n redirect_to existing_user_purchase_path\n end \nend","def save_and_charge\n # Check our data if it's valid\n if self.valid?\n #If if it's valid, charge\n Stripe::Charge.create(amount: self.total_price, currency: \"USD\", source: self.stripe_token, description: \"Order for #{self.email}\")\n\n self.save\n\n else\n false # Not valid, show error\n end\n\n rescue Stripe::CardError => e\n # This is coming from stripe documentation\n @message = e.json_body[:error][:message]\n\n # Beside validation errors, we can create our own errors\n self.errors.add(:stripe_token, @message)\n\n # Return false to our controller\n false\n\n end","def managed\n connector = StripeManaged.new(current_customer)\n account = connector.create_account!(\n params[:country], params[:tos] == 'on', request.remote_ip\n )\n\n if account\n flash[:notice] = \"Managed StripeAccount account created! View in dashboard »\"\n else\n flash[:alert] = 'Unable to create StripeAccount account!'\n end\n redirect_to customer_path(current_customer)\n end","def pay\n # Find the user to pay.\n user = User.find( params[:id] )\n\n # Charge $10.\n amount = 1000\n # Calculate the fee amount that goes to the application.\n fee = (amount * Rails.application.secrets.fee_percentage).to_i\n\n begin\n charge = Stripe::Charge.create(\n {\n amount: amount,\n currency: user.currency,\n card: params[:token],\n description: \"Test Charge via Stripe Connect\",\n application_fee: fee\n },\n\n # Use the user-to-be-paid's access token\n # to make the charge.\n user.secret_key\n )\n flash[:notice] = \"Charged successfully! View in dashboard »\"\n\n rescue Stripe::CardError => e\n error = e.json_body[:error][:message]\n flash[:error] = \"Charge failed! #{error}\"\n end\n\n redirect_to user_path( user )\n end","def newcustomercreate_trial\n@user = User.new(params[:user]) #replaced code below so when hit this url directly, don't get a nil error\n\n # @user = User.new\n # @user.email = params[:user][:email]\n # @user.password=params[:user][:password]\n # @user.password_confirmation=params[:user][:password_confirmation]\n # @user.first_name = params[:user][:first_name]\n # @user.last_name = params[:user][:last_name]\n # @user.company = params[:user][:company]\n # @user.event_type = params[:user][:event_type]\n #this will pass in the @plan value into the stripenewcustomer_purchase page via the render 'stripenewcustomer_purchase' below (changed this from redirect, wasn't sure that would work)\n\n\n if @user.save\n\n sign_in @user\n # since user is new, won't have any PO with user_id; might have floating PO's with this email for some event, but those would be caught later when customer signs in for those events\n # when creates an event, can invite himself (at that email) to create a PO for that event for himself\n flash[:success] = \"Welcome to VoiceGems! Please contact us with any questions about how to make the most of this service.\"\n \n # render 'stripe_vgtrial' # i think @number defined in this action is being used on the stripenewcustomer_purchase rendering\n # redirect_to welcome_path # a welcome page to explain to them what to do\n create_vg_trial_without_stripe \n redirect_to welcome_path\n else\n\n if User.find_by_email(@user.email)#if the user already exists, tell them to try logging in to the right\n flash[:error] = \"You are already registered on our site. Please sign in to purchase event pages under your Accounts tab.\"\n redirect_to root_path\n else\n render action: 'newcustomer_trial'\n end \n\n end \n\nend","def create\n if user_params[:password_confirmation]\n user = User.create!(user_params)\n\n session[:user_id] = user.id\n session[:expiration_time] = Time.now + 6*60*60 # 6 hours until expiration\n \n response = { message: Message.account_created }\n json_response(response, :created)\n else\n response = { message: Message.password_confirmation_missing}\n json_response(response, :not_acceptable)\n end\n end","def create\n\n\t\t# Get the credit card details submitted by the form\n\t\ttoken = params[:stripeToken]\n\n\t\t# Amount in cents\n\t\t@amount = 500\n\n\t\tcustomer = Stripe::Customer.create(\n\t\t\t:email => 'example@stripe.com',\n\t\t\t:card => params[:stripeToken]\n\t\t)\n\n\t\t# Create the charge on Stripe's servers - this will charge the user's card\n\t\tcharge = Stripe::Charge.create(\n\t\t\t:customer => customer.id,\n\t\t\t:amount => @amount,\n\t\t\t:description => 'Rails Stripe customer',\n\t\t\t:currency => 'usd',\n\t\t\t:card => token\n\t\t)\n\n\trescue Stripe::CardError => e\n\t flash[:error] = e.message\n\t redirect_to charges_path\n\tend","def create\n @credit_card = current_user.credit_cards.new(credit_card_params)\n\n current_user._create_stripe_customer_id\n # We want to retrieve the customer from Stripe\n # Then add the new card to the customer\n begin\n customer = Stripe::Customer.retrieve(current_user.stripe_customer_id)\n card = customer.sources.create(:source => params[:stripeToken])\n rescue Stripe::CardError => e\n # Since it's a decline, Stripe::CardError will be caught\n body = e.json_body\n err = body[:error][:message]\n redirect_to :back, notice: \"#{err}\"\n else\n customer.default_source = card.id\n customer.save\n @credit_card.stripe_card_id = card.id\n @credit_card.last_four = card.last4\n\n if @credit_card.save\n unless session[:pending_session_counselor_id].present?\n redirect_to user_dashboard_path, notice: 'Credit card was successfully created.'\n else\n redirect_to new_counseling_session_path, notice: 'You are almost done. Now you can finalize your session.'\n end\n else\n render :new\n end\n end\n end","def create(params)\n If(Hr.find(params[:user_id])) do |hr|\n customer = Stripe::Customer.create(source: params[:stripe][:token])\n hr.update_attribute(:stripe_id, customer.id)\n hr.update_attribute(:last_four_digits, customer.sources.data.first.last4)\n end\n end","def new_customer_registration(user, token)\n @current_user = user\n @token = token\n mail(to: user[:email], subject: 'Registration Successful – Please Verify Your Email Address')\n end","def purchase_events_existing_card_couple\n\n @number = params[:peu][:number]\n coupon = params[:peu][:coupon] # this is the coupon name/code, a string\n cost = params[:peu][:cost]\n\n # retrieve stripe customer object (downstream from user having a customer_id)\n c = Stripe::Customer.retrieve(current_user.customer_id)\n \n if existing_customer_purchase_events_existing_card(@number, cost, coupon)\n #if the customer had a coupon, update that coupon to be inactive, and attach customer's user id to it\n #if !coupon.blank?\n # redeem_single_use_coupon(coupon)\n #end \n flash[:success] = \"Thank you! You have purchased #{@number} VoiceGems pages.\"\n redirect_to current_user\n else #errors in processing the card shouldn't usually happen, because the card was originally ok. Can test by using stripes card number that binds to customer but does not charge correctly.\n # YES THE REDIRECT WORKS WITH THAT STRIPE TESTING NUMBER\n redirect_to existing_couple_purchase_select_path({:peu => {:number => @number }, :coupon => coupon})\n end \n\nend","def create_charge\n customer = Stripe::Customer.create(\n :email => params[:stripeEmail],\n :card => params[:stripeToken]\n )\n\n charge = Stripe::Charge.create(\n :customer => customer.id,\n :amount => Deal.find(current_consumer.orders.last[:deal_id]).price.to_i * 100,\n :description => 'Prlayvous Ticket',\n :currency => 'usd'\n )\n\n #After paying with Stripe, consumers are prompt to confirm their shipping address.\n redirect_to edit_consumer_order_path(current_consumer, @order)\n\n rescue Stripe::CardError => e\n flash[:error] = e.message\n redirect_to charges_path\n end","def activate\n \n # Subscription vitals\n customer_ref = params[:SubscriptionReferrer]\n plan_ref = params[:ProductPath].sub(\"/\", \"\")\n subscription_ref = params[:SubscriptionReference]\n \n # subscription info\n status = params[:SubscriptionStatus].to_s.downcase.strip\n end_date = params[:SubscriptionEndDate]\n next_period_date = params[:SubscriptionNextPeriodDate]\n status_reason = params[:SubscriptionStatusReason]\n total_price = params[:SubscriptionTotalPriceValue]\n \n user = User.find(customer_ref)\n plan = Plan.find_by_fastspring_reference(plan_ref)\n \n raise \"Received subscription activation but the subscription status is not 'active', but is rather: '#{status}'\" unless status == \"active\"\n raise \"Received subscription activation for #{user.id} but couldn't find a matching plan: #{plan_ref}\" unless plan\n raise \"Received subscription activation for #{user.id} but they already have an active subscription with reference #{user.active_subscription.reference}\" if user.subscribed?\n\n Subscription.create!(\n user: user,\n reference: subscription_ref,\n end_date: end_date,\n next_period_date: next_period_date,\n status: status,\n status_reason: status_reason,\n total_price: total_price,\n currency: params[:SubscriptionTotalPriceCurrency]\n )\n user.plan = plan\n user.save!\n\n render nothing: true, status: 200\n end","def create\n #to avoid unwanted/unsafe requests we replace params[:user]\n @user = User.new(user_params)\n if @user.save\n # =WANT THEM TO ACTIVATE ACCOUNT FIRST\n @user.send_activation_email\n flash[:info] = \"Please check your email to activate your account.\"\n redirect_to root_url\n #logs in a user after they make account\n # log_in(@user)\n # flash[:success] = \"Welcome to Twitter Clone!\"\n #redirect_to @user\n else\n render 'new'\n end\n end","def create\n @customer = User.new(customer_params)\n @customer.authority = 'customer'\n respond_to do |format|\n if @customer.save\n if !current_user\n log_in @customer, :customer\n end\n format.html {redirect_to customer_path(@customer), notice: 'Customer was successfully created.'}\n format.json {render :show, status: :created, location: @customer}\n else\n format.html {render :new}\n format.json {render json: @customer.errors, status: :unprocessable_entity}\n end\n end\n end","def stripe_customer_subscription_created(event, req)\n stripe_customer_subscription_updated(event, req)\n end","def create\n\n @charge = Charge.new(charge_params)\n \n customer = StripeTool.create_customer(email: params[:stripeEmail], \n stripe_token: params[:stripeToken])\n\n charge = StripeTool.create_charge(customer_id: customer.id, \n amount: (@charge.amount*100).to_i,\n description: @charge.topic)\n\n @charge.stripe_id = customer.id\n \n\n respond_to do |format|\n if @charge.save\n if @charge.owner_type == \"User\"\n format.html { redirect_to user_path(:id => @charge.owner_id, :topic => \"personen_charges\"), notice: (I18n.t :thxpayment) }\n end\n if @charge.owner_type == \"Company\"\n format.html { redirect_to company_path(:id => @charge.owner_id, :topic => \"institutionen_charges\"), notice: 'Charge was successfully created.' }\n end\n format.json { render :show, status: :created, location: @charge }\n else\n format.html { render :new }\n format.json { render json: @charge.errors, status: :unprocessable_entity }\n end\n end\n\n rescue Stripe::CardError => e\n flash[:error] = e.message\n redirect_to user_path(:id => @charge.owner_id, :topic => \"personen_charges\"), notice: (:I18n.t :nopayment)\n \n end","def purchase_events_new_card_couple\n token = params[:stripeToken]\n @number = params[:number].to_i\n coupon = params[:coupon]\n cost = params[:cost]\n\n if update_card_and_purchase(token, @number, cost, coupon)\n #if the customer had a coupon, update that coupon to be inactive, and attach customer's user id to it\n # if !coupon.blank?\n # redeem_single_use_coupon(coupon)\n # end \n flash[:success] = \"Thank you! You have purchased #{@number} VoiceGems Pages.\"\n redirect_to current_user\n else\n redirect_to existing_couple_purchase_select_path({:peu => {:number => @number }, :coupon => coupon})\n end \nend","def create_user_account\n User.create!(email: self.email, password: self.customer)\n # user = User.new do |u|\n # u.email = email\n # u.password = customer\n # u.save\n # end\n end","def post_billing(req)\n with_stripe_error_handlers do\n customer = Stripe::Customer.retrieve(@dealership.customer_id)\n customer.card = posted['stripeToken']\n customer.save\n req.session['billing_flash_msg'] = \"Card updated successfully.\"\n redirect \"/admin/#{@dealership.slug}/billing\"\n end\n end","def pay\n @card = Creditcard.new(creditcard_params)\n\n user = current_user\n\n if @card.valid?\n result = Creditcard.create_only_creditcard_over_braintree(user.braintree_customer_id, @card)\n @braintree_cc_return = result.success? ? result.credit_card : nil\n end\n\n\n if @braintree_cc_return.present?\n @card.save\n @card.update_attributes(user_id: user.id)\n @card = Creditcard.update_creditcard(@braintree_cc_return, user.id)\n end\n\n end","def create\n if params[:type] == StripePaymentGatewayProfile::Events::SUBSCRIPTION_UPDATED\n\n # hackity mchacks a lot. use a singleton? hmm.\n event = StripePaymentGatewayProfile.new.webhook_event_with_stripe_key(AppConfiguration.get('stripe.secret_key'), params[:id])\n\n if event\n\n subscription = event.data.values[0]\n previous_values = event.data.values[1]\n if event.type == StripePaymentGatewayProfile::Events::SUBSCRIPTION_UPDATED\n profile = StripePaymentGatewayProfile.by_vendor_id(subscription['customer']).first\n if profile && profile.subscribable?\n profile.reload_remote\n if !previous_values['status'].blank? && previous_values['status'] != subscription['status'] && !profile.active_plan?\n profile.payment_gateway_profilable.notify_inactive!\n end\n else\n # Found event, but not the customer record. dismiss the event,\n # but remember in our system that we messed up.\n DetectedError.create(\"Received webhook for customer that we didn't handle: #{subscription.customer}\")\n end\n end\n\n head :ok\n else\n # not existent event\n head :not_found\n end\n else\n\n # this is a trade off. on the one hand, lets attackers identify this end and DOS us. on the other hand,\n # we don't recognize this hook...we don't care.\n # todo: build this stripe key retrieval into the mfe.\n head :ok\n\n end\n end","def handle_unpaid_customer(customer_subscription)\n\t\tsubscription = Subscription.find_by_stripe_customer_token(customer_subscription.customer)\n\t\tsubscription.status = false\n\t\tsubscription.status_info = customer_subscription.status\n\t\tsubscription.save!\n\n\t\tuser = subscription.user\n\t\tNotifyMailer.delay.account_expired(user)\n\t\tNotifyMailer.delay.update_grapevine_team(user, \"User has been set to UNPAID status\")\n\tend","def create\n @user = User.find_by_email_and_activated(params[:user][:email], false) # We can only register a user that hasn't been activated yet.\n \n if @user\n # Cases 2 and 3.\n params[:user].delete(:email) # They can't arbitrarily change their email address.\n @user.update_attributes(params[:user])\n else\n # Case 1.\n @user = User.new(params[:user].merge({:perishable_token => \"\"}))\n @user.reset_perishable_token!\n end\n \n # This is true when a user finishes their registration from a link in their email (Case 3),\n # which means we don't need to send an activation link.\n if params[:token] && User.find_using_perishable_token(params[:token], 0) == @user\n activate\n else\n # Cases 1 and 2. \n # Saving without session maintenance to skip\n # auto-login which can't happen here because\n # the user has not yet been activated\n if @user.save_without_session_maintenance\n @user.deliver_activation_instructions\n flash[:notice] = 'Registration successful. Please check your email to activate your account.'\n redirect_to shares_path\n else\n flash[:error] = 'Registration failed. Please try again.'\n redirect_to root_path\n end\n end\n end","def create\n super do |resource| #super means inherit the 'create' action, but then extend it\n if params[:plan]\n #is there a parameter called param?\n resource.plan_id = params[:plan] #resource means user in this case. So take whatever is in the form and set this users plan to be that plan id\n if(resource.plan_id == 2) #so if the form is coming from the pro form, then don't just save the user. We also wanyt to keep the plan id. run the function that we create called save_with_subscription\n resource.save_with_subscription #write a user created function in the model. So in this case models/user.rb\n #the save is done in the model.\n else\n #otherwise just save as normal devise save\n resource.save\n end\n end\n end\n end","def create\n @registration = Registration.new(registration_params)\n\n # Amount in cents\n @amount = @registration.subtype == 'team' ? 9000 : 5000\n\n # Disabled for now,\n # customer = Stripe::Customer.create(\n # :email => params[:stripeEmail],\n # :source => params[:stripeToken]\n # )\n #\n # charge = Stripe::Charge.create(\n # :customer => customer.id,\n # :amount => @amount,\n # :description => 'EnergyX Resolve To Row',\n # :currency => 'usd'\n # )\n #\n # @registration.is_paid = true if customer && charge\n # @registration.stripe_customer_id = customer.id\n # @registration.stripe_charge_id = charge.id\n\n respond_to do |format|\n if @registration.save\n format.html { redirect_to @registration, notice: 'We have successfully created your registration! You card HAS NOT BEEN CHARGED. Please Print this page for your records.' }\n format.json { render :show, status: :created, location: @registration }\n else\n format.html { render :new }\n format.json { render json: @registration.errors, status: :unprocessable_entity }\n end\n end\n\n rescue Stripe::CardError => e\n flash[:error] = e.message\n redirect_to new_registration_path(@registration)\n end","def create\n @purchase = Purchase.new purchase_attributes\n if @purchase.save\n @ok = true\n renewed = Purchase.find_by_id params[:renewed_id]\n if renewed\n renewed.users.each do |u|\n u.purchase_id = @purchase.id\n u.save\n Notification.send_to(\n u.id,\n I18n.t('notifications.account.renewed.title'),\n I18n.t('notifications.account.renewed.message', :expiration_date => TimeConvert.to_string(@purchase.expiration_date)),\n ''\n )\n end\n renewed.expiration_date = Time.zone.now\n renewed.save\n end\n else\n @ok = false\n @errors = @purchase.errors.messages.keys\n @errors << :ssn_code if @errors.include?(:base)\n end\n end","def change_subscription\n\tbounce_free_account\n\n\t@subs = current_user.subscriptions \n\tif @subs && !@subs.active.blank?\n\t@s = @subs.active.first\n\t@s_year = @s.created_at + 365.days\n\t#@c = Stripe::Customer.retrieve(@s.customer_id)\n\telse #this should not happen - be careful to make sure every customer has a subscription; or at least if they have a \n\t\t# cancel subsciption link, there is an active subscription to be canceled. \n\tredirect_to current_user, notice: 'You have no active subscriptions.'\n\t # return false is this line needed to end the action?\n\tend \n\n\t# users first (oldest) subscription, for displaying free trial information\n\t@firstsub = @subs.first\n\t@firstsub_end = @firstsub.created_at + 14.days\n\n\t#@plan = Plan.find_by_name(@s.plan_id) #this would be better for easily retrieving other associated plan info; but could have just used @s.plan_id for the plan name\n\tif !@s.my_plan_id.nil? # so that @plan isn't nil, which would cause problems in the view \n\t@plan = Plan.find_by_my_plan_id(@s.my_plan_id) # NOTE THAT @PLAN IS THE PLANOBJECT\n\t\t\t\t#see if active subscription has a coupon associated with it\n\t\t\t\tif !@s.coupon.nil? && Coupon.find_by_name(@s.coupon)\n\t\t\t\t\t@coupon = Coupon.find_by_name(@s.coupon)\n\t\t\t\t\t@code = @coupon.name\n\t\t\t\t\t@new_price = @plan.monthly_cost_cents * (100 - @coupon.percent_off)/100\n\t\t\t\telse\n\t\t\t\t\t@coupon = nil \n\t\t\t\t\t@code = nil\n\t\t\t\t\t@new_price = nil \n\t\t\t\tend \n\telse\n\t\t@plan = nil\n\t\t@coupon = nil \n\t\t@code = nil \n\t @new_price = nil \n\tend \n\nend","def create\n\t\t#Prepare the models\n\t\t@subscription = Subscription.new(\n\t\t\tcampaign_id: @subscribed.active_campaign.id,\n\t\t\tshipping_country: params[:subscription][:shipping_country],\n\t\t\tget_reward: params[:subscription][:get_reward],\n\t\t\tfunding_type: params[:subscription][:funding_type],\n\t\t\tamount: params[:subscription][:amount],\n\t\t\tsubscriber_id: @subscriber.id,\n\t\t\tsubscribed_id: @subscribed.id,\n\t\t\tcurrency: 'usd',\n\t\t\tcampaign_funding_type: @subscribed.active_campaign.funding_type\n\t\t)\n\t\tif params[:subscription][:majorpost_id]\n\t\t\t@subscription.majorpost_id = params[:subscription][:majorpost_id]\n\t\tend\n\t\tif params[:subscription][:upper_limit]\n\t\t\t@subscription.upper_limit = params[:subscription][:upper_limit]\n\t\tend\n\t\tif params[:subscription][:cards_attributes]\n\t\t\tadd_card\n\t\tend\n\t\t#Charge if charge\n\t\tif @subscription.funding_type == 'one_time'\n\t\t\t#Charge the card now\n\t\t\tsubscribe_through_stripe\n\t\telse\n\t\t\t#Do not charge the card\n\t\t\tsubscription_post_payment\n\t\tend\n\trescue Stripe::CardError => e\n\t\t# Since it's a decline, Stripe::CardError will be caught\n\t\tbody = e.json_body\n\t\terr = body[:error]\n\n\t\tputs \"Status is: #{e.http_status}\"\n\t\tputs \"Type is: #{err[:type]}\"\n\t\tputs \"Code is: #{err[:code]}\"\n\t\t# param is '' in this case\n\t\tputs \"Param is: #{err[:param]}\"\n\t\tputs \"Message is: #{err[:message]}\"\n\t\t#Show to the user\n\t\tflash[:error] = \"#{err[:message]}\"\n\t\tredirect_to how_i_pay_user_studio_wallets_path(@subscriber.username)\n\trescue Stripe::RateLimitError => e\n\t\t# Too many requests made to the API too quickly\n\t\tflash[:error] = t('errors.messages.too_many_requests')\n\t\tredirect_to profile_url_path(@subscribed.username)\n\trescue Stripe::InvalidRequestError => e\n\t\t# Invalid parameters were supplied to Stripe's API\n\t\tflash[:error] = t('errors.messages.not_saved')\n\t\tredirect_to profile_url_path(@subscribed.username)\n\trescue Stripe::AuthenticationError => e\n\t\t# Authentication with Stripe's API failed\n\t\t# (maybe you changed API keys recently)\n\t\tflash[:error] = t('errors.messages.not_saved')\n\t\tredirect_to profile_url_path(@subscribed.username)\n\trescue Stripe::APIConnectionError => e\n\t\t# Network communication with Stripe failed\n\t\tflash[:error] = t('errors.messages.not_saved')\n\t\tredirect_to profile_url_path(@subscribed.username)\n\trescue Stripe::StripeError => e\n\t\t# Display a very generic error to the user, and maybe send\n\t\t# yourself an email\n\t\tflash[:error] = t('errors.messages.not_saved')\n\t\tredirect_to profile_url_path(@subscribed.username)\n\trescue \n\t\t# General rescue\n\t\tflash[:error] = t('errors.messages.not_saved')\n\t\tredirect_to profile_url_path(@subscribed.username)\n\tend","def create\n @cart = Cart.find(params[:cart_id].to_i)\n token = params[:stripeToken]\n #payment old changes\n # if @cart.instant_total_price_cents != 0\n # begin\n # puts \"Processing payment\"\n # if params[:payment_method].blank? or params[:payment_method] == \"card\"\n # sub = Subscription.find_by(user_id: current_user.id, stripe_customer_token: token)\n # if sub.nil?\n # last4 = params[:last4]\n # exp_year = params[:exp_year]\n # exp_month = params[:exp_month]\n # subscription = Subscription.new(stripe_customer_token: token, user_id: current_user.id,last4: last4,exp_year: exp_year,exp_month: exp_month)\n # new_sub = Order.save_with_payment(params[:email],token,current_user.name,@cart.instant_total_price_cents)\n # subscription.stripe_user_id = new_sub\n # subscription.save\n # else\n # Order.payment_only(current_user.name,@cart.instant_total_price_cents,sub.stripe_user_id)\n # end\n # else\n # account = current_user.bank_accounts.first\n # if account.stripe_user_id.nil?\n # account.stripe_user_id = Order.save_with_payment(params[:email],account.stripe_customer_token,current_user.name,@cart.instant_total_price_cents)\n # account.save\n # else\n # Order.payment_only(current_user.name,@cart.instant_total_price_cents,account.stripe_user_id)\n # end\n # end\n # rescue => e\n # puts \"Payment failed\"\n # puts e\n # ExceptionNotifier.notify_exception e\n # render json: {\"error\":\"Payment was unsuccessful\"}, status: :unprocessable_entity and return\n # end\n # end\n\n address_type = params[:address_type].nil? ? \"user\" : params[:address_type]\n if params[:old_address_id].blank?\n current_user.addresses.create!(first_name: params[:first_name], last_name: params[:last_name], mobile: params[:mobile], line_1: params[:line_1], line_2: params[:line_2], line_3: params[:line_3], city: params[:city], state: params[:state], address_type: address_type, pincode: params[:pincode].to_i, name: \"shipping\")\n else\n puts \"Address found. Updating it\"\n address = Address.find params[:old_address_id]\n address.updated_at = DateTime.now\n address.save\n end\n\n CartItem.where(cart: @cart).group_by(&:provider).each do |provider,cart_items_all|\n cart_items_instant = cart_items_all.select {|ci| ci.product.storefront_option == true}\n cart_items_invoice = cart_items_all.select {|ci| ci.product.storefront_option == false}\n [cart_items_instant,cart_items_invoice].each do |cart_items|\n if cart_items.length > 0\n @order = Order.new\n @order.first_name = params[:first_name]\n @order.last_name = params[:last_name]\n @order.mobile_number = params[:mobile_number]\n @order.email = params[:email]\n @order.order_date = DateTime.now\n @order.total_price_cents = 0\n @order.user = current_user\n @order.save!\n # if cart_items.first.product.storefront_option\n # @order.status = :unpaid\n # @order.save!\n # end\n\n cart_items.each do |cart_item|\n @order.total_price_cents += cart_item.price_cents * cart_item.quantity\n order_item = @order.order_items.new(price_cents: cart_item.price_cents, product: cart_item.product, quantity: cart_item.quantity,provider: cart_item.provider)\n cart_item.destroy\n end\n\n @order.recalcuate_order_total\n @order.addresses.create!(first_name: params[:first_name], last_name: params[:last_name], mobile: params[:mobile], line_1: params[:line_1], line_2: params[:line_2], line_3: params[:line_3], city: params[:city], state: params[:state], address_type: address_type, pincode: params[:pincode].to_i, name: \"shipping\")\n SupplierMailer.order_email(@order).deliver_later\n end\n end\n end\n\n respond_to do |format|\n format.html { render json: @order.id, status: :ok }\n format.json { render json: @order.id, status: :ok}\n end\n end"],"string":"[\n \"def save_with_subscription\\n #If user data passes validations, then call Stripe with user information\\n #to get a new subscription created upon charging their card\\n if valid?\\n customer = Stripe::Customer.create(description: email, plan: plan_id, card: stripe_card_token)\\n self.stripe_customer_token = customer.id\\n save!\\n end\\n end\",\n \"def save_with_subscription\\n if valid?\\n customer = Stripe::Customer.create(description: email, card: stripe_card_token)\\n self.stripe_customer_token = customer.id\\n save! \\n end\\n end\",\n \"def create_subscription\\n subscription = nil\\n stripe_call do\\n local_plan = Plan.active.find(@params[:user][:plan_id])\\n return false if local_plan.nil?\\n stripe_plan = Stripe::Plan.retrieve(local_plan.stripe_id)\\n # If the plan has a trial time, it does not need a stripe token to create a subscription\\n # We assume you have a trial time > 0. Otherwise there will be 2 customers created for\\n # each subscribed customer. One at registration and another when subscribing.\\n subscription = customer.subscriptions.create(\\n source: @params[:stripeToken],\\n plan: stripe_plan.id\\n )\\n end\\n return false if subscription.nil?\\n\\n user_attributes_to_update = {\\n stripe_id: customer.id,\\n stripe_subscription_id: subscription.id\\n }\\n assign_card_details(user_attributes_to_update, @params)\\n @user.update(user_attributes_to_update)\\n end\",\n \"def save_with_subscription\\n if valid?\\n customer = Stripe::Customer.create(description: email, plan: plan_id, card: stripe_card_token)\\n # save customer id in DB with response\\n self.stripe_customer_token = customer.id \\n # runs save\\n save!\\n end\\n end\",\n \"def subscribe\\n # Find the user to pay.\\n user = User.find( params[:id] )\\n\\n # Calculate the fee percentage that applies to\\n # all invoices for this subscription.\\n fee_percent = (Rails.application.secrets.fee_percentage * 100).to_i\\n begin\\n if user.stripe_customer_id\\n customer = Stripe::Customer.retrieve(user.stripe_customer_id)\\n customer.coupon = 'ahip200off'\\n customer.save\\n\\n customer.subscriptions.create({:plan => params[:plan]})\\n #customer.application_fee_percent = fee_percent\\n # customer.save\\n else\\n # Create a customer and subscribe them to a plan\\n # in one shot.\\n # Normally after this you would store customer.id\\n # in your database so that you can keep track of\\n # the subscription status/etc. Here we're just\\n # fire-and-forgetting it.\\n customer = Stripe::Customer.create(\\n {\\n card: params[:token],\\n email: current_user.email,\\n plan: params[:plan],\\n application_fee_percent: fee_percent,\\n metadata: {name: user.name},\\n # coupon: 'ahip200off',\\n },\\n user.secret_key\\n )\\n user.stripe_customer_id = customer.id\\n user.save!\\n\\n end\\n flash[:notice] = \\\"Subscribed! View in dashboard »\\\"\\n\\n rescue Stripe::CardError => e\\n error = e.json_body[:error][:message]\\n flash[:error] = \\\"Charge failed! #{error}\\\"\\n end\\n\\n redirect_to user_path( user )\\n end\",\n \"def save_withsubscription\\n if valid?\\n customer = Stripe::Customer.create(description: email, plan: plan_id, card: stripe_card_token)\\n self.stripe_card_token = customer.id\\n save!\\n end\\n end\",\n \"def create\\n customer = Stripe::Customer.create({\\n :description => current_user.id,\\n :email => current_user.email,\\n :card => params[:stripeToken],\\n })\\n\\n current_user.stripe_id = customer.id\\n current_user.save!\\n\\n Stripe::Charge.create(\\n :customer => current_user.stripe_id,\\n :amount => 250,\\n :description => 'Fantasy Rocket Monthly Subscription',\\n :currency => 'usd',\\n )\\n\\n current_user.create_subscription!\\n redirect_to params[:redirect_to] || root_url, notice: \\\"Thanks! You're now subscribed.\\\"\\n rescue Stripe::CardError => e\\n redirect_to new_subscriptions_url, alert: e.message\\n end\",\n \"def save_with_payment\\n # if valid (ruby)\\n if valid?\\n # create a variable that stores all of the values from the form as well as a new stripe_card_token that will be returned from stripe\\n customer = Stripe::Customer.create(description: email, plan: plan_id, card: stripe_card_token)\\n # set a variable that is equal to the id attribute of the customer object that was created above\\n # save all of this to the User database\\n # needed to run a migration to add AddStripeCustomerTokenToUsers column to User database\\n self.stripe_customer_token = customer.id # User.stripe_customer_token = ....\\n save!\\n end\\n end\",\n \"def save_with_payment\\n if valid? # We did added some validation to make sure user filled in properly ::contact.rb\\n # After Stripe get this info, Stripe will do the charging, this method comes from Stripe gem\\n # Stripe will return an id after charging\\n customer = Stripe::Customer.create(description: email, plan: plan_id, source: stripe_card_token) # Stripe had upgrade their API from card: -> source:\\n # Set a property to the user after received the id Stripe returned(stripe will return customer hash)\\n # 'self' means the target of this function, in this case is User, and we set a new atribute stripe_customer_token to User. \\n self.stripe_customer_token = customer.id # Setting stripe_customer_token to Stripe::customer.id \\n save!\\n end\\n \\n end\",\n \"def update_stripe\\n Stripe.api_key = \\\"sk_test_fVKfBEBDcWPZl5mLFk44KBJX\\\"\\n \\n # create the charge on Stripe's servers - this will charge the user's card\\n if customer = Stripe::Customer.create(\\n :card => stripe_token,\\n :plan => \\\"basic_plan\\\",\\n :description => email\\n )\\n \\n User.update(user_id, :status => 'paid', :stripe_customer_id => customer.id)\\n end\\n end\",\n \"def create\\n @user = User.new(params[:user])\\n @user.customer = Customer.new(params[:user][:customer_attributes])\\n @user.origin = Origin.find_by_code(cookies[:origin]) if (cookies[:origin] and !Origin.find_by_code(cookies[:origin]).nil?)\\n @user.partner_id = partner\\n @quietly_create = params[:quietly_create] || false\\n \\n if User.exists?(:email => @user.email)\\n flash[:error] = \\\"This email is already registered with WTD.
Forgot your password? You can reset your password here.\\\"\\n redirect_to login_path and return\\n end\\n \\n # setup promo code from params\\n if !params[:referral_code].blank? and PromotionCode.exists?(:code => params[:referral_code])\\n @promotion_code = PromotionCode.find_by_code(params[:referral_code])\\n elsif !session[:stored_promotion_code_id].blank? and PromotionCode.find(session[:stored_promotion_code_id])\\n @promotion_code = PromotionCode.find(session[:stored_promotion_code_id])\\n else\\n @promotion_code = nil\\n end\\n\\n # quiet create extras\\n if @quietly_create\\n # @user.email_confirmation = @user.email if @user.email_confirmation.blank?\\n @user.password = @user.temporary_password\\n @user.password_confirmation = @user.password\\n @user.quietly_created = true\\n @user.customer.quietly_created = true\\n end\\n\\n # add survey question if present\\n session[:survey_question_value] = params[:survey_question_value] unless params[:survey_question_value].blank?\\n \\n # update subscriptions and tracking analytics\\n if @user.update_subscriptions(request.referrer, nil, true)\\n session[:new_subscriber] = true\\n session[:new_subscriber_email] = @user.email\\n end\\n \\n \\n # check promo code and attempt to save user\\n if !@promotion_code.nil? and !@promotion_code.redeemable?\\n flash[:error] = 'Sorry, but that promo code is not redeemable!'\\n render :action => 'new'\\n elsif @user.save \\n flash[:notice] = \\\"Success! You're officially part of the WTD family.\\\" unless @quietly_create\\n \\n # trigger analytics to track\\n session[:new_user] = true\\n session[:new_subscriber_user_id] = @user.id\\n\\n # check referrals and credits\\n unless @promotion_code.nil?\\n unless @promotion_code.bad_referral?(@user.id)\\n @credit = Credit.new\\n @credit.promotion_code_id = @promotion_code.id\\n @credit.value = @promotion_code.value\\n @credit.user_id = @user.id\\n @credit.referrer_user_id = @promotion_code.user_id\\n @credit.save\\n else\\n flash[:error] = \\\"Sorry, but there seems to be something wrong with your referral. Please check back in an hour or email us at support@sowhatsthedeal.com.\\\"\\n end\\n end\\n \\n flash[:notice] = params[:flash_notice] || \\\"Welcome, you are now officially part of the WTD family!\\\"\\n flash[:notice] += \\\"
Please choose a password to complete your WTD account.\\\" if @user.quietly_created?\\n flash[:notice] = \\\"Thanks for signing up for Half Price DC\\\" if partner == 3\\n redirect_to session[:return_to] ? session[:return_to] : my_account_path\\n else\\n @user.password = \\\"\\\"\\n @user.password_confirmation = \\\"\\\"\\n flash[:error] = \\\"Be sure to include your first name, last name and a valid email address.
Remember, If you subscribed to our newsletter, you already have an account. Forgot your password? You can reset your password here.\\\" if @user.errors.empty?\\n session[:return_to] ? redirect_to(session[:return_to]) : render(:action => 'new')\\n end\\n end\",\n \"def create\\n customer = StripeTool.create_customer(email: params[:stripeEmail], stripe_token: params[:stripeToken])\\n\\n\\tcharge = StripeTool.create_charge(customer_id: customer.id, amount: @amount, description: @description)\\n\\n current_user.stripe_id = customer.id\\n\\n\\treceipt = Charge.new charge_stripe_token: charge.id, price: @amount, description: @description)\\n\\n\\tif Charge.save\\n\\n\\telse\\n\\n\\tend\",\n \"def create_stripe_customer_and_subscription(user)\\n begin\\n s_customer = Stripe::Customer.create(description: user.first_name, card: self.stripe_card_token, email: user.email)\\n stripe_customer = StripeCustomer.create(object: s_customer.object, description: s_customer.description, livemode: s_customer.livemode, created_timestamp: s_customer.created, reference_id: s_customer.id, user_id: self.user_id)\\n customer = Stripe::Customer.retrieve(stripe_customer.reference_id)\\n \\n if user.plan_name == \\\"school_closing_date\\\" && user.plan == \\\"daily\\\"\\n stripe_charge = Stripe::Charge.create(amount: stripe_charge_amount(user), currency: \\\"usd\\\", customer: s_customer.id, description: \\\"school_closing daily\\\")\\n user.stripe_charges.create(amount: stripe_charge_amount(user), currency: \\\"usd\\\", description: \\\"test\\\", stripe_customer_id: stripe_customer.id)\\n elsif user.plan_name == \\\"school_closing_date\\\" && user.plan == \\\"all_days\\\"\\n stripe_charge = Stripe::Charge.create(amount: stripe_all_dates, currency: \\\"usd\\\", customer: s_customer.id, description: \\\"school_closing all days\\\")\\n user.stripe_charges.create(amount: stripe_all_dates, currency: \\\"usd\\\", description: \\\"test\\\", stripe_customer_id: stripe_customer.id)\\n elsif user.plan_name == \\\"christmas_break\\\" && user.plan == \\\"daily\\\"\\n stripe_charge = Stripe::Charge.create(amount: stripe_charge_amount(user), currency: \\\"usd\\\", customer: s_customer.id, description: \\\"xmas daily\\\")\\n user.stripe_charges.create(amount: stripe_charge_amount(user), currency: \\\"usd\\\", description: \\\"test\\\", stripe_customer_id: stripe_customer.id)\\n elsif user.plan_name == \\\"christmas_break\\\" && user.plan == \\\"all_days\\\"\\n stripe_charge = Stripe::Charge.create(amount: stripe_all_dates, currency: \\\"usd\\\", customer: s_customer.id, description: \\\"Xmas all days\\\")\\n user.stripe_charges.create(amount: stripe_all_dates, currency: \\\"usd\\\", description: \\\"test\\\", stripe_customer_id: stripe_customer.id) \\n elsif user.plan_name == \\\"spring_break\\\" && user.plan == \\\"daily\\\"\\n stripe_charge = Stripe::Charge.create(amount: stripe_charge_amount(user), currency: \\\"usd\\\", customer: s_customer.id, description: \\\"spring break daily\\\")\\n user.stripe_charges.create(amount: stripe_charge_amount(user), currency: \\\"usd\\\", description: \\\"test\\\", stripe_customer_id: stripe_customer.id)\\n elsif user.plan_name == \\\"spring_break\\\" && user.plan == \\\"all_days\\\"\\n stripe_charge = Stripe::Charge.create(amount: stripe_all_dates, currency: \\\"usd\\\", customer: s_customer.id, description: \\\"spring break all days\\\")\\n user.stripe_charges.create(amount: stripe_all_dates, currency: \\\"usd\\\", description: \\\"test\\\", stripe_customer_id: stripe_customer.id) \\n elsif user.plan_name == \\\"charlotte\\\" || user.plan_name == \\\"noresmen_cheer\\\"\\n \\n stripe_charge = Stripe::Charge.create(amount: stripe_football_amount(user), currency: \\\"usd\\\", customer: s_customer.id, description: \\\"Charge For Charlotte\\\")\\n user.stripe_charges.create(amount: stripe_football_amount(user), currency: \\\"usd\\\", description: \\\"Charlotte\\\", stripe_customer_id: stripe_customer.id)\\n \\n elsif user.plan_name == \\\"eden\\\" || user.plan_name == \\\"noresmen_cheer\\\"\\n \\n stripe_charge = Stripe::Charge.create(amount: stripe_football_amount(user), currency: \\\"usd\\\", customer: s_customer.id, description: \\\"Charge for Eden\\\")\\n user.stripe_charges.create(amount: stripe_football_amount(user), currency: \\\"usd\\\", description: \\\"Eden\\\", stripe_customer_id: stripe_customer.id)\\n\\n elsif user.plan_name == \\\"early_bird\\\" || user.plan_name == \\\"norsemen_baseball\\\"\\n stripe_charge = Stripe::Charge.create(amount: stripe_early_bird_amount(user), currency: \\\"usd\\\", customer: s_customer.id, description: \\\"EarlyBird\\\")\\n user.stripe_charges.create(amount: stripe_early_bird_amount(user), currency: \\\"usd\\\", description: \\\"EarlyBird\\\", stripe_customer_id: stripe_customer.id) \\n \\n elsif user.plan_name == \\\"wffull\\\" || user.plan_name == \\\"norsemen_baseball\\\"\\n stripe_charge = Stripe::Charge.create(amount: stripe_wffull_amount(user), currency: \\\"usd\\\", customer: s_customer.id, description: \\\"WFF FULL DAY\\\")\\n user.stripe_charges.create(amount: stripe_wffull_amount(user), currency: \\\"usd\\\", description: \\\"WFF FULL\\\", stripe_customer_id: stripe_customer.id) \\n\\n elsif user.plan_name == \\\"wffhalf\\\" || user.plan_name == \\\"norsemen_baseball\\\"\\n stripe_charge = Stripe::Charge.create(amount: stripe_wffhalf_amount(user), currency: \\\"usd\\\", customer: s_customer.id, description: \\\"WFF HALF DAY\\\")\\n user.stripe_charges.create(amount: stripe_wffhalf_amount(user), currency: \\\"usd\\\", description: \\\"WFF HALF DAY\\\", stripe_customer_id: stripe_customer.id) \\n \\n elsif user.plan_name == \\\"nonfull\\\" || user.plan_name == \\\"norsemen_baseball\\\"\\n stripe_charge = Stripe::Charge.create(amount: stripe_nonfull_amount(user), currency: \\\"usd\\\", customer: s_customer.id, description: \\\"NON FULL DAY\\\")\\n user.stripe_charges.create(amount: stripe_nonfull_amount(user), currency: \\\"usd\\\", description: \\\"NON FULL DAY\\\", stripe_customer_id: stripe_customer.id) \\n \\n elsif user.plan_name == \\\"nonhalf\\\" || user.plan_name == \\\"norsemen_baseball\\\"\\n stripe_charge = Stripe::Charge.create(amount: stripe_nonhalf_amount(user), currency: \\\"usd\\\", customer: s_customer.id, description: \\\"NON HALF DAY\\\")\\n user.stripe_charges.create(amount: stripe_nonhalf_amount(user), currency: \\\"usd\\\", description: \\\"NON HALF DAY\\\", stripe_customer_id: stripe_customer.id) \\n\\n else\\n \\n \\n subscription = customer.subscriptions.create(:plan => payment_discount(user.plan_name))\\n user.subscriptions.create(stripe_card_token: subscription.id,plan_name: user.plan_name, stripe_customer_id: stripe_customer.id)\\n end\\n rescue Exception => e\\n end\\n end\",\n \"def save_with_payment\\n if valid?\\n customer = Stripe::Customer.create(description: email, plan: plan_id, source: stripe_card_token)\\n self.stripe_customer_token = customer.id\\n save!\\n end\\n end\",\n \"def create\\n @user = User.new(user_params)\\n\\n if @user.save\\n @user.update_attribute(:token, SecureRandom.hex(6))\\n RegistrationMailer.registration_confirmation(@user, new_email_confirmation_url(token: @user.token)).deliver\\n if( @user.account == \\\"premium\\\")\\n redirect_to new_charge_path :user, @user\\n else\\n redirect_to root_path, notice: \\\"An email has been sent to your account. Please click the link in the email to verify address and complete your registration.\\\"\\n end\\n else\\n flash[:error] = \\\"Error creating new user. Please try again.\\\"\\n render :new\\n end\\n\\n end\",\n \"def create_customer\\n input_param = params[:user] || params[:customer]\\n if input_param\\n input_param.delete(:password)\\n input_param.delete(:password_confirmation)\\n input_param.delete(:username)\\n if current_user.is_a?(Referral) && input_param[:profile_attributes].present?\\n input_param[:referral_category_id] = current_user.referral_category_id\\n input_param[:profile_attributes][:referal_id] = current_user.code\\n input_param[:profile_attributes][:referal] = current_user.referral_category.name if current_user.referral_category\\n end\\n end\\n\\n @customer = Customer.find_or_initialize_by_email(input_param[:email])\\n @membership_order = Membership.find(session[:current_premium_id]) if session[:current_premium_id]\\n \\n if @customer.update_attributes(input_param)\\n order.orderable = @customer\\n # CustomerMailer.delay.welcome_email(@customer)\\n CustomerMailer.delay.welcome_email_admin(@customer)\\n \\n if order.save && session[:current_premium_id].present?\\n redirect_to extra_manage_orders_path\\n else\\n redirect_to premium_manage_orders_path\\n end\\n else\\n @customer = Customer.new(input_param)\\n flash[:errors] = @customer.errors.full_messages.uniq.join(', ')\\n prepare_customer_form\\n render :new\\n end\\n end\",\n \"def purchase_events_new_stripe_customer\\n token = params[:stripeToken]\\n @number = params[:number].to_i\\n coupon = params[:coupon]\\n cost = params[:cost]\\n\\n if create_customer_and_purchase_existing_user(token, @number, cost, coupon) # this is almost like create_customer_purchase, except have flash.nows in that helper\\n #if the customer had a coupon, update that coupon to be inactive, and attach customer's user id to it\\n # if !coupon.blank?\\n # redeem_single_use_coupon(coupon)\\n # end \\n redirect_to current_user\\n else\\n redirect_to existing_user_purchase_path\\n end \\n\\nend\",\n \"def create\\n @new_sign_up = false #don't call alias again, but do call identify from here on\\n Stripe.api_key = ENV['STRIPE_SECRET_KEY']\\n\\n unless ( params[:card].present? && params[:card][:card_number].present? &&\\n params[:card][:exp_year].present? && params[:card][:exp_month].present? &&\\n params[:card][:cvc].present? && params[:card][:plan_id].present? &&\\n params[:phone].present? && params[:customer_card_name].present?\\n )\\n\\n puts \\\"-----StripeCC - Missing Fields In Form\\\"\\n flash.now[:alert] = \\\"Missing Details - All Fields are compulsory\\\"\\n @name = params[:customer_card_name]\\n @phone = params[:phone]\\n render 'users/payment'\\n return\\n end\\n\\n \\t\\t@error = current_user.create_stripe_subscription(subscription_params)\\n\\n\\t \\tif @error.present?\\n\\t \\t\\tflash.now[:alert] = @error\\n\\t \\t\\tlogger.warn(\\\"=========Stripe Controller - Transaction Failure=========\\\")\\n @transaction = Transaction.new( :user_id => current_user.id,\\n :payment_service => \\\"Stripe\\\",\\n :trans_type => \\\"Failed\\\",\\n :stripe_callback_data => @error\\n )\\n unless @transaction.save\\n puts \\\"-----StripeCC - Our Transaction Did Not Save on Stripe Fail\\\"\\n end\\n\\n # back to payment screen:\\n\\t \\t\\trender 'users/payment'\\n\\n\\t \\telse #success\\n\\t \\t\\tflash.now[:notice] = \\\"Subscription Successfull\\\"\\n\\t \\t\\tlogger.warn(\\\"=========Transaction Successfull=========\\\")\\n @transaction = Transaction.where(:user_id => current_user.id).order(\\\"id DESC\\\").first\\n if @transaction.present?\\n @transaction.update_attributes(\\n :payment_service => \\\"Stripe\\\",\\n :trans_type => \\\"Recurring\\\"\\n )\\n else\\n puts \\\"-----StripeCC - Our Transaction Did Not Save on Stripe Success\\\"\\n end\\n\\n namearray = (params[:customer_card_name]).split(' ', 2)\\n save_user = current_user.update_attributes(:phone => (params[:phone]),\\n :first_name => namearray.first, :last_name => namearray.last)\\n puts \\\">>> current user did not save email and name.\\\" if save_user == false\\n\\n\\t \\t\\tredirect_to submit_bill_path, :notice => \\\"Subscription Successful.\\\"\\n\\t end\\n\\n end\",\n \"def create\\n @Payment = Payment.new\\n @Payment.user_id = current_user\\n\\n Stripe.api_key = ENV[\\\"STRIPE_API_KEY\\\"]\\n token = params[:stripeToken]\\n\\n begin\\n charge = Stripe::Charge.create(\\n :amount => (25 * 100).floor,\\n :currency => \\\"usd\\\",\\n :card => token\\n )\\n flash[:notice] = \\\"Thanks for purchasing!\\\"\\n rescue Stripe::CardError => e\\n flash[:danger] = e.message\\n end\\n\\n @Payment.stripe_id = charge.id\\n @Payment.amount = charge.amount\\n\\n if current_user.subscribed != true\\n current_user.subscribed = true\\n current_user.credit = 25.00\\n else\\n current_user.credit = current_user.credit + 25.00\\n end\\n\\n current_user.save\\n redirect_to caves_path\\n end\",\n \"def purchase_sub_existing_card\\n @plan = params[:sub][:plan] #integer corresponding to my_plan_id\\n @events_number = params[:sub][:events_number]\\n @code = params[:sub][:code]\\n @new_price = params[:sub][:new_price]\\n\\n # retrieve stripe customer object yet again\\n if !current_user.customer_id.blank?\\n c = Stripe::Customer.retrieve(current_user.customer_id)\\n end \\n \\n if is_valid_sub_coupon(@code) \\n\\n #create subscription for this customer in stripe (note that update_subscription creates a new subscription for this customer in this case)\\n if has_not_trialed?\\n c.update_subscription(:plan => @plan, :coupon => @code)\\n else\\n c.update_subscription(:plan => @plan, :trial_end => (Date.today + 1.day).to_time.to_i, :coupon => @code) \\n end \\n #create new subscription object in my database\\n @sub = Subscription.new(:user_id => current_user.id, :email => current_user.email, :customer_id => c.id, :my_plan_id => @plan, :plan_name => Plan.find_by_my_plan_id(@plan).name, :active => true)\\n @sub.events_remaining = @events_number\\n @sub.coupon = @code\\n @sub.save \\n\\n #create receipt\\n @r = Receipt.new(:user_id => current_user.id, :email => current_user.email, :customer_id => c.id,\\n :subscription_id => @sub.id, :sub_my_plan_id => @sub.my_plan_id, :sub_plan_name => @sub.plan_name,\\n :sub_events_number => @sub.events_remaining, :sub_reg_monthly_cost_in_cents => Plan.find_by_my_plan_id(@sub.my_plan_id).monthly_cost_cents,\\n :sub_actual_monthly_cost_in_cents => @new_price, :sub_coupon_name => @sub.coupon) \\n @r.save\\n\\n #mail receipt\\n UserMailer.sub_receipt(current_user, @r).deliver\\n\\n else\\n #create subscription for this customer in stripe (note that update_subscription creates a new subscription for this customer in this case)\\n if has_not_trialed?\\n c.update_subscription(:plan => @plan)\\n else\\n c.update_subscription(:plan => @plan, :trial_end => (Date.today + 1.day).to_time.to_i) \\n end \\n #create new subscription object in my database\\n @sub = Subscription.new(:user_id => current_user.id, :email => current_user.email, :customer_id => c.id, :my_plan_id => @plan, :plan_name => Plan.find_by_my_plan_id(@plan).name, :active => true)\\n @sub.events_remaining = @events_number\\n @sub.save \\n\\n #create receipt\\n @r = Receipt.new(:user_id => current_user.id, :email => current_user.email, :customer_id => c.id,\\n :subscription_id => @sub.id, :sub_my_plan_id => @sub.my_plan_id, :sub_plan_name => @sub.plan_name,\\n :sub_events_number => @sub.events_remaining, :sub_reg_monthly_cost_in_cents => Plan.find_by_my_plan_id(@sub.my_plan_id).monthly_cost_cents,\\n :sub_actual_monthly_cost_in_cents => @new_price, :sub_coupon_name => @sub.coupon) \\n @r.save\\n\\n #mail receipt\\n UserMailer.sub_receipt(current_user, @r).deliver\\n end \\n\\n\\n flash[:success] = \\\"Thank you! You are now subscribed to the #{Plan.find_by_my_plan_id(@plan).name.titleize} plan!\\\"\\n redirect_to current_user\\n\\n #rescue Stripe::StripeError => e # THIS CODE WORKS!!! NEEED TO FIGURE OUT HOW EXACTLY\\n # logger.error \\\"Stripe error while creating subscription w/o active sub for existing user with card on file (purchase_sub_existing_card)\\\"\\n # flash[:error] = \\\"Something went wrong. Please try again or contact us!\\\"\\n # redirect_to current_user\\n\\nend\",\n \"def create\\n @user = User.new(user_params)\\n\\n respond_to do |format|\\n if @user.save\\n format.html { redirect_to @user, notice: 'User was successfully created.' }\\n format.json { render :show, status: :created, location: @user }\\n else\\n format.html { render :new }\\n format.json { render json: @user.errors, status: :unprocessable_entity }\\n end\\n end\\n\\n Stripe.api_key = ENV[\\\"STRIPE_SECRET_KEY\\\"]\\n\\n stripe_customer = Stripe::Customer.create(\\n :email => @user.email,\\n )\\n @user.stripe_id = stripe_customer.id\\n end\",\n \"def create\\n # set up Stripe session\\n Stripe.api_key = YAML.load_file(\\\"#{Rails.root}/config/stripe.yml\\\")[Rails.env][:secret_key]\\n\\n @account_type = AccountType.find params[:account_type_id]\\n @account = Account.new({ :account_type_id => @account_type.id, name: account_params[:name] })\\n\\n user = User.new(user_params)\\n unless user.valid?\\n flash[:notice] = 'User invalid'\\n render :new\\n return\\n end\\n\\n # Get the credit card details submitted by the form\\n customer = create_stripe_customer(params[:stripeToken], user.email)\\n\\n @account.stripe_customer_id = customer.id\\n\\n begin\\n # Create the charge on Stripe's servers - this will charge the user's card\\n subscription = customer.subscriptions.create(:plan => @account_type.stripe_subscription_plan)\\n @account.recurrence_at = Time.at(subscription.start.to_i).utc.strftime('%d')\\n\\n rescue Exception => e\\n # The card has been declined\\n flash[:notice] = e.message\\n render :new\\n return\\n end\\n\\n respond_to do |format|\\n begin\\n @account.save\\n user.save\\n AccountUser.create({ :account_id => @account.id, :user_id => user.id })\\n\\n format.html { redirect_to confirm_email_path, notice: 'Account was successfully created.' }\\n format.json { render :show, status: :created, location: @account }\\n rescue Exception => e\\n flash[:notice] = e.message\\n format.html { render :new }\\n format.json { render json: e.message, status: :unprocessable_entity }\\n end\\n end\\n # respond_to do |format|\\n # if @account.save\\n # if user.save\\n # AccountUser.create({ :account_id => @account.id, :user_id => user.id })\\n # else\\n # format.html { render :new }\\n # format.json { render json: user.errors, status: :unprocessable_entity }\\n # end\\n # format.html { redirect_to confirm_email_path, notice: 'Account was successfully created.' }\\n # format.json { render :show, status: :created, location: @account }\\n # else\\n # format.html { render :new }\\n # format.json { render json: @account.errors, status: :unprocessable_entity }\\n # end\\n # end\\n end\",\n \"def update_card_and_new_subscription(token, plan, code) # plan is now a my_plan_id\\n #should be a customer_id b/c downstream from option in which user has an existing stripe customer id\\n c = Stripe::Customer.retrieve(current_user.customer_id)\\n \\n\\n #updates customer with new card\\n c.card = token\\n c.save\\n\\n if !code.nil? && is_valid_sub_coupon(code) \\n #create subscription for this customer in stripe (note that update_subscription creates a new subscription for this customer in this case)\\n if has_not_trialed?\\n c.update_subscription(:plan => plan, :coupon => code)\\n else #this shouldn't happen b/c in an upstream controller, set code to nil if has_trialed\\n c.update_subscription(:plan => plan, :trial_end => (Date.today + 1.day).to_time.to_i, :coupon => code)\\n end \\n else\\n #create subscription for this customer in stripe (note that update_subscription creates a new subscription for this customer in this case)\\n if has_not_trialed?\\n c.update_subscription(:plan => plan)\\n else\\n c.update_subscription(:plan => plan, :trial_end => (Date.today + 1.day).to_time.to_i)\\n end \\n end \\n\\n rescue Stripe::InvalidRequestError => e\\n logger.error \\\"Stripe error while creating customer: #{e.message}\\\"\\n flash[:error] = \\\"There was a problem processing your credit card. #{e.message}. Please try again.\\\"\\n false\\n \\n rescue Stripe::CardError => e\\n logger.error \\\"Stripe error while creating customer: #{e.message}\\\"\\n flash[:error] = \\\"There was a problem processing your credit card. #{e.message}. Please try again.\\\"\\n false\\n\\n rescue Stripe::StripeError => e\\n logger.error \\\"Stripe error while creating customer: #{e.message}\\\"\\n flash[:error] = \\\"There was a problem processing your credit card. #{e.message}. Please try again.\\\"\\n false\\n\\n end\",\n \"def create_stripe\\n # Order created by promotions#order and passed to merchant/orders/order_form\\n # Cases: 1) not a customer; saving card\\n # 2) not a customer; not saving card\\n # 3) customer; using saved card\\n # 4) customer; using new card and saving it\\n # 5) customer; using new card and not saving it\\n #\\n # NOTE: I'm saving the associated user object in the orders controller, instead of trying to do it in the User model\\n # I think it makes more sense to isolate all the Stripe stuff here, than have it scattered through models.\\n # I also removed Stripe code from the Order model. It is all in the controller and User model (where it belongs).\\n\\n @stripe_customer = @order.user.stripe_customer_obj\\n\\n # Calculate total charge, adjusting for macho bucks. Do we need to charge the card?\\n total_charge = @order.total_cost - @order.user.total_macho_bucks\\n if total_charge > 0\\n # We need to charge the credit card \\n if @stripe_customer.nil?\\n charge_success = false\\n \\n if params[:save_card] == 'true'\\n # case 1\\n @stripe_customer = Stripe::Customer.create(:email => @order.email,\\n :description => @order.description,\\n :card => @order.stripe_card_token)\\n \\n # Not in attr_accessible for security; must assign explicitly\\n @order.user.stripe_id = @stripe_customer.id\\n if @order.user.save\\n charge_success = charge_customer(@order, @stripe_customer, total_charge)\\n else\\n flash[:notice] = \\\"Card could not be saved.\\\"\\n charge_success = charge_card(@order, total_charge)\\n end\\n else \\n # case 2\\n charge_success = charge_card(@order, total_charge)\\n end\\n else\\n # get existing customer\\n if params[:new_card] == 'true'\\n if params[:save_card] == 'true'\\n # case 4\\n # Update the card information for an existing customer\\n @stripe_customer.card = @order.stripe_card_token\\n @stripe_customer.save\\n \\n charge_success = charge_customer(@order, @stripe_customer, total_charge)\\n else\\n # case 5\\n charge_success = charge_card(@order, total_charge)\\n end\\n else\\n # case 3\\n charge_success = charge_customer(@order, @stripe_customer, total_charge)\\n end\\n end\\n else\\n # No charge necessary\\n charge_success = true\\n # Validated, so it has to be there\\n @order.transaction_id = Order::MACHO_BUCKS_TRANSACTION_ID\\n end\\n \\n # Charge operation should either succeed or throw an exception\\n if charge_success\\n # If the charge was successful, order will have charge_id (validated on save)\\n if @order.save\\n # After saving the order, create the associated vouchers using the promotion strategy\\n # status defaults to Available; uuid is created upon save\\n if @order.promotion.strategy.generate_vouchers(@order)\\n flash[:notice] = I18n.t('order_successful')\\n \\n # If everything worked (voucher(s) saved), send the email\\n # Products are handled differently in the mailer\\n UserMailer.delay.promotion_order_email(@order)\\n @order.user.log_activity(@order)\\n \\n # Debit the Macho Bucks. Usually 0, but possible they had more bucks than it cost\\n # In the pathological case where they have negative macho bucks, the card was charged extra. That has to be cleared as well.\\n # So we have to check for != 0, not > 0\\n if @order.user.total_macho_bucks != 0\\n deduction = @order.user.total_macho_bucks < 0 ? @order.user.total_macho_bucks : [@order.user.total_macho_bucks, @order.total_cost].min\\n bucks = @order.build_macho_buck(:user_id => @order.user.id, :amount => -deduction, :notes => \\\"Credited on order: #{@order.description}\\\")\\n if !bucks.save\\n flash[:alert] = 'Unable to apply macho bucks!'\\n end\\n UserMailer.delay.macho_bucks_order_email(bucks)\\n end\\n \\n redirect_to merchant_order_path(@order) and return\\n end\\n else\\n @order.errors.add :base, \\\"Could not save order.\\\"\\n end\\n end\\n\\n # Should never get here, put theoretically possible if orders don't validate somehow; avoid template error\\n render 'new' \\n \\n # Don't need a begin inside a def\\n rescue Stripe::InvalidRequestError => error\\n logger.error \\\"Stripe error while creating customer: #{error.message}\\\"\\n @order.errors.add :base, \\\"There was a problem with your credit card. #{error.message}\\\"\\n @promotion = @order.promotion\\n render 'promotions/order'\\n \\n rescue Stripe::CardError => error\\n logger.error \\\"Stripe error: #{error.message}\\\"\\n @order.errors.add :base, \\\"There was a problem with your credit card. #{error.message}\\\"\\n @promotion = @order.promotion\\n render 'promotions/order'\\n end\",\n \"def create_stripe_customer!\\n Stripe::Customer.create(\\n email: user.email,\\n description: store.name,\\n source: stripe_source_id\\n )\\n end\",\n \"def subscription_checkout\\n\\n @code = params[:couponCode]\\n\\n if !@code.blank?\\n @discount = @code\\n\\n if @discount.nil?\\n flash[:error] = 'Coupon code is not valid or expired.'\\n redirect_to pricing_path\\n return\\n end\\n\\n charge_metadata = {\\n :coupon_code => @code,\\n :coupon_discount => (@discount * 100).to_s + \\\"%\\\"\\n }\\n end\\n\\n charge_metadata ||= {}\\n\\n plan_id = params[:plan_id]\\n plan = Stripe::Plan.retrieve(plan_id)\\n #This should be created on signup.\\n customer = Stripe::Customer.create(\\n #:description => \\\"Customer for test@example.com\\\",\\n :source => params[:stripeToken],\\n :email => current_user.email\\n )\\n\\n user = current_user\\n user.stripe_id = customer.id\\n user.subscribed = true\\n user.save\\n\\n # Save this in your DB and associate with the user;s email\\n stripe_subscription = customer.subscriptions.create(:plan => plan.id, :coupon => @discount)\\n\\n flash[:notice] = \\\"Successfully Subscribed!\\\"\\n redirect_to '/dashboard'\\n end\",\n \"def create\\n plan = params[\\\"payment\\\"][\\\"plan\\\"]\\n plan=\\\"premium_monthly\\\" if plan.empty?\\n stripe_token = params[:payment][:stripe_customer_token]\\n cardHolderName = params[\\\"cardHolderName\\\"]\\n email = params[\\\"payment\\\"][\\\"email\\\"]\\n flag = false\\n\\n if stripe_token\\n begin\\n @payment = current_user.payments.new(payment_params)\\n customer = current_user.do_transaction(params[:payment_type], stripe_token, plan, cardHolderName, email)\\n if customer\\n @payment.stripe_customer_token = customer.id\\n subcripted_detail = customer.subscriptions[\\\"data\\\"][0]\\n flash[:notice] = 'Card charged successfully'\\n else\\n flag = true\\n flash[:alert] = 'Some error happened while charging you, please double check your card details'\\n end\\n rescue Stripe::APIError => e\\n flash[:alert] = e\\n flag = true\\n end\\n else\\n flag = true\\n flash[:alert] = 'You did not submit the form correctly'\\n end\\n\\n if flag\\n render new_payment_path({plan: plan, error: e})\\n end\\n\\n respond_to do |format|\\n if @payment.save\\n plan = Payment.plans[plan]\\n current_user.update_attributes(subscription: plan, remaining_days: -1, stripe_customer_id: customer.id, is_paid_user: true)\\n NotificationMailer.monthly_subscription_email(current_user, subcripted_detail).deliver_now\\n format.html { redirect_to \\\"/users/edit\\\", notice: 'Payment made successfully.'}\\n format.json { render json: @payment, status: :created, location: @payment }\\n end\\n end\\n\\n end\",\n \"def create\\n @payment = Payment.new(payment_params)\\n\\n @amount = @payment.amount * 100\\n\\n Stripe.api_key = 'sk_test_CfSPVwqeJbuCxJSnCDcXuKRG';\\n\\n begin\\n if current_user.stripe_customer_id.present?\\n @customer = Stripe::Customer.retrieve(current_user.stripe_customer_id) \\n else\\n card_details = {}\\n card_details[:name] = payment_params[:first_name]\\n card_details[:number] = payment_params[:credit_card_number]\\n card_details[:cvc] = payment_params[:card_security_code]\\n card_details[:exp_month] = payment_params[:expiration_month]\\n card_details[:exp_year] = payment_params[:expiration_year]\\n\\n @card = Stripe::Token.create(card: card_details)\\n \\n @customer = Stripe::Customer.create(\\n :email => current_user.email,\\n :card => @card.id\\n )\\n\\n if @customer.present?\\n current_user.stripe_customer_id = @customer.id\\n current_user.save!\\n end\\n end\\n\\n\\n @charge = Stripe::Charge.create(\\n :customer => @customer.id,\\n :amount => @amount,\\n :description => 'Autopass payment',\\n :currency => 'usd'\\n )\\n\\n if @payment.save\\n redirect_to success_payment_path(@payment), notice: 'Payment was successfully created. Vender will be notified.'\\n end\\n rescue Stripe::CardError => e\\n redirect_to \\\"/siteparking/sitepayments/#{@payment.parking.token}\\\"\\n flash[:error] = e.message\\n end \\n\\n\\n end\",\n \"def success\\n if params[:reference].present?\\n\\n paystackObj = Paystack.new(ENV['PAYSTACK_PUBLIC_KEY'], ENV['PAYSTACK_PRIVATE_KEY'])\\n\\n subscriptions = PaystackSubscriptions.new(paystackObj)\\n result = subscriptions.create(\\n\\n :customer => current_user.email,\\n :plan => \\\"PLN_96ws6ovviw8028d\\\", #plan id\\n :amount => 200000 #in KOBO\\n\\n \\n )\\n\\n\\n u = current_user\\n u.subscribed = true\\n u.subscription_code = code\\n u.email_token = token\\n u.save!\\n \\n else\\n redirect_to new_subscription_path, notice: \\\"Error Making Payment, Try Again\\\"\\n\\n end\\n end\",\n \"def create\\n params.permit(:interval, :plan, :stripeEmail, :stripeToken)\\n if current_user\\n @user = current_user\\n begin\\n customer = Stripe::Customer.create(\\n :email => params[:stripeEmail],\\n :source => params[:stripeToken],\\n :plan => params[:plan]\\n )\\n if @user.plan.nil? || @user.plan != params[:plan]\\n case params[:interval]\\n when \\\"month\\\"\\n active_date_increment = Time.now + 1.month\\n when \\\"year\\\"\\n active_date_increment = Time.now + 1.year\\n when \\\"week\\\"\\n active_date_increment = Time.now + 1.week\\n end\\n @user.update_attributes!(\\n stripe_customer_id: customer.id,\\n active_until: active_date_increment,\\n plan: params[:plan],\\n stripe_token: params[:stripeToken]\\n )\\n end\\n redirect_to @user\\n rescue\\n puts \\\"Unable to register customer with Stripe: #{params[:stripeEmail]}\\\"\\n flash[:alert] = \\\"There was an error processing the payment. Please try again.\\\"\\n redirect_to plan_path(Stripe::Plan.retrieve(params[:plan]))\\n end\\n end\\n end\",\n \"def postfill!(customer)\\n self.price = customer.subscription.plan.amount / 100\\n self.stripe_id = customer.id\\n self.exp_month = customer.active_card.exp_month\\n self.exp_year = customer.active_card.exp_year\\n self.last4 = customer.active_card.last4\\n self.status = \\\"active\\\"\\n self.save!\\n self\\n end\",\n \"def purchase_events_new_stripe_couple\\n token = params[:stripeToken]\\n @number = params[:number].to_i\\n coupon = params[:coupon]\\n cost = params[:cost]\\n\\n if create_customer_and_purchase_existing_user(token, @number, cost, coupon) # this is almost like create_customer_purchase, except have flash.nows in that helper\\n #if the customer had a coupon, update that coupon to be inactive, and attach customer's user id to it\\n # if !coupon.blank?\\n # redeem_single_use_coupon(coupon)\\n # end \\n redirect_to current_user\\n else\\n redirect_to existing_couple_purchase_select_path({:peu => {:number => @number }, :coupon => coupon})\\n end \\n\\nend\",\n \"def purchase_sub_not_stripe_customer\\n token = params[:stripeToken]\\n @plan = params[:plan] #integer corresponding to my_plan_id\\n @events_number = params[:events_number] #not being used right now because create_customer helper finds the events_number form the plan object via @plan argument\\n @code = params[:code] \\n @new_price = params[:new_price]\\n event_type = \\\"voicegems\\\"\\n\\n if create_customer(token, @plan, @code, @new_price, event_type) #using the same helper as when a new user signs up as a customer\\n #record stripe's (?) customer_id for this user\\n # this helper is in users helper\\n \\n redirect_to current_user\\n else\\n @first_plan = Plan.find_by_my_plan_id(plan_set_one) # sets @first_plan the first plan object ACCORDING TO MY LEGEND (with my_plan_id)\\n @second_plan = Plan.find_by_my_plan_id(plan_set_two)\\n @third_plan = Plan.find_by_my_plan_id(plan_set_three)\\n #These above are required to properly render purchase_sub_existing. Not changing below to redirect because the create_customer helper is creating Flash.nows, not Flashs, and this helper also being used in for totally new customers/users\\n render 'purchase_sub_existing'\\n end \\n\\n\\nend\",\n \"def create\\n @user.account = Account.new if @user.account.nil?\\n\\n if @user.account.save_with_stripe(params)\\n redirect_to user_url(@user), notice: 'Account was successfully created.'\\n else\\n handle_account_errors(@user, params)\\n render :new\\n end\\n end\",\n \"def save_with_payment\\n if valid?\\n @amount = (amount * 100)\\n customer = Stripe::Customer.create(description: email, card: stripe_card_token)\\n charge = Stripe::Charge.create(\\n :customer => customer.id,\\n :amount => @amount,\\n :description => 'Food bank donation',\\n :currency => 'usd'\\n )\\n self.stripe_customer_token = customer.id\\n save!\\n end\\n rescue Stripe::InvalidRequestError => e\\n logger.error \\\"Stripe error while creating customer: #{e.message}\\\"\\n errors.add :base, \\\"There was a problem with your credit card.\\\"\\n false\\n end\",\n \"def process_payment_unlimitess\\n customer = Stripe::Customer.create email: email, card: token\\n update_stripe_customer_id(customer)\\n Stripe::Subscription.create customer: customer.id,\\n items: [\\n {price: 'price_1IndU1Bje2Voz8401SdrQuM0'},\\n ]\\n\\n# customer = Stripe::Customer.create email: email, card: token\\n# Stripe::Charge.create customer: customer.id,\\n# amount: 10000,\\n# description: 'Premium',\\n# currency: 'usd'\\n end\",\n \"def charge_user_via_invoice\\n customer_id = stripe_user_customer_id\\n return unless customer_id.present?\\n\\n invoice = create_invoice(customer_id)\\n create_invoice_items_for_dpc(customer_id, invoice.id)\\n resource.identifier.payment_id = invoice.id\\n resource.identifier.payment_type = stripe_user_waiver? ? 'waiver' : 'stripe'\\n resource.identifier.save\\n invoice.send_invoice\\n end\",\n \"def create_stripe_subscription(card_details)\\n @error = \\\"\\\"\\n\\t\\tbegin\\n\\t\\t\\tcustomer = Stripe::Customer.create(\\n\\t\\t\\t\\t:email => self.email,\\n\\t\\t \\t\\t## if you are using the js to fetch the stripe_card_token change the ':card => card_details[\\\"stripe_card_token\\\"]' ##\\n\\t\\t \\t\\t:card => {\\n\\t\\t \\t\\t\\t:number => card_details[\\\"card_number\\\"],\\n\\t\\t \\t\\t\\t:exp_month => card_details[\\\"exp_month\\\"],\\n\\t\\t \\t\\t\\t:exp_year => card_details[\\\"exp_year\\\"],\\n\\t\\t \\t\\t\\t:cvc => card_details[\\\"cvc\\\"]\\n },\\n\\t\\t\\t :plan => card_details[\\\"plan_id\\\"]\\n )\\n\\n \\t\\tputs \\\"==Customer_id : ====#{customer.id}============\\\"\\n puts \\\"--------------User Model Stripe Customer Object: \\\" + customer.inspect\\n @transaction = Transaction.new( :user_id => self.id,\\n :payment_service => \\\"Stripe\\\",\\n :trans_type => \\\"CreateStripeCustomer\\\",\\n :stripe_id => customer.id,\\n :last4 => customer.cards.data.first['last4'],\\n :brand => customer.cards.data.first['brand'],\\n :funding => customer.cards.data.first['funding'],\\n :exp_month => customer.cards.data.first['exp_month'],\\n :exp_year => customer.cards.data.first['exp_year']\\n )\\n unless @transaction.save\\n puts \\\"-----UserModel - Stripe - Our Transaction Did Not Save on Stripe Fail\\\"\\n end\\n\\n\\t \\trescue Stripe::StripeError => e\\n logger.warn(\\\"====#{e.message}==\\\")\\n puts \\\"====User-Model - Stripe Transaction Failed Due to #{e.message}=====\\\"\\n @error = (\\\"card error: \\\" + e.message)\\n # Transaction Error Record Created In Controller\\n # @transaction = Transaction.new( :user_id => self.id,\\n # :payment_service => \\\"Stripe\\\",\\n # :trans_type => \\\"Failed\\\",\\n # :stripe_callback_data => @error\\n # )\\n # unless @transaction.save\\n # puts \\\"-----UserModel - Stripe - Our Transaction Did Not Save on Stripe Fail\\\"\\n # end\\n\\t\\tend\\n\\t\\treturn @error\\n\\n end\",\n \"def subscribe!\\n Subscription.transaction do\\n subscription = create_stripe_subscription!\\n store.subscriptions.create!(\\n customer: user,\\n stripe_plan_id: stripe_plan_id,\\n stripe_id: subscription.id,\\n first_date: Date.today,\\n status: :active\\n )\\n end\\n end\",\n \"def create_stripe_customer(token)\\n Stripe.api_key = 'sk_test_xvxhe0dUKfbGI2MJOWOg1N8j'\\n\\n begin \\n customer = Stripe::Customer.create(\\n card: token,\\n description: self.email\\n )\\n\\n self.update(stripe_customer_id: customer.id)\\n rescue Stripe::CardError => e\\n flash[:error] = e.message\\n redirect_to sub_request_path\\n end\\n end\",\n \"def update_subscription\\n success = stripe_call do\\n customer = Stripe::Customer.retrieve(@user.stripe_id)\\n subscription = customer.subscriptions.retrieve(@user.stripe_subscription_id)\\n subscription.source = @params[:stripeToken] if @params[:stripeToken]\\n # Update plan if one is provided, otherwise use user's existing plan\\n # TODO providing plan_id is untested\\n plan_stripe_id = @params[:plan_id] ? Plan.find(@params[:plan_id]).stripe_id : @user.plan.stripe_id\\n subscription.items = [{\\n id: subscription.items.data[0].id,\\n plan: plan_stripe_id\\n }]\\n subscription.save\\n end\\n return false unless success\\n user_attributes_to_update = {}\\n # This is updated by the stripe webhook customer.updated\\n # But we can update it here for a faster optimistic 'response'\\n assign_card_details(user_attributes_to_update, @params)\\n user_attributes_to_update[:plan_id] = @params[:plan_id].to_i if @params[:plan_id]\\n @user.update(user_attributes_to_update) if user_attributes_to_update.any?\\n return true if success\\n end\",\n \"def create\\n customer = Stripe::Customer.create(\\n email: current_user.email,\\n card: params[:stripeToken]\\n )\\n # Changes the user role to premium\\n charge = Stripe::Charge.create(\\n customer: customer.id, \\n amount: amount_for_upgrade,\\n description: \\\"Premium Membership! - #{current_user.email}\\\",\\n currency: 'usd'\\n )\\n\\n # @param: customer, the string representation of the customer id\\n # @param: amount, an integer represenation of amount \\n # @param: description, the string representation of description \\n # @param: currency, the string representation of currancy\\n\\n current_user.update_attribute(:role, 'premium')\\n flash[:notice] = \\\"Thanks for upgrading your account!, #{current_user.email}! \\\"\\n redirect_to wikis_path(current_user) \\n\\n# Rescue block catches and displays error \\n rescue Stripe::CardError => e\\n flash[:error] = e.message\\n redirect_to new_charge_path\\nend\",\n \"def create\\n @user = User.new(user_params)\\n respond_to do |format|\\n if @user.save and @user.payment == \\\"paypal\\\"\\n response = EXPRESS_GATEWAY.setup_purchase(@user.calculate_total_in_cents,\\n :ip => request.remote_ip,\\n :return_url => new_order_url,\\n :cancel_return_url => orders_url,\\n :currency => \\\"USD\\\",\\n :description => \\\"Sms affirmation service - $#{\\\"%.2f\\\" % (@user.calculate_total_in_cents / 100 ) }\\\",\\n )\\n\\n @user.update(:payment_token => response.token)\\n redirect_to EXPRESS_GATEWAY.redirect_url_for(response.token) and return\\n format.html { redirect_to new_user_path, notice: 'Your SMS Subscription has been activated.' }\\n format.json { render action: 'show', status: :created, location: @user }\\n else\\n @user.terms = false\\n\\n format.html { render action: 'new' }\\n format.json { render json: @user.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def pay\\n Stripe.api_key = Constants::STRIPE_API_SECRET_KEY\\n\\n # Get the credit card details submitted by the form\\n token = params[:stripeToken]\\n\\n # Create a charge: this will charge the user's card\\n begin\\n #Keep this as a sample of basic Stripe payment\\n # charge = Stripe::Charge.create(\\n # :amount => 500, # Amount in cents\\n # :currency => \\\"usd\\\",\\n # :source => token,\\n # :description => \\\"Example charge\\\",\\n # :metadata => {\\\"order_id\\\" => \\\"6735\\\"}\\n # )\\n\\n #If the current_user has no stripe_customer_id in the DB, that means this is the first time he provide\\n #their bank account info, so let's create a Stripe Customer on the cloud to store their bank info for\\n #use it later.\\n if current_user.stripe_customer_id.blank?\\n customer = Stripe::Customer.create(\\n card: token,\\n description: \\\"#{current_user.email}-#{current_user.display_name}\\\",\\n email: current_user.email\\n )\\n customer_id = customer.id\\n else\\n customer = Stripe::Customer.retrieve(current_user.stripe_customer_id)\\n customer_id = current_user.stripe_customer_id\\n end\\n # Stripe::Charge.create(\\n # amount: cart_total_price, # $15.00 this time\\n # currency: 'usd',\\n # customer: customer_id\\n # )\\n\\n #TODO I know this is ugly but it can define less functions, we can optimize this later\\n @card = {card_number: (\\\"*****#{params[:card_number][-4..-1]}\\\" rescue nil) || \\\"*****#{customer[:sources][:data].first[:last4]}\\\",\\n cvv: params[:cvv] || \\\"\\\",\\n exp_date: \\\"#{params[:exp_year] || customer[:sources][:data].first[:exp_year]}-\\n #{params[:exp_month] || customer[:sources][:data].first[:exp_month]}\\\",\\n card_holder_name: params[:card_holder_name] || \\\"\\\"}\\n PaymentMailer.payment_success(current_user, @card).deliver_now\\n PaymentMailer.send_essay(current_user, session[:cart]).deliver_now\\n session[:cart] = nil\\n # save the customer ID in your database so you can use it later\\n current_user.update_column(\\\"stripe_customer_id\\\", customer_id)\\n rescue Stripe::CardError => e\\n @transaction_falied = true\\n # The card has been declined\\n PaymentMailer.payment_failed(current_user, @card).deliver_now\\n end\\n render 'payment_confirmation'\\n end\",\n \"def create\\n @subscription = Subscription.new(subscription_params)\\n\\n @subscription.sub_create(current_user,subscription_params[:stripe_plan_id],subscription_params[:coupon_code])\\n\\n # Create a subscription with the following information:\\n #\\n # 1) Customer Account\\n # 2) Subscription Type (GOLD, Silver, etc.)\\n # 3) Discount Coupom (if applicable)\\n\\n if @subscription.save\\n redirect_to @subscription, notice: 'Subscription was successfully created.'\\n else\\n @verrors = @subscription.errors.full_messages\\n render 'new'\\n end\\n end\",\n \"def create_account\\n @customer = Customer.find params[:id]\\n fail unless @customer.email == params[:customer][:email]\\n @customer.update_attributes!(customer_params)\\n @customer_session = Authentication::CustomerSession.new(\\n email: @customer.email,\\n password: customer_params[:password]\\n )\\n @customer_session.save!\\n end\",\n \"def charge!\\n self.class.transaction do\\n return if used_comp?\\n if subscriber.blank?\\n # something happened where the attached user no longer exists....\\n # do not do anything, but log it so the admin can decide what to do?\\n Freemium.log_subscription_msg(self, \\\"Subscriber (id: #{subscriber_id}, type: #{subscriber_type}) is no longer found. Deleting this subscription (id: #{self.id}).\\\")\\n self.destroy\\n return\\n end\\n \\n if billing_key.blank?\\n expire_after_grace! #if self.expires_on.blank? || self.expires_on <= Date.today\\n return \\n end\\n # attempt to bill (use gateway)\\n transaction = Freemium.gateway.charge(billing_key, subscription_plan.rate)\\n Freemium.log_subscription_msg(self, transaction)\\n transaction.success? ? receive_payment!(transaction.amount) : expire_after_grace!\\n end\\n end\",\n \"def charge\\r\\n if paypal?\\r\\n if (@response = paypal.get_profile_details(billing_id)).success?\\r\\n next_billing_date = Time.parse(@response.params['next_billing_date'])\\r\\n if next_billing_date > Time.now.utc\\r\\n update_attributes(:next_renewal_at => next_billing_date, :state => 'active')\\r\\n subscription_payments.create(:subscriber => subscriber, :amount => amount) unless amount == 0\\r\\n true\\r\\n else\\r\\n false\\r\\n end\\r\\n else\\r\\n errors.add(:base, @response.message)\\r\\n false\\r\\n end\\r\\n else\\r\\n if amount == 0 || (@response = gateway.purchase(amount_in_pennies, billing_id)).success?\\r\\n update_attributes(:next_renewal_at => self.next_renewal_at.advance(:months => self.renewal_period), :state => 'active')\\r\\n subscription_payments.create(:subscriber => subscriber, :amount => amount, :transaction_id => @response.authorization) unless amount == 0\\r\\n true\\r\\n else\\r\\n errors.add(:base, @response.message)\\r\\n false\\r\\n end\\r\\n end\\r\\n end\",\n \"def changesub_existinguser\\n @plan = params[:sub][:plan] # this is an integer corresponding to my_plan_id\\n @planobject = Plan.find_by_my_plan_id(@plan)\\n @events_number = @planobject.events_number \\n @code = params[:sub][:code]\\n\\n if is_valid_sub_coupon(@code) && !@planobject.nil?\\n @coupon = Coupon.find_by_name(@code)\\n @new_price = @planobject.monthly_cost_cents * (100 - @coupon.percent_off)/100\\n flash.now[:success] = \\\"Your promo code has been applied!\\\"\\n else #could not find that coupon\\n @code = nil \\n @coupon = nil \\n @new_price = nil\\n end\\n\\n if !current_user.customer_id.blank?\\n c = Stripe::Customer.retrieve(current_user.customer_id)\\n @last4 = c.cards.data.first.last4\\n @cardtype = c.cards.data.first.type\\n end \\n\\n render action: 'purchase_sub_existing_choose'\\n\\nend\",\n \"def create_stripe_account\\n unless stripe_token.present? || Rails.env.test?\\n customer = Stripe::Customer.create(description: \\\"User ID: #{id}\\\", email: email)\\n update_columns(stripe_token: customer.id)\\n end\\n end\",\n \"def purchase_sub_new_card\\n token = params[:stripeToken]\\n @plan = params[:plan] #integer corresponding to my_plan_id\\n @events_number = params[:events_number] \\n @code = params[:code]\\n @new_price = params[:new_price]\\n\\n if update_card_and_new_subscription(token, @plan, @code)\\n c = Stripe::Customer.retrieve(current_user.customer_id)\\n \\n #create new subscription object in my database\\n @sub = Subscription.new(:user_id => current_user.id, :email => current_user.email, :customer_id => c.id, :my_plan_id => @plan, :plan_name => Plan.find_by_my_plan_id(@plan).name, :active => true)\\n @sub.events_remaining = @events_number\\n @sub.coupon = @code \\n @sub.save \\n\\n #create receipt\\n @r = Receipt.new(:user_id => current_user.id, :email => current_user.email, :customer_id => c.id,\\n :subscription_id => @sub.id, :sub_my_plan_id => @sub.my_plan_id, :sub_plan_name => @sub.plan_name,\\n :sub_events_number => @sub.events_remaining, :sub_reg_monthly_cost_in_cents => Plan.find_by_my_plan_id(@sub.my_plan_id).monthly_cost_cents,\\n :sub_actual_monthly_cost_in_cents => @new_price, :sub_coupon_name => @sub.coupon) \\n @r.save\\n\\n #mail receipt\\n UserMailer.sub_receipt(current_user, @r).deliver\\n\\n flash[:success] = \\\"Thank you for subscribing to the #{Plan.find_by_my_plan_id(@plan).name.titleize} plan!\\\"\\n redirect_to current_user\\n\\n else\\n redirect_to purchase_sub_existing_path\\n end \\n\\n\\nend\",\n \"def subscribe!(params)\\n raise Errors::AlreadySubscribedError if subscribed?\\n raise Errors::StripeCustomerExistsError if stripe_customer_id\\n\\n customer = ::Stripe::Customer.create(\\n source: params[:stripe_token],\\n plan: params[:subscription_plan_id] || SlackRubyBotServer::Stripe.config.subscription_plan_id,\\n email: params[:stripe_email],\\n metadata: {\\n id: id,\\n team_id: team_id,\\n name: name,\\n domain: domain\\n }\\n )\\n\\n update_attributes!(\\n subscribed: true,\\n subscribed_at: Time.now.utc,\\n stripe_customer_id: customer['id'],\\n subscription_expired_at: nil,\\n subscription_past_due_at: nil,\\n subscription_past_due_informed_at: nil\\n )\\n\\n customer\\n end\",\n \"def update_card_and_subscription(token, plan) # plan is now a my_plan_id\\n \\n c = Stripe::Customer.retrieve(current_user.customer_id) #have this in the enveloping controller action as well, because of the 'undefined variable c' error i was getting from the 4000000000000341 card test\\n\\n #updates customer with new card\\n c.card = token\\n c.save\\n\\n #updates subscription plan in stripe \\n c.update_subscription(:plan => plan, :prorate => true)\\n\\n rescue Stripe::InvalidRequestError => e\\n logger.error \\\"Stripe error while creating customer: #{e.message}\\\"\\n flash[:error] = \\\"There was a problem processing your credit card. #{e.message}. Please try again.\\\"\\n false\\n \\n rescue Stripe::CardError => e\\n logger.error \\\"Stripe error while creating customer: #{e.message}\\\"\\n flash[:error] = \\\"There was a problem processing your credit card. #{e.message}. Please try again.\\\"\\n false\\n\\n rescue Stripe::StripeError => e\\n logger.error \\\"Stripe error while creating customer: #{e.message}\\\"\\n flash[:error] = \\\"There was a problem processing your credit card. #{e.message}. Please try again.\\\"\\n false\\n\\n end\",\n \"def create\\n\\n # @stripe_account = StripeAccount.new(stripe_account_params)\\n # @user = User.find(params[:user_id])\\n # @stripe_account.user_id = current_user.id\\n\\n @user = (current_user || current_affiliate)\\n @stripe_account = @user.build_stripe_account(stripe_account_params)\\n\\n\\n\\n acct = Stripe::Account.create({\\n :country => \\\"US\\\",\\n :type => \\\"custom\\\",\\n legal_entity: {\\n first_name: stripe_account_params[:first_name].capitalize,\\n last_name: stripe_account_params[:last_name].capitalize,\\n type: stripe_account_params[:account_type],\\n dob: {\\n day: stripe_account_params[:dob_day],\\n month: stripe_account_params[:dob_month],\\n year: stripe_account_params[:dob_year]\\n },\\n address: {\\n line1: stripe_account_params[:address_line1],\\n city: stripe_account_params[:address_city],\\n state: stripe_account_params[:address_state],\\n postal_code: stripe_account_params[:address_postal]\\n },\\n ssn_last_4: stripe_account_params[:ssn_last_4]\\n },\\n tos_acceptance: {\\n date: Time.now.to_i,\\n ip: request.remote_ip\\n }\\n\\n })\\n\\n @stripe_account.acct_id = acct.id\\n # @user.stripe_token = acct.id\\n\\n\\n\\n respond_to do |format|\\n\\n # @user = User.find(params[:id])\\n\\n if @stripe_account.save!\\n # && @user.save\\n\\n\\n\\n\\n format.html { redirect_to new_bank_account_path, notice: 'Stripe account was successfully created.' }\\n format.json { render :show, status: :created, location: @stripe_account }\\n\\n\\n else\\n format.html { render :new }\\n format.json { render json: @stripe_account.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def save_with_payment discount_code\\n if valid?\\n customer = Stripe::Customer.create(description: user.name, email: user.email, plan: plan.name.parameterize.underscore, card: stripe_card_token, coupon: discount_code.try(:code))\\n user.update_column(:stripe_customer_token, customer.id)\\n user.create_discount_code_user(discount_code_id: discount_code.id) unless discount_code.nil?\\n save!\\n end\\n rescue Stripe::InvalidRequestError => e\\n logger.error \\\"Stripe error while creating customer: #{e.message}\\\"\\n errors.add :base, \\\"There was a problem with your credit card.\\\"\\n false\\n end\",\n \"def pay\\n # Find the user to pay.\\n captain = User.find( params[:id] )\\n\\n # Charge amount owed over .971 to account for Stripe fee. This needs to be done here because the fee is being charged to the captain, so he needs to charge his players extra to account for the money being taken out of his take.\\n amount = session[:amount_owed]/0.971\\n # Calculate the fee amount that goes to the application.\\n fee = (amount * Rails.application.secrets.fee_percentage).to_i\\n\\n begin\\n charge_attrs = {\\n amount: amount,\\n currency: user.currency,\\n source: params[:token],\\n description: \\\"Test Charge via Stripe Connect\\\",\\n application_fee: fee,\\n destination: captain.stripe_user_id\\n }\\n\\n # case params[:charge_on]\\n # when 'connected'\\n # p charge_attrs\\n # # Use the user-to-be-paid's access token\\n # # to make the charge directly on their account\\n # charge = Stripe::Charge.create( charge_attrs, user.secret_key )\\n # when 'platform'\\n # # Use the platform's access token, and specify the\\n # # connected account's user id as the destination so that\\n # # the charge is transferred to their account.\\n # charge_attrs[:destination] = user.stripe_user_id\\n charge = Stripe::Charge.create( charge_attrs )\\n # end\\n\\n flash[:notice] = \\\"Charged successfully! View in dashboard »\\\"\\n\\n rescue Stripe::CardError => e\\n error = e.json_body[:error][:message]\\n flash[:error] = \\\"Charge failed! #{error}\\\"\\n end\\n\\n redirect_to session[:saved_url]\\n end\",\n \"def create_subscription(credit_card, options = {})\\n\\n u = self.user\\n options[:order_id] = number # currently just loading a date\\n options[:email] = u.email\\n options[:address] = {\\n :first_name => u.first_name,\\n :last_name => u.last_name,\\n :address1 => u.street_address1,\\n :address2 => (u.street_address2 || \\\"\\\"),\\n :company => (u.company || \\\"\\\"),\\n :city => u.city,\\n :state => u.us_state,\\n :zip => u.zip,\\n :country => 'United States',\\n :phone => u.primary_phone\\n }\\n\\n subscription = OrderTransaction.generate_yearly_subscription(credit_card, options)\\n self.save!\\n order_transactions << subscription\\n\\n if subscription.success?\\n self.payment_captured!\\n else\\n self.transaction_declined!\\n end\\n\\n subscription\\n end\",\n \"def create\\n # Amount in cents\\n @amount = params[:price].to_i * 100\\n \\n customer = Stripe::Customer.create(\\n :email => params[:stripeEmail],\\n :source => params[:stripeToken]\\n )\\n \\n charge = Stripe::Charge.create(\\n :customer => customer.id,\\n :amount => @amount,\\n :description => 'Rails Stripe customer',\\n :currency => 'aud'\\n )\\n \\n set_available_to_false(params[:product_id])\\n add_user_balance(params[:price])\\n redirect_to root_path\\n\\n rescue Stripe::CardError => e\\n flash[:error] = e.message\\n redirect_to new_charge_path\\n end\",\n \"def create\\n payer_email = params[:payer_email]\\n txn_type = params[:txn_type] # subscr_failed, subscr_cancel, subscr_payment, subscr_signup, subscr_eot, subscr_modify\\n \\n if params[:reason_code] == 'refund'\\n # TODO: just notify me that somebody refunded, keep their is_customer flag set to true\\n else\\n # add/flag customer\\n u = User.find_or_create_by_email(payer_email)\\n u.first_name = params[:first_name] # overwrite whatever we've got with Paypal's info\\n u.last_name = params[:last_name]\\n u.password = 'temporary'\\n u.is_customer = true\\n u.save\\n CustomerMailer.deliver_purchase_complete(u) # send them a link\\n AdminMailer.deliver_purchase_notification(u) # let me know they were added\\n subject = 'Customer added'\\n end\\n \\n render :text => 'OK'\\n end\",\n \"def create\\n tpauth = Authentication.find session[:customer_oauth_id]\\n if tpauth\\n @customer = Customer.new(params[:customer])\\n if Customer.count == 0\\n # The first customer has administrative privileges.\\n @customer.add_roles([:admin])\\n end\\n @customer.authentications << tpauth\\n @customer.save\\n session[:customer_id] = @customer.id\\n redirect_to edit_customer_registration_path(@customer), :notice => \\\"Signed In!\\\"\\n else\\n redirect_to customer_sign_in_path, \\\"You need to authenticate first.\\\"\\n end\\n end\",\n \"def create\\n sub_id = params[:spree_user][:sub_type].blank? ? \\\"1\\\" : params[:spree_user][:sub_type]\\n coupon_code = params[:spree_user][:coupon_code]\\n @cart = Cart.new\\n @user = build_resource(user_params_list)\\n\\n credit_card_params = params[:spree_user][:creditcards_attributes][\\\"0\\\"]\\n respond_to do |format|\\n format.js do\\n if @user.valid?\\n billing_address = @user.addresses.last\\n result = Creditcard.create_customer_and_creditcard_over_braintree(billing_address, @user.email,credit_card_params)\\n @success = result.success? ? true : false\\n puts \\\"i am in user success with params#{@success} and #{billing_address}\\\"\\n\\n\\n if @success && @user.save\\n customer =result.customer\\n @credit_card_details = Creditcard.update_creditcard(customer.credit_cards.first, @user.id)\\n @user.push_subscription_and_customer_id(sub_id, customer.id)\\n @cart.prepare_cart(@user.id, sub_id)\\n @user.update_bill_and_ship_address_details\\n @user.update_address_type_and_name_fields\\n\\n #####code for creating new orders#####\\n # first order\\n plan_price = Subscription.where(id: sub_id).first.plan_price.to_f\\n @order_1 = place_order_registration(sub_id, FIRST_DELIVERY_DAYS.days.from_now, @user, @credit_card_details.id, request.remote_ip, plan_price)\\n new_token_1 = @order_1.get_unique_ID\\n new_token_subscr = Spree::Order.get_unique_subscription_token\\n #entry in user subscription\\n\\n coupon = Coupon.get_briantree_discount_id_and_calculate_final_amount(plan_price, coupon_code)\\n\\n if coupon.present?\\n user_subscription_id = UserSubscription.create_user_subscription(sub_id, @user.id, new_token_subscr, coupon[\\\"id\\\"])\\n sub_result = Subscription.place_subscription_with_coupon(@order_1.delivery_date, @order_1.subscription_id, @credit_card_details.id, new_token_subscr, coupon)\\n @order_1.update_attributes(coupon_id: coupon[\\\"id\\\"])\\n Coupon.raise_counter(coupon[\\\"id\\\"])\\n else\\n user_subscription_id = UserSubscription.create_user_subscription(sub_id, @user.id, new_token_subscr)\\n sub_result = Subscription.place_subscription_without_coupon(@order_1.delivery_date, @order_1.subscription_id, @credit_card_details.id, new_token_subscr)\\n end\\n\\n @order_1.update_attributes(number: new_token_1, user_subscription_id: user_subscription_id, subscription_token: new_token_subscr)\\n\\n # second order\\n @order_2 = place_order_registration(sub_id, SECOND_DELIVERY_DAYS.days.from_now, @user, @credit_card_details.id, plan_price)\\n new_token_2 = @order_2.get_unique_ID\\n @order_2.update_attributes(number: new_token_2, subscription_token: new_token_subscr, user_subscription_id: user_subscription_id)\\n\\n # third order\\n @order_3 = place_order_registration(sub_id, THIRD_DELIVERY_DAYS.days.from_now, @user, @credit_card_details.id, plan_price)\\n new_token_3 = @order_3.get_unique_ID\\n @order_3.update_attributes(number: new_token_3, subscription_token: new_token_subscr, user_subscription_id: user_subscription_id)\\n\\n #creating new line-items-default\\n\\n create_new_line_items(sub_id,@order_1)\\n create_new_line_items(sub_id,@order_2)\\n create_new_line_items(sub_id,@order_3)\\n\\n @order_1.update_total_and_item_total #reupdated total & item_total as its changed by is_pushed = 1 , in push notification method.\\n @order_2.update_total_and_item_total\\n @order_3.update_total_and_item_total\\n ######################################\\n\\n sign_in(:spree_user, @user)\\n session[:spree_user_signup] = true\\n #MyMailer.notify_user_after_registration(current_user).deliver\\n result = signup_mail_params(@order_1)\\n VeganMailer.signup_email(result).deliver\\n\\n result = vendor_email_params(@order_1)\\n VeganMailer.vendor_email(result).deliver\\n\\n render js: %(window.location.href="https://huggingface.co/spree/orders/snack_queue") and return\\n\\n else\\n @user.destroy\\n @user.remove_errormessages_added_by_spree\\n @user.errors.add(:creditcards,\\\"invalid credit card details\\\")\\n end\\n else\\n \\n end\\n end\\n end\\n\\n end\",\n \"def create\\n \\n @customer = Customer.new(customer_params)\\n @user = current_user\\n respond_to do |format|\\n if @customer.save\\n @customer.update!(user_id: @user.id)\\n format.html { redirect_to customers_path, notice: 'Customer was successfully created.' }\\n format.json { render :show, status: :created, location: @customer }\\n else\\n format.html { render :new }\\n format.json { render json: @customer.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n #create a random key to identify the new customer\\n customer_id = Array.new(8/2) { rand(256) }.pack('C*').unpack('H*').first\\n\\n # The APP_CONFIG value comes from app_config.yml in the Config dir\\n @subscription = Subscription.new(params[:subscription])\\n\\n #maybe this should be in the model?\\n @subscription.plan_id = APP_CONFIG[:subscription_token]\\n @subscription.customer_id = customer_id\\n @subscription.sub_id = \\\"#{Time.now.strftime(\\\"%Y%m%d%H%M%s\\\")}\\\"\\n # First try to create the customer in BrainTree's vault, if successful then save the subscription record.\\n # I'd like this process improved to so it's using error handling instead of flash messages\\n @result = Braintree::Customer.create(\\n :id => customer_id,\\n :first_name => params[:subscription][\\\"billing_first_name\\\"],\\n :last_name => params[:subscription][\\\"billing_last_name\\\"],\\n :company => params[:subscription][\\\"billing_company\\\"],\\n :credit_card => {\\n :cardholder_name => params[:subscription][\\\"credit_card_name\\\"],\\n :number => params[:subscription][\\\"credit_card_number\\\"],\\n :token => @subscription.sub_id,\\n :expiration_date => \\\"#{params[:subscription][\\\"credit_card_month\\\"]}/#{params[:subscription][\\\"credit_card_year\\\"]}\\\",\\n :cvv => params[:subscription][\\\"credit_card_cvv_code\\\"],\\n :billing_address => {\\n :street_address => params[:subscription][\\\"billing_address\\\"],\\n :extended_address =>params[:subscription][\\\"billing_address2\\\"],\\n :locality => params[:subscription][\\\"billing_city\\\"],\\n :region => params[:subscription][\\\"billing_state\\\"],\\n :postal_code => params[:subscription][\\\"billing_zipcode\\\"],\\n :country_code_numeric => params[:subscription][\\\"billing_country\\\"]\\n }\\n }\\n )\\n if @result.success?\\n if create_subscription( @subscription.sub_id, params[:subscription][\\\"fee\\\"])\\n @merchant = Merchant.find(session[:merchant_id])\\n @merchant.update_attributes(:customer_id => customer_id)\\n # I removed all the respond_to code, I don't think I'll be using XML formating, shoudl all the respond_do code be removed?\\n if @subscription.save\\n redirect_to(:controller => 'subscriptions', :action => 'index', :notice => 'Subscription was successfully created.')\\n else\\n render :action => \\\"new\\\"\\n end\\n else\\n render :action => \\\"new\\\"\\n end\\n else\\n #was not able to create the customer, display error messages\\n render :action => \\\"new\\\"\\n end\\n end\",\n \"def purchase_events_existing_card\\n\\n @number = params[:peu][:number]\\n coupon = params[:peu][:coupon] # this is the coupon name/code, a string\\n cost = params[:peu][:cost] #in cents\\n\\n # retrieve stripe customer object (downstream from user having a customer_id)\\n c = Stripe::Customer.retrieve(current_user.customer_id)\\n \\n if existing_customer_purchase_events_existing_card(@number, cost, coupon)\\n #if the customer had a coupon, update that coupon to be inactive, and attach customer's user id to it\\n #if !coupon.blank?\\n # redeem_single_use_coupon(coupon)\\n #end \\n flash[:success] = \\\"Thank you! You have purchased an additional #{@number} event pages.\\\"\\n redirect_to current_user\\n else #errors in processing the card shouldn't usually happen, because the card was originally ok. Can test by using stripes card number that binds to customer but does not charge correctly.\\n # YES THE REDIRECT WORKS WITH THAT STRIPE TESTING NUMBER\\n redirect_to existing_user_purchase_path\\n end \\n\\n\\n \\nend\",\n \"def create\\n @return_path = new_subscription_path\\n\\n redirect_to subscriptions_path and return unless current_plan\\n render 'new' and return unless current_user\\n\\n current_user.update_stripe_card!(params[:stripe_card_token]) unless params[:stripe_card_token].blank?\\n current_user.apply_coupon!(current_coupon.id) if current_coupon\\n current_user.set_offer_and_subscription_plan!(current_offer, current_plan) if current_offer && current_plan\\n\\n unless current_user.stripe_subscription_active?\\n Rails.logger.debug \\\"current_user.stripe_subscription_active? is false\\\"\\n render 'new' and return\\n end\\n\\n Resque.enqueue(UpdateMailChimp, current_user.email, :subscriber)\\n\\n Rails.logger.info \\\"Subscription updated.\\\"\\n \\n clear_subscription_data\\n process_new_subscription_analytics\\n\\n redirect_to subscription_confirm_path\\n\\n rescue Stripe::StripeError => e\\n error = e.json_body[:error]\\n\\n # this POST happens twice. The first time through, the user hasn't entered any form data and we don't want to show bogus errors.\\n unless params[:stripe_customer_id].nil? # first pass through won't include stripe_customer_id as a param\\n Rails.logger.error error[:message]\\n flash.alert = error[:message]\\n end\\n \\n render 'new'\\n\\n rescue => e\\n Rails.logger.error e.message\\n flash.alert = \\\"M2222\\\"#e.message\\n\\n render 'new'\\n\\n end\",\n \"def thank_you\\n user = session[:user]\\n user.zip = params[:zip]\\n \\n start_date = Date.today\\n start_date += 61\\n \\n response = create_autorrecuring_subscription(start_date, user, params[:card_number], params[:month], params[:year], \\n params[:cvc], params[:card_type], params[:city], params[:state],\\n params[:billing_address_1], params[:billing_address_2])\\n if response.success?\\n session[:errors] = nil\\n session[:user] = nil\\n user.arb_subscription_id = response.subscription_id\\n user.arb_status = AuthorizeNet::ARB::Subscription::Status::ACTIVE\\n user.billing_information_id = user.add_billing_information(params[:fullname], params[:billing_address_1] ,\\n params[:billing_address_2], params[:city], params[:state],\\n params[:zip]).id\\n user.save\\n else\\n puts \\\"Failed to make purchase. \\\" + response.response_reason_code + \\\" - \\\" + response.response_reason_text\\n user.errors.clear()\\n user.errors.add(:transaction, response.response_reason_text)\\n session[:errors] = user.errors\\n redirect_to admin_signup_step3_path\\n end \\n\\n \\n end\",\n \"def save_with_stripe(params)\\n account_valid = true\\n begin\\n\\n if (account_valid = is_valid(params))\\n # Create a stripe customer\\n Stripe.api_key = ENV['API_KEY']\\n\\n customer = Stripe::Customer.create(\\n :description => \\\"#{ACCOUNT_NAME} customer account.\\\",\\n :card => params[:account][:stripe_cc_token],\\n :email => params[:cardholder_email]\\n )\\n\\n load_customer_info(customer)\\n self.status = ACTIVE\\n\\n # Attempt to save the record\\n account_valid = self.save ? true : false\\n end\\n\\n rescue Stripe::StripeError => stripe_error\\n account_valid = stripe_error_handler(stripe_error, INACTIVE)\\n end\\n\\n return account_valid\\n end\",\n \"def new_customer\\n @org = Organisation.find_by(permalink: params[:organisation_id])\\n @customer = Customer.new\\n\\n Stripe.api_key = ENV[\\\"STRIPE_SECRET_KEY\\\"]\\n end\",\n \"def create_as_stripe_customer(options = {})\\n raise Reji::CustomerAlreadyCreatedError.exists(self) if stripe_id?\\n\\n options[:email] = stripe_email if !options.key?('email') && stripe_email\\n\\n # Here we will create the customer instance on Stripe and store the ID of the\\n # user from Stripe. This ID will correspond with the Stripe user instances\\n # and allow us to retrieve users from Stripe later when we need to work.\\n customer = Stripe::Customer.create(\\n options, stripe_options\\n )\\n\\n update({ stripe_id: customer.id })\\n\\n customer\\n end\",\n \"def create_customer(customer_data)\\n ::Stripe::Customer.create(customer_data)\\n end\",\n \"def purchase_events_new_card\\n token = params[:stripeToken]\\n @number = params[:number].to_i\\n coupon = params[:coupon]\\n cost = params[:cost] #in cents\\n\\n if update_card_and_purchase(token, @number, cost, coupon)\\n #if the customer had a coupon, update that coupon to be inactive, and attach customer's user id to it\\n # if !coupon.blank?\\n # redeem_single_use_coupon(coupon)\\n # end \\n flash[:success] = \\\"Thank you! You have purchased an additional #{@number} event pages.\\\"\\n redirect_to current_user\\n else\\n redirect_to existing_user_purchase_path\\n end \\nend\",\n \"def save_and_charge\\n # Check our data if it's valid\\n if self.valid?\\n #If if it's valid, charge\\n Stripe::Charge.create(amount: self.total_price, currency: \\\"USD\\\", source: self.stripe_token, description: \\\"Order for #{self.email}\\\")\\n\\n self.save\\n\\n else\\n false # Not valid, show error\\n end\\n\\n rescue Stripe::CardError => e\\n # This is coming from stripe documentation\\n @message = e.json_body[:error][:message]\\n\\n # Beside validation errors, we can create our own errors\\n self.errors.add(:stripe_token, @message)\\n\\n # Return false to our controller\\n false\\n\\n end\",\n \"def managed\\n connector = StripeManaged.new(current_customer)\\n account = connector.create_account!(\\n params[:country], params[:tos] == 'on', request.remote_ip\\n )\\n\\n if account\\n flash[:notice] = \\\"Managed StripeAccount account created! View in dashboard »\\\"\\n else\\n flash[:alert] = 'Unable to create StripeAccount account!'\\n end\\n redirect_to customer_path(current_customer)\\n end\",\n \"def pay\\n # Find the user to pay.\\n user = User.find( params[:id] )\\n\\n # Charge $10.\\n amount = 1000\\n # Calculate the fee amount that goes to the application.\\n fee = (amount * Rails.application.secrets.fee_percentage).to_i\\n\\n begin\\n charge = Stripe::Charge.create(\\n {\\n amount: amount,\\n currency: user.currency,\\n card: params[:token],\\n description: \\\"Test Charge via Stripe Connect\\\",\\n application_fee: fee\\n },\\n\\n # Use the user-to-be-paid's access token\\n # to make the charge.\\n user.secret_key\\n )\\n flash[:notice] = \\\"Charged successfully! View in dashboard »\\\"\\n\\n rescue Stripe::CardError => e\\n error = e.json_body[:error][:message]\\n flash[:error] = \\\"Charge failed! #{error}\\\"\\n end\\n\\n redirect_to user_path( user )\\n end\",\n \"def newcustomercreate_trial\\n@user = User.new(params[:user]) #replaced code below so when hit this url directly, don't get a nil error\\n\\n # @user = User.new\\n # @user.email = params[:user][:email]\\n # @user.password=params[:user][:password]\\n # @user.password_confirmation=params[:user][:password_confirmation]\\n # @user.first_name = params[:user][:first_name]\\n # @user.last_name = params[:user][:last_name]\\n # @user.company = params[:user][:company]\\n # @user.event_type = params[:user][:event_type]\\n #this will pass in the @plan value into the stripenewcustomer_purchase page via the render 'stripenewcustomer_purchase' below (changed this from redirect, wasn't sure that would work)\\n\\n\\n if @user.save\\n\\n sign_in @user\\n # since user is new, won't have any PO with user_id; might have floating PO's with this email for some event, but those would be caught later when customer signs in for those events\\n # when creates an event, can invite himself (at that email) to create a PO for that event for himself\\n flash[:success] = \\\"Welcome to VoiceGems! Please contact us with any questions about how to make the most of this service.\\\"\\n \\n # render 'stripe_vgtrial' # i think @number defined in this action is being used on the stripenewcustomer_purchase rendering\\n # redirect_to welcome_path # a welcome page to explain to them what to do\\n create_vg_trial_without_stripe \\n redirect_to welcome_path\\n else\\n\\n if User.find_by_email(@user.email)#if the user already exists, tell them to try logging in to the right\\n flash[:error] = \\\"You are already registered on our site. Please sign in to purchase event pages under your Accounts tab.\\\"\\n redirect_to root_path\\n else\\n render action: 'newcustomer_trial'\\n end \\n\\n end \\n\\nend\",\n \"def create\\n if user_params[:password_confirmation]\\n user = User.create!(user_params)\\n\\n session[:user_id] = user.id\\n session[:expiration_time] = Time.now + 6*60*60 # 6 hours until expiration\\n \\n response = { message: Message.account_created }\\n json_response(response, :created)\\n else\\n response = { message: Message.password_confirmation_missing}\\n json_response(response, :not_acceptable)\\n end\\n end\",\n \"def create\\n\\n\\t\\t# Get the credit card details submitted by the form\\n\\t\\ttoken = params[:stripeToken]\\n\\n\\t\\t# Amount in cents\\n\\t\\t@amount = 500\\n\\n\\t\\tcustomer = Stripe::Customer.create(\\n\\t\\t\\t:email => 'example@stripe.com',\\n\\t\\t\\t:card => params[:stripeToken]\\n\\t\\t)\\n\\n\\t\\t# Create the charge on Stripe's servers - this will charge the user's card\\n\\t\\tcharge = Stripe::Charge.create(\\n\\t\\t\\t:customer => customer.id,\\n\\t\\t\\t:amount => @amount,\\n\\t\\t\\t:description => 'Rails Stripe customer',\\n\\t\\t\\t:currency => 'usd',\\n\\t\\t\\t:card => token\\n\\t\\t)\\n\\n\\trescue Stripe::CardError => e\\n\\t flash[:error] = e.message\\n\\t redirect_to charges_path\\n\\tend\",\n \"def create\\n @credit_card = current_user.credit_cards.new(credit_card_params)\\n\\n current_user._create_stripe_customer_id\\n # We want to retrieve the customer from Stripe\\n # Then add the new card to the customer\\n begin\\n customer = Stripe::Customer.retrieve(current_user.stripe_customer_id)\\n card = customer.sources.create(:source => params[:stripeToken])\\n rescue Stripe::CardError => e\\n # Since it's a decline, Stripe::CardError will be caught\\n body = e.json_body\\n err = body[:error][:message]\\n redirect_to :back, notice: \\\"#{err}\\\"\\n else\\n customer.default_source = card.id\\n customer.save\\n @credit_card.stripe_card_id = card.id\\n @credit_card.last_four = card.last4\\n\\n if @credit_card.save\\n unless session[:pending_session_counselor_id].present?\\n redirect_to user_dashboard_path, notice: 'Credit card was successfully created.'\\n else\\n redirect_to new_counseling_session_path, notice: 'You are almost done. Now you can finalize your session.'\\n end\\n else\\n render :new\\n end\\n end\\n end\",\n \"def create(params)\\n If(Hr.find(params[:user_id])) do |hr|\\n customer = Stripe::Customer.create(source: params[:stripe][:token])\\n hr.update_attribute(:stripe_id, customer.id)\\n hr.update_attribute(:last_four_digits, customer.sources.data.first.last4)\\n end\\n end\",\n \"def new_customer_registration(user, token)\\n @current_user = user\\n @token = token\\n mail(to: user[:email], subject: 'Registration Successful – Please Verify Your Email Address')\\n end\",\n \"def purchase_events_existing_card_couple\\n\\n @number = params[:peu][:number]\\n coupon = params[:peu][:coupon] # this is the coupon name/code, a string\\n cost = params[:peu][:cost]\\n\\n # retrieve stripe customer object (downstream from user having a customer_id)\\n c = Stripe::Customer.retrieve(current_user.customer_id)\\n \\n if existing_customer_purchase_events_existing_card(@number, cost, coupon)\\n #if the customer had a coupon, update that coupon to be inactive, and attach customer's user id to it\\n #if !coupon.blank?\\n # redeem_single_use_coupon(coupon)\\n #end \\n flash[:success] = \\\"Thank you! You have purchased #{@number} VoiceGems pages.\\\"\\n redirect_to current_user\\n else #errors in processing the card shouldn't usually happen, because the card was originally ok. Can test by using stripes card number that binds to customer but does not charge correctly.\\n # YES THE REDIRECT WORKS WITH THAT STRIPE TESTING NUMBER\\n redirect_to existing_couple_purchase_select_path({:peu => {:number => @number }, :coupon => coupon})\\n end \\n\\nend\",\n \"def create_charge\\n customer = Stripe::Customer.create(\\n :email => params[:stripeEmail],\\n :card => params[:stripeToken]\\n )\\n\\n charge = Stripe::Charge.create(\\n :customer => customer.id,\\n :amount => Deal.find(current_consumer.orders.last[:deal_id]).price.to_i * 100,\\n :description => 'Prlayvous Ticket',\\n :currency => 'usd'\\n )\\n\\n #After paying with Stripe, consumers are prompt to confirm their shipping address.\\n redirect_to edit_consumer_order_path(current_consumer, @order)\\n\\n rescue Stripe::CardError => e\\n flash[:error] = e.message\\n redirect_to charges_path\\n end\",\n \"def activate\\n \\n # Subscription vitals\\n customer_ref = params[:SubscriptionReferrer]\\n plan_ref = params[:ProductPath].sub(\\\"/\\\", \\\"\\\")\\n subscription_ref = params[:SubscriptionReference]\\n \\n # subscription info\\n status = params[:SubscriptionStatus].to_s.downcase.strip\\n end_date = params[:SubscriptionEndDate]\\n next_period_date = params[:SubscriptionNextPeriodDate]\\n status_reason = params[:SubscriptionStatusReason]\\n total_price = params[:SubscriptionTotalPriceValue]\\n \\n user = User.find(customer_ref)\\n plan = Plan.find_by_fastspring_reference(plan_ref)\\n \\n raise \\\"Received subscription activation but the subscription status is not 'active', but is rather: '#{status}'\\\" unless status == \\\"active\\\"\\n raise \\\"Received subscription activation for #{user.id} but couldn't find a matching plan: #{plan_ref}\\\" unless plan\\n raise \\\"Received subscription activation for #{user.id} but they already have an active subscription with reference #{user.active_subscription.reference}\\\" if user.subscribed?\\n\\n Subscription.create!(\\n user: user,\\n reference: subscription_ref,\\n end_date: end_date,\\n next_period_date: next_period_date,\\n status: status,\\n status_reason: status_reason,\\n total_price: total_price,\\n currency: params[:SubscriptionTotalPriceCurrency]\\n )\\n user.plan = plan\\n user.save!\\n\\n render nothing: true, status: 200\\n end\",\n \"def create\\n #to avoid unwanted/unsafe requests we replace params[:user]\\n @user = User.new(user_params)\\n if @user.save\\n # =WANT THEM TO ACTIVATE ACCOUNT FIRST\\n @user.send_activation_email\\n flash[:info] = \\\"Please check your email to activate your account.\\\"\\n redirect_to root_url\\n #logs in a user after they make account\\n # log_in(@user)\\n # flash[:success] = \\\"Welcome to Twitter Clone!\\\"\\n #redirect_to @user\\n else\\n render 'new'\\n end\\n end\",\n \"def create\\n @customer = User.new(customer_params)\\n @customer.authority = 'customer'\\n respond_to do |format|\\n if @customer.save\\n if !current_user\\n log_in @customer, :customer\\n end\\n format.html {redirect_to customer_path(@customer), notice: 'Customer was successfully created.'}\\n format.json {render :show, status: :created, location: @customer}\\n else\\n format.html {render :new}\\n format.json {render json: @customer.errors, status: :unprocessable_entity}\\n end\\n end\\n end\",\n \"def stripe_customer_subscription_created(event, req)\\n stripe_customer_subscription_updated(event, req)\\n end\",\n \"def create\\n\\n @charge = Charge.new(charge_params)\\n \\n customer = StripeTool.create_customer(email: params[:stripeEmail], \\n stripe_token: params[:stripeToken])\\n\\n charge = StripeTool.create_charge(customer_id: customer.id, \\n amount: (@charge.amount*100).to_i,\\n description: @charge.topic)\\n\\n @charge.stripe_id = customer.id\\n \\n\\n respond_to do |format|\\n if @charge.save\\n if @charge.owner_type == \\\"User\\\"\\n format.html { redirect_to user_path(:id => @charge.owner_id, :topic => \\\"personen_charges\\\"), notice: (I18n.t :thxpayment) }\\n end\\n if @charge.owner_type == \\\"Company\\\"\\n format.html { redirect_to company_path(:id => @charge.owner_id, :topic => \\\"institutionen_charges\\\"), notice: 'Charge was successfully created.' }\\n end\\n format.json { render :show, status: :created, location: @charge }\\n else\\n format.html { render :new }\\n format.json { render json: @charge.errors, status: :unprocessable_entity }\\n end\\n end\\n\\n rescue Stripe::CardError => e\\n flash[:error] = e.message\\n redirect_to user_path(:id => @charge.owner_id, :topic => \\\"personen_charges\\\"), notice: (:I18n.t :nopayment)\\n \\n end\",\n \"def purchase_events_new_card_couple\\n token = params[:stripeToken]\\n @number = params[:number].to_i\\n coupon = params[:coupon]\\n cost = params[:cost]\\n\\n if update_card_and_purchase(token, @number, cost, coupon)\\n #if the customer had a coupon, update that coupon to be inactive, and attach customer's user id to it\\n # if !coupon.blank?\\n # redeem_single_use_coupon(coupon)\\n # end \\n flash[:success] = \\\"Thank you! You have purchased #{@number} VoiceGems Pages.\\\"\\n redirect_to current_user\\n else\\n redirect_to existing_couple_purchase_select_path({:peu => {:number => @number }, :coupon => coupon})\\n end \\nend\",\n \"def create_user_account\\n User.create!(email: self.email, password: self.customer)\\n # user = User.new do |u|\\n # u.email = email\\n # u.password = customer\\n # u.save\\n # end\\n end\",\n \"def post_billing(req)\\n with_stripe_error_handlers do\\n customer = Stripe::Customer.retrieve(@dealership.customer_id)\\n customer.card = posted['stripeToken']\\n customer.save\\n req.session['billing_flash_msg'] = \\\"Card updated successfully.\\\"\\n redirect \\\"/admin/#{@dealership.slug}/billing\\\"\\n end\\n end\",\n \"def pay\\n @card = Creditcard.new(creditcard_params)\\n\\n user = current_user\\n\\n if @card.valid?\\n result = Creditcard.create_only_creditcard_over_braintree(user.braintree_customer_id, @card)\\n @braintree_cc_return = result.success? ? result.credit_card : nil\\n end\\n\\n\\n if @braintree_cc_return.present?\\n @card.save\\n @card.update_attributes(user_id: user.id)\\n @card = Creditcard.update_creditcard(@braintree_cc_return, user.id)\\n end\\n\\n end\",\n \"def create\\n if params[:type] == StripePaymentGatewayProfile::Events::SUBSCRIPTION_UPDATED\\n\\n # hackity mchacks a lot. use a singleton? hmm.\\n event = StripePaymentGatewayProfile.new.webhook_event_with_stripe_key(AppConfiguration.get('stripe.secret_key'), params[:id])\\n\\n if event\\n\\n subscription = event.data.values[0]\\n previous_values = event.data.values[1]\\n if event.type == StripePaymentGatewayProfile::Events::SUBSCRIPTION_UPDATED\\n profile = StripePaymentGatewayProfile.by_vendor_id(subscription['customer']).first\\n if profile && profile.subscribable?\\n profile.reload_remote\\n if !previous_values['status'].blank? && previous_values['status'] != subscription['status'] && !profile.active_plan?\\n profile.payment_gateway_profilable.notify_inactive!\\n end\\n else\\n # Found event, but not the customer record. dismiss the event,\\n # but remember in our system that we messed up.\\n DetectedError.create(\\\"Received webhook for customer that we didn't handle: #{subscription.customer}\\\")\\n end\\n end\\n\\n head :ok\\n else\\n # not existent event\\n head :not_found\\n end\\n else\\n\\n # this is a trade off. on the one hand, lets attackers identify this end and DOS us. on the other hand,\\n # we don't recognize this hook...we don't care.\\n # todo: build this stripe key retrieval into the mfe.\\n head :ok\\n\\n end\\n end\",\n \"def handle_unpaid_customer(customer_subscription)\\n\\t\\tsubscription = Subscription.find_by_stripe_customer_token(customer_subscription.customer)\\n\\t\\tsubscription.status = false\\n\\t\\tsubscription.status_info = customer_subscription.status\\n\\t\\tsubscription.save!\\n\\n\\t\\tuser = subscription.user\\n\\t\\tNotifyMailer.delay.account_expired(user)\\n\\t\\tNotifyMailer.delay.update_grapevine_team(user, \\\"User has been set to UNPAID status\\\")\\n\\tend\",\n \"def create\\n @user = User.find_by_email_and_activated(params[:user][:email], false) # We can only register a user that hasn't been activated yet.\\n \\n if @user\\n # Cases 2 and 3.\\n params[:user].delete(:email) # They can't arbitrarily change their email address.\\n @user.update_attributes(params[:user])\\n else\\n # Case 1.\\n @user = User.new(params[:user].merge({:perishable_token => \\\"\\\"}))\\n @user.reset_perishable_token!\\n end\\n \\n # This is true when a user finishes their registration from a link in their email (Case 3),\\n # which means we don't need to send an activation link.\\n if params[:token] && User.find_using_perishable_token(params[:token], 0) == @user\\n activate\\n else\\n # Cases 1 and 2. \\n # Saving without session maintenance to skip\\n # auto-login which can't happen here because\\n # the user has not yet been activated\\n if @user.save_without_session_maintenance\\n @user.deliver_activation_instructions\\n flash[:notice] = 'Registration successful. Please check your email to activate your account.'\\n redirect_to shares_path\\n else\\n flash[:error] = 'Registration failed. Please try again.'\\n redirect_to root_path\\n end\\n end\\n end\",\n \"def create\\n super do |resource| #super means inherit the 'create' action, but then extend it\\n if params[:plan]\\n #is there a parameter called param?\\n resource.plan_id = params[:plan] #resource means user in this case. So take whatever is in the form and set this users plan to be that plan id\\n if(resource.plan_id == 2) #so if the form is coming from the pro form, then don't just save the user. We also wanyt to keep the plan id. run the function that we create called save_with_subscription\\n resource.save_with_subscription #write a user created function in the model. So in this case models/user.rb\\n #the save is done in the model.\\n else\\n #otherwise just save as normal devise save\\n resource.save\\n end\\n end\\n end\\n end\",\n \"def create\\n @registration = Registration.new(registration_params)\\n\\n # Amount in cents\\n @amount = @registration.subtype == 'team' ? 9000 : 5000\\n\\n # Disabled for now,\\n # customer = Stripe::Customer.create(\\n # :email => params[:stripeEmail],\\n # :source => params[:stripeToken]\\n # )\\n #\\n # charge = Stripe::Charge.create(\\n # :customer => customer.id,\\n # :amount => @amount,\\n # :description => 'EnergyX Resolve To Row',\\n # :currency => 'usd'\\n # )\\n #\\n # @registration.is_paid = true if customer && charge\\n # @registration.stripe_customer_id = customer.id\\n # @registration.stripe_charge_id = charge.id\\n\\n respond_to do |format|\\n if @registration.save\\n format.html { redirect_to @registration, notice: 'We have successfully created your registration! You card HAS NOT BEEN CHARGED. Please Print this page for your records.' }\\n format.json { render :show, status: :created, location: @registration }\\n else\\n format.html { render :new }\\n format.json { render json: @registration.errors, status: :unprocessable_entity }\\n end\\n end\\n\\n rescue Stripe::CardError => e\\n flash[:error] = e.message\\n redirect_to new_registration_path(@registration)\\n end\",\n \"def create\\n @purchase = Purchase.new purchase_attributes\\n if @purchase.save\\n @ok = true\\n renewed = Purchase.find_by_id params[:renewed_id]\\n if renewed\\n renewed.users.each do |u|\\n u.purchase_id = @purchase.id\\n u.save\\n Notification.send_to(\\n u.id,\\n I18n.t('notifications.account.renewed.title'),\\n I18n.t('notifications.account.renewed.message', :expiration_date => TimeConvert.to_string(@purchase.expiration_date)),\\n ''\\n )\\n end\\n renewed.expiration_date = Time.zone.now\\n renewed.save\\n end\\n else\\n @ok = false\\n @errors = @purchase.errors.messages.keys\\n @errors << :ssn_code if @errors.include?(:base)\\n end\\n end\",\n \"def change_subscription\\n\\tbounce_free_account\\n\\n\\t@subs = current_user.subscriptions \\n\\tif @subs && !@subs.active.blank?\\n\\t@s = @subs.active.first\\n\\t@s_year = @s.created_at + 365.days\\n\\t#@c = Stripe::Customer.retrieve(@s.customer_id)\\n\\telse #this should not happen - be careful to make sure every customer has a subscription; or at least if they have a \\n\\t\\t# cancel subsciption link, there is an active subscription to be canceled. \\n\\tredirect_to current_user, notice: 'You have no active subscriptions.'\\n\\t # return false is this line needed to end the action?\\n\\tend \\n\\n\\t# users first (oldest) subscription, for displaying free trial information\\n\\t@firstsub = @subs.first\\n\\t@firstsub_end = @firstsub.created_at + 14.days\\n\\n\\t#@plan = Plan.find_by_name(@s.plan_id) #this would be better for easily retrieving other associated plan info; but could have just used @s.plan_id for the plan name\\n\\tif !@s.my_plan_id.nil? # so that @plan isn't nil, which would cause problems in the view \\n\\t@plan = Plan.find_by_my_plan_id(@s.my_plan_id) # NOTE THAT @PLAN IS THE PLANOBJECT\\n\\t\\t\\t\\t#see if active subscription has a coupon associated with it\\n\\t\\t\\t\\tif !@s.coupon.nil? && Coupon.find_by_name(@s.coupon)\\n\\t\\t\\t\\t\\t@coupon = Coupon.find_by_name(@s.coupon)\\n\\t\\t\\t\\t\\t@code = @coupon.name\\n\\t\\t\\t\\t\\t@new_price = @plan.monthly_cost_cents * (100 - @coupon.percent_off)/100\\n\\t\\t\\t\\telse\\n\\t\\t\\t\\t\\t@coupon = nil \\n\\t\\t\\t\\t\\t@code = nil\\n\\t\\t\\t\\t\\t@new_price = nil \\n\\t\\t\\t\\tend \\n\\telse\\n\\t\\t@plan = nil\\n\\t\\t@coupon = nil \\n\\t\\t@code = nil \\n\\t @new_price = nil \\n\\tend \\n\\nend\",\n \"def create\\n\\t\\t#Prepare the models\\n\\t\\t@subscription = Subscription.new(\\n\\t\\t\\tcampaign_id: @subscribed.active_campaign.id,\\n\\t\\t\\tshipping_country: params[:subscription][:shipping_country],\\n\\t\\t\\tget_reward: params[:subscription][:get_reward],\\n\\t\\t\\tfunding_type: params[:subscription][:funding_type],\\n\\t\\t\\tamount: params[:subscription][:amount],\\n\\t\\t\\tsubscriber_id: @subscriber.id,\\n\\t\\t\\tsubscribed_id: @subscribed.id,\\n\\t\\t\\tcurrency: 'usd',\\n\\t\\t\\tcampaign_funding_type: @subscribed.active_campaign.funding_type\\n\\t\\t)\\n\\t\\tif params[:subscription][:majorpost_id]\\n\\t\\t\\t@subscription.majorpost_id = params[:subscription][:majorpost_id]\\n\\t\\tend\\n\\t\\tif params[:subscription][:upper_limit]\\n\\t\\t\\t@subscription.upper_limit = params[:subscription][:upper_limit]\\n\\t\\tend\\n\\t\\tif params[:subscription][:cards_attributes]\\n\\t\\t\\tadd_card\\n\\t\\tend\\n\\t\\t#Charge if charge\\n\\t\\tif @subscription.funding_type == 'one_time'\\n\\t\\t\\t#Charge the card now\\n\\t\\t\\tsubscribe_through_stripe\\n\\t\\telse\\n\\t\\t\\t#Do not charge the card\\n\\t\\t\\tsubscription_post_payment\\n\\t\\tend\\n\\trescue Stripe::CardError => e\\n\\t\\t# Since it's a decline, Stripe::CardError will be caught\\n\\t\\tbody = e.json_body\\n\\t\\terr = body[:error]\\n\\n\\t\\tputs \\\"Status is: #{e.http_status}\\\"\\n\\t\\tputs \\\"Type is: #{err[:type]}\\\"\\n\\t\\tputs \\\"Code is: #{err[:code]}\\\"\\n\\t\\t# param is '' in this case\\n\\t\\tputs \\\"Param is: #{err[:param]}\\\"\\n\\t\\tputs \\\"Message is: #{err[:message]}\\\"\\n\\t\\t#Show to the user\\n\\t\\tflash[:error] = \\\"#{err[:message]}\\\"\\n\\t\\tredirect_to how_i_pay_user_studio_wallets_path(@subscriber.username)\\n\\trescue Stripe::RateLimitError => e\\n\\t\\t# Too many requests made to the API too quickly\\n\\t\\tflash[:error] = t('errors.messages.too_many_requests')\\n\\t\\tredirect_to profile_url_path(@subscribed.username)\\n\\trescue Stripe::InvalidRequestError => e\\n\\t\\t# Invalid parameters were supplied to Stripe's API\\n\\t\\tflash[:error] = t('errors.messages.not_saved')\\n\\t\\tredirect_to profile_url_path(@subscribed.username)\\n\\trescue Stripe::AuthenticationError => e\\n\\t\\t# Authentication with Stripe's API failed\\n\\t\\t# (maybe you changed API keys recently)\\n\\t\\tflash[:error] = t('errors.messages.not_saved')\\n\\t\\tredirect_to profile_url_path(@subscribed.username)\\n\\trescue Stripe::APIConnectionError => e\\n\\t\\t# Network communication with Stripe failed\\n\\t\\tflash[:error] = t('errors.messages.not_saved')\\n\\t\\tredirect_to profile_url_path(@subscribed.username)\\n\\trescue Stripe::StripeError => e\\n\\t\\t# Display a very generic error to the user, and maybe send\\n\\t\\t# yourself an email\\n\\t\\tflash[:error] = t('errors.messages.not_saved')\\n\\t\\tredirect_to profile_url_path(@subscribed.username)\\n\\trescue \\n\\t\\t# General rescue\\n\\t\\tflash[:error] = t('errors.messages.not_saved')\\n\\t\\tredirect_to profile_url_path(@subscribed.username)\\n\\tend\",\n \"def create\\n @cart = Cart.find(params[:cart_id].to_i)\\n token = params[:stripeToken]\\n #payment old changes\\n # if @cart.instant_total_price_cents != 0\\n # begin\\n # puts \\\"Processing payment\\\"\\n # if params[:payment_method].blank? or params[:payment_method] == \\\"card\\\"\\n # sub = Subscription.find_by(user_id: current_user.id, stripe_customer_token: token)\\n # if sub.nil?\\n # last4 = params[:last4]\\n # exp_year = params[:exp_year]\\n # exp_month = params[:exp_month]\\n # subscription = Subscription.new(stripe_customer_token: token, user_id: current_user.id,last4: last4,exp_year: exp_year,exp_month: exp_month)\\n # new_sub = Order.save_with_payment(params[:email],token,current_user.name,@cart.instant_total_price_cents)\\n # subscription.stripe_user_id = new_sub\\n # subscription.save\\n # else\\n # Order.payment_only(current_user.name,@cart.instant_total_price_cents,sub.stripe_user_id)\\n # end\\n # else\\n # account = current_user.bank_accounts.first\\n # if account.stripe_user_id.nil?\\n # account.stripe_user_id = Order.save_with_payment(params[:email],account.stripe_customer_token,current_user.name,@cart.instant_total_price_cents)\\n # account.save\\n # else\\n # Order.payment_only(current_user.name,@cart.instant_total_price_cents,account.stripe_user_id)\\n # end\\n # end\\n # rescue => e\\n # puts \\\"Payment failed\\\"\\n # puts e\\n # ExceptionNotifier.notify_exception e\\n # render json: {\\\"error\\\":\\\"Payment was unsuccessful\\\"}, status: :unprocessable_entity and return\\n # end\\n # end\\n\\n address_type = params[:address_type].nil? ? \\\"user\\\" : params[:address_type]\\n if params[:old_address_id].blank?\\n current_user.addresses.create!(first_name: params[:first_name], last_name: params[:last_name], mobile: params[:mobile], line_1: params[:line_1], line_2: params[:line_2], line_3: params[:line_3], city: params[:city], state: params[:state], address_type: address_type, pincode: params[:pincode].to_i, name: \\\"shipping\\\")\\n else\\n puts \\\"Address found. Updating it\\\"\\n address = Address.find params[:old_address_id]\\n address.updated_at = DateTime.now\\n address.save\\n end\\n\\n CartItem.where(cart: @cart).group_by(&:provider).each do |provider,cart_items_all|\\n cart_items_instant = cart_items_all.select {|ci| ci.product.storefront_option == true}\\n cart_items_invoice = cart_items_all.select {|ci| ci.product.storefront_option == false}\\n [cart_items_instant,cart_items_invoice].each do |cart_items|\\n if cart_items.length > 0\\n @order = Order.new\\n @order.first_name = params[:first_name]\\n @order.last_name = params[:last_name]\\n @order.mobile_number = params[:mobile_number]\\n @order.email = params[:email]\\n @order.order_date = DateTime.now\\n @order.total_price_cents = 0\\n @order.user = current_user\\n @order.save!\\n # if cart_items.first.product.storefront_option\\n # @order.status = :unpaid\\n # @order.save!\\n # end\\n\\n cart_items.each do |cart_item|\\n @order.total_price_cents += cart_item.price_cents * cart_item.quantity\\n order_item = @order.order_items.new(price_cents: cart_item.price_cents, product: cart_item.product, quantity: cart_item.quantity,provider: cart_item.provider)\\n cart_item.destroy\\n end\\n\\n @order.recalcuate_order_total\\n @order.addresses.create!(first_name: params[:first_name], last_name: params[:last_name], mobile: params[:mobile], line_1: params[:line_1], line_2: params[:line_2], line_3: params[:line_3], city: params[:city], state: params[:state], address_type: address_type, pincode: params[:pincode].to_i, name: \\\"shipping\\\")\\n SupplierMailer.order_email(@order).deliver_later\\n end\\n end\\n end\\n\\n respond_to do |format|\\n format.html { render json: @order.id, status: :ok }\\n format.json { render json: @order.id, status: :ok}\\n end\\n end\"\n]"},"negative_scores":{"kind":"list like","value":["0.8166746","0.7665318","0.7586758","0.75683373","0.75390834","0.7518053","0.74716955","0.7392793","0.7294338","0.72191966","0.72115946","0.7128112","0.712692","0.70379615","0.7009483","0.69722223","0.69667715","0.69576347","0.68969506","0.6877924","0.68738455","0.6838514","0.6808635","0.68085533","0.6794398","0.67791283","0.6754727","0.6663394","0.6660503","0.66594195","0.66379404","0.6633256","0.6625867","0.6624655","0.66234833","0.66179913","0.6612186","0.66033965","0.660339","0.65842515","0.6571633","0.6565765","0.6551454","0.6551","0.65377724","0.6517199","0.65123665","0.65093195","0.64928615","0.6486056","0.6476452","0.64489985","0.64424413","0.64421034","0.6438776","0.6414931","0.6403593","0.63806343","0.6379774","0.6367634","0.6363081","0.6326799","0.6320511","0.63159084","0.6310064","0.6306572","0.6304497","0.629161","0.6284527","0.6279491","0.6274226","0.6261975","0.6256208","0.6247529","0.62385696","0.6223252","0.6216851","0.62160146","0.62079746","0.6206411","0.620528","0.6201498","0.62009394","0.61999726","0.6190837","0.6184518","0.6182206","0.6181689","0.61795604","0.6172749","0.616085","0.6141751","0.61415803","0.61397487","0.6138544","0.6137542","0.6135","0.61321133","0.61263144","0.61133295"],"string":"[\n \"0.8166746\",\n \"0.7665318\",\n \"0.7586758\",\n \"0.75683373\",\n \"0.75390834\",\n \"0.7518053\",\n \"0.74716955\",\n \"0.7392793\",\n \"0.7294338\",\n \"0.72191966\",\n \"0.72115946\",\n \"0.7128112\",\n \"0.712692\",\n \"0.70379615\",\n \"0.7009483\",\n \"0.69722223\",\n \"0.69667715\",\n \"0.69576347\",\n \"0.68969506\",\n \"0.6877924\",\n \"0.68738455\",\n \"0.6838514\",\n \"0.6808635\",\n \"0.68085533\",\n \"0.6794398\",\n \"0.67791283\",\n \"0.6754727\",\n \"0.6663394\",\n \"0.6660503\",\n \"0.66594195\",\n \"0.66379404\",\n \"0.6633256\",\n \"0.6625867\",\n \"0.6624655\",\n \"0.66234833\",\n \"0.66179913\",\n \"0.6612186\",\n \"0.66033965\",\n \"0.660339\",\n \"0.65842515\",\n \"0.6571633\",\n \"0.6565765\",\n \"0.6551454\",\n \"0.6551\",\n \"0.65377724\",\n \"0.6517199\",\n \"0.65123665\",\n \"0.65093195\",\n \"0.64928615\",\n \"0.6486056\",\n \"0.6476452\",\n \"0.64489985\",\n \"0.64424413\",\n \"0.64421034\",\n \"0.6438776\",\n \"0.6414931\",\n \"0.6403593\",\n \"0.63806343\",\n \"0.6379774\",\n \"0.6367634\",\n \"0.6363081\",\n \"0.6326799\",\n \"0.6320511\",\n \"0.63159084\",\n \"0.6310064\",\n \"0.6306572\",\n \"0.6304497\",\n \"0.629161\",\n \"0.6284527\",\n \"0.6279491\",\n \"0.6274226\",\n \"0.6261975\",\n \"0.6256208\",\n \"0.6247529\",\n \"0.62385696\",\n \"0.6223252\",\n \"0.6216851\",\n \"0.62160146\",\n \"0.62079746\",\n \"0.6206411\",\n \"0.620528\",\n \"0.6201498\",\n \"0.62009394\",\n \"0.61999726\",\n \"0.6190837\",\n \"0.6184518\",\n \"0.6182206\",\n \"0.6181689\",\n \"0.61795604\",\n \"0.6172749\",\n \"0.616085\",\n \"0.6141751\",\n \"0.61415803\",\n \"0.61397487\",\n \"0.6138544\",\n \"0.6137542\",\n \"0.6135\",\n \"0.61321133\",\n \"0.61263144\",\n \"0.61133295\"\n]"},"document_score":{"kind":"string","value":"0.7624558"},"document_rank":{"kind":"string","value":"2"}}},{"rowIdx":123,"cells":{"query":{"kind":"string","value":"The default security delegates to ActiveRecordPermissions. You may override the method to customize."},"document":{"kind":"string","value":"def batch_create_authorized?(record = nil)\n authorized_for?(:crud_type => :create)\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n if current_user.admin?\n # Role management\n # don't allow :destroy, :edit, :create\n # - destroy adds a 'delete' button that\n # - could be clicked accidentally\n # - would be very infrequently used (if ever)\n # - implications of edit are unclear for associated actions\n # - create is meaningless without associating actions which happens in code.\n can [:read, :add_user, :remove_user], Role\n end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end","def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role if current_user.admin?\n\n can [:fa_overview], ActiveFedora::Base\n can [:advanced], ActiveFedora::Base\n can [:streets], ActiveFedora::Base\n can [:pdf_page], ActiveFedora::Base\n can [:pdf_page_metadata], ActiveFedora::Base\n can [:bookreader], ActiveFedora::Base\n can [:imageviewer], ActiveFedora::Base\n can [:streetsviewer], ActiveFedora::Base\n can [:fa_series], ActiveFedora::Base\n can [:audio_transcriptonly], ActiveFedora::Base\n can [:video_transcriptonly], ActiveFedora::Base\n end","def custom_permissions\n discover_permissions\n export_sets_permissions\n batches_permissions\n preservation_events_permissions\n end","def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end","def custom_permissions\n if current_user.admin?\n can :manage, :all\n end\n end","def custom_permissions\n can [:file_status, :stage, :unstage], FileSet\n\n if current_user.ingest_from_external_sources?\n end\n\n if current_user.manage_users?\n can [:show, :add_user, :remove_user, :index], Role\n end\n\n if current_user.manage_roles?\n can [:create, :show, :index, :edit, :update, :destroy], Role\n end\n\n if current_user.run_fixity_checks?\n can [:fixity], FileSet\n end\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end","def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n # Admin user can create works of all work types\n can :create, curation_concerns_models\n end\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end","def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n end\n\n# if current_user.contentadmin?\n# can [:create, :destroy], GwWork\n# can [:create, :destroy], GwEtd\n# end\n end","def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\nif current_user.admin?\n\t can [:create, :show, :add_user, :remove_user, :index], Role\n\t end\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n\n\n\n end","def custom_permissions\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n can [:create], Collection\n can [:discover], Hydra::AccessControls::Embargo\n can [:discover], Hydra::AccessControls::Lease\n can [:create], [ CurationConcerns.config.curation_concerns ]\n can [:destroy], ActiveFedora::Base\n can [:permissions], [ CurationConcerns.config.curation_concerns ]\n end\n\n # Limits deleting objects to a the admin user\n #\n #if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n #end\n\n if current_user.has_role?('collection.manager')\n # can [:create, :show, :index, :edit, :update, :destroy], Collection\n can [:create], Collection\n end\n\n if current_user.has_role?('collection.depositor') or current_user.has_group_role?('collection.depositor')\n # can [:create, :show, :index, :edit, :update, :destroy], [ CurationConcerns.configuration.curation_concerns ]\n can [:create], [ CurationConcerns.config.curation_concerns ]\n # can [:show], Collection\n end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end","def custom_permissions\n alias_action :show, :manifest, to: :read\n alias_action :color_pdf, :pdf, :edit, :browse_everything_files, :structure, :file_manager, to: :modify\n roles.each do |role|\n send \"#{role}_permissions\" if current_user.send \"#{role}?\"\n end\n end","def custom_permissions\n alias_action :show, :manifest, to: :read\n alias_action :color_pdf, :pdf, :edit, :browse_everything_files, :structure, :file_manager, to: :modify\n roles.each do |role|\n send \"#{role}_permissions\" if current_user.send \"#{role}?\"\n end\n end","def custom_permissions # rubocop:disable Metrics/CyclomaticComplexity\n can :read, ApplicationPresenter, &:can_read?\n can :read, UsersPresenter, &:can_read?\n can :read, UserPresenter, &:can_read?\n can :read, RolesPresenter, &:can_read?\n can :read, RolePresenter, &:can_read?\n\n can :read, Press\n\n grant_press_analyst_abiltites if press_analyst?\n grant_press_editor_abilities if press_editor?\n grant_press_admin_abilities if platform_admin? || press_admin?\n grant_platform_admin_abilities if platform_admin?\n end","def load_permissions\n authorize! :manage, :all\n end","def custom_permissions\n #Collection Manager Permissions\n #Higher power than edit user...[Dont want edit users to be able to DELETE a COLLECTION??, (Delete a DO?)]\n if current_user.applicable_policy?(SETTING_POLICY_COLLECTION_MANAGER)\n #Marked as being able to :manage_collection\n can :manage_collection_flag, :all\n can :create, [DRI::Batch, DRI::GenericFile]\n end\n\n\n #Admin Permissions\n if current_user.applicable_policy?(SETTING_POLICY_ADMIN)\n can :admin_flag, :all\n #Disabled for now..\n can :manage, :all\n end\n\n #Create_do flag (alias for :edit collection)\n can :create_do, String do |pid|\n test_create(pid)\n end\n\n can :create_do, DRI::Batch do |collection|\n test_create(collection)\n end\n end","def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n\n if user_groups.include? ['all_project_writers']\n can [:create], PulStore::Base\n can [:create], PulStore::Lae::Box\n can [:create], PulStore::Lae::Folder\n can [:create], Pulstore::Lae::HardDrive\n end\n\n if user_groups.include? ['lae_project_writers']\n can [:create], PulStore::Lae::Box\n can [:create], PulStore::Lae::Folder\n can [:create], Pulstore::Lae::HardDrive\n end \n\n if user_groups.include? ['all_project_writers']\n can [:destroy], PulStore::Base\n end\n\n if user_groups.include? ['lae_project_readers', 'all_project_readers' ]\n can [:show], PulStore::Base\n end\n end","def custom_permissions\n if admin?\n can [:confirm_delete], ActiveFedora::Base\n can [:allow_downloads, :prevent_downloads], AdminSet\n\n can :manage, Spotlight::HomePage\n can :manage, Spotlight::Exhibit\n end\n\n can :read, Spotlight::HomePage\n can :read, Spotlight::Exhibit\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end","def paranoid_permissions\n true\n end","def custom_permissions\n if user_groups.include?(\"admin\")\n can :manage, :all\n end\n end","def standard_authorized_user_rights\n public_access + protected_access \n end","def custom_permissions\n can [:create], Account\n end","def custom_permissions\n can [:create], Account\n end","def load_permissions \n @current_permissions = current_user.role.permissions.collect{|i| [i.subject_class, i.action]} \n end","def set_permissions\n self.permissions ||= \"guest\"\n end","def smart?; self.permission_level = 2; end","def permission_set\n if attributes[\"InheritedSecurity\"]\n supersite.permission_set\n else\n PermissionSet.new(self)\n end\n end","def write_permission_check(*args)\n # Don't prevent writes if creating a new object (anyone should be able to do this)\n return unless self.exist?\n\n if LinkedData.settings.enable_security\n user = nil\n options_hash = {}\n args.each {|e| options_hash.merge!(e) if e.is_a?(Hash)}\n user = options_hash[:user]\n\n # Allow a passed option to short-cut the security process\n return if options_hash[:override_security]\n\n user ||= Thread.current[:remote_user]\n\n reference_object = self\n\n # If we have a modified object, we should do the security check\n # on the original. This allows a user to change the ownsership of\n # an object without having to add the owner and have the new owner\n # remove the original owner.\n reference_object = self.class.find(self.id).first if self.modified?\n\n # Allow everyone to write\n return if reference_object.access_for_all?\n\n # Load attributes needed by security\n if reference_object.access_control_load?\n # Only load ones that aren't loaded so we don't overwrite changes\n not_loaded = []\n reference_object.access_control_load_attrs.each do |attr|\n not_loaded << attr unless reference_object.loaded_attributes.include?(attr)\n end\n reference_object.bring(*not_loaded) unless not_loaded.empty?\n end\n\n writable = reference_object.writable?(user)\n raise LinkedData::Security::WriteAccessDeniedError, \"Write access denied: #{reference_object.id}\" unless writable\n end\n end","def user_permissions\n if user_signed_in? && (current_user.is_logistics? || current_user.is_clerical? || current_user.is_vendor? || current_user.is_customer?)\n authorize! :edit, Element\n end\n end","def load_permissions\n @current_permissions = current_user.role.permissions.collect{|i| [i.subject_class, i.action]}\n end","def load_permissions\n \n @current_permissions = current_user.role.permissions.collect{|i| [i.subject_class, i.action]}\n end","def has_permission?\n return true if administrator?\n \n # Load the Model based on the controller name\n klass = self.controller_name.classify.constantize\n \n # Load the possible parent requested\n @parents = (klass.has_parent?) ? get_parents_from_request_params(klass, params) : nil\n \n # Load the resource requested\n if params[:id]\n if [\"index\", \"destroy\", \"update\"].include?(params[:action]) && klass.respond_to?(:in_set)\n @resource = klass.in_set(params[:id])\n @resource = @resource.first if @resource.size == 1\n else\n @resource = klass.find(params[:id])\n end\n end\n \n # Let's let the Model decide what is acceptable\n # NOTE: It is still the concrete controller's job to filter inaccessible resources (accessed via the index)!\n # This presumably happens in the with_parent named scope\n \n authorized = case params[:action]\n when \"edit\", \"update\"\n if !@resource.is_a?(Array)\n return @resource.updatable_by?(current_user, @parents) # this is 'returned' to authorized\n end\n \n verify_set_accessablility(@resource, :updatable_by?) do |unauthorized_ids|\n permission_denied(\n :status => :conflict,\n :message => \"#{unauthorized_ids.to_a.join(',')} is not available for update.\"\n ) if unauthorized_ids.size > 0\n end\n true # if it gets past verification, authorized is true\n \n when \"destroy\" \n if !@resource.is_a?(Array)\n return @resource.deletable_by?(current_user, @parents)\n end\n \n verify_set_accessablility(@resource, :deletable_by?) do |unauthorized_ids|\n permission_denied(\n :status => :conflict,\n :message => \"#{unauthorized_ids.to_a.join(',')} is not available for deletion.\"\n ) if unauthorized_ids.size > 0\n end\n true # if it gets past verification, authorized is true\n \n when \"index\" then klass.indexable_by?(current_user, @parents)\n when \"new\", \"create\" then klass.creatable_by?(current_user, @parents)\n when \"show\" then @resource.readable_by?(current_user, @parents)\n else check_non_restful_route(current_user, klass, @resource, @parents)\n end\n \n permission_denied unless authorized\n \n #rescue NoMethodError => e\n # Misconfiguration: A RESTful_ACL specific method is missing.\n #raise_error(klass, e)\n #rescue\n # Failsafe: If any funny business is going on, log and redirect\n #routing_error\n #end\n end","def permits_write_access_for(user)\n end","def set_default_permissions!\n # Always allow to read the id\n let :read, :id\n # These shouldn't change after the first save.\n let :write, [ :id, :created_at ], :if => :new?\n # These can always change.\n let :write, :updated_at\n end","def permitted?(model_name, requested_flags = 0)\n return false if self.kind != Kind::ROLE\n return true if admin?\n\n p = self.model_permissions.find_by_model(model_name)\n if requested_flags == 0\n p\n else\n p && p.permitted?(requested_flags)\n end\n end","def my_permissions\n @my_permissions ||= self.roles.map {|r| r.permissions.map {|p| p.name}}.flatten.freeze\n end","def permissions_policy(&block); end","def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n\n # TODO: This area looks like it needs to be refactored.\n\n if current_user.admin?\n editor_abilities\n upload_abilities\n publish_abilities\n roles_abilities\n hard_delete_abilities\n import_admin_abilities\n user_abilities\n group_abilities\n can [:create, :destroy, :update], FeaturedWork\n can [:manage], Hydra::Admin::Collection\n\n can :create, TinymceAsset\n can [:create, :update], ContentBlock\n can :read, ContentBlock\n can :characterize, GenericFile\n end\n\n\n if current_user.manager?\n upload_abilities\n publish_abilities\n roles_abilities\n import_user_abilities\n can [:manage], Hydra::Admin::Collection do |admin_set|\n # Can manage admin sets within their assigned unit.\n current_user.osul_groups.include? admin_set.unit_group\n end\n can [:manage], Osul::Group do |group|\n # Can manage the groups the user is in or the groups of the units a user is assigned to.\n current_user.osul_groups.include? group or current_user.osul_groups.include? group.unit\n end\n can [:create], Osul::Group\n can [:create, :destroy, :update], FeaturedWork\n end\n\n if current_user.data_entry?\n upload_abilities\n publish_abilities\n no_admin_set_abilities\n end\n\n if current_user.data_entry_student?\n upload_abilities\n no_admin_set_abilities\n end\n\n unless current_user.public?\n can :view_full, GenericFile\n end\n\n if current_user.role.nil?\n no_file_abilities\n no_admin_set_abilities\n end\n end","def build_permissions(perms, other)\n perms.permits! :read\n perms.permits! :write if self == other\n end","def permissions\n @resource_permissions\n end","def admin_permissions\n can [:manage], :all\n end","def admin_permissions\n can [:manage], :all\n end","def mass_assignment_authorizer(role = :default)\n if accessible == :all\n self.class.protected_attributes\n else\n super + (accessible || [])\n end\n end","def set_perms\n self.perms = Access.for_user(self)\n end","def permissions\n attribute_prop(5)\n end","def deny_all_access\n @permissions = 0\n end","def user_permission\n has_controller_permission?('user')\n end","def permits_read_acccess_for(user)\n end","def enforce_delete_permissions\n enforce_edit_permissions\n end","def permission\n Ricer::Irc::Permission.by_permission(self.permissions, authenticated?)\n end","def setable_permissions\n setable_permissions = Erp::AccessControl.permissions - Erp::AccessControl.public_permissions\n setable_permissions -= Erp::AccessControl.members_only_permissions if builtin == BUILTIN_NON_MEMBER\n setable_permissions -= Erp::AccessControl.loggedin_only_permissions if builtin == BUILTIN_ANONYMOUS\n setable_permissions\n end","def project_permissions\n user.project_permissions(rule.project)\n end","def standard_authorized_user_rights\n Lockdown::System.public_access + Lockdown::System.protected_access \n end","def permissions = {}","def make_permission_protected(name)\n permission(name).is_protected\n end","def permissions( force_reload = false )\n\n # Two levels of joins here, so can't use has_many :through\n if force_reload\n @permissions = nil \n @permissions_by_class_and_op = {}\n end\n\n cond_str = 'role_id in ' + self.class.role_assigned_cond( '?' )\n if !instance_variable_defined?(\"@permissions\") || @permissions.nil?\n @permissions ||= Permission.where([cond_str, self]).to_a\n end\n\n return @permissions\n end","def define_global_privileges\n can :read, Project, public_can_view?: true\n can :index, Project\n can :read, Group\n end","def permissions\n User.do_find_permissions session_id: kb_session_id\n end","def role\n permission_type\n end","def permitted_to! (privilege, options = {} )\n options = {\n :user => Authorization.current_user,\n :object => self\n }.merge(options)\n\nlogger.debug \"Checking for: #{self.class.name}\"\n\n Authorization::Engine.instance.permit!(privilege,\n {:user => options[:user],\n :object => options[:object]})\n end","def can_change( record, type = '*' )\n name, type = get_name_and_type_from_param( record, type )\n self.permissions['allowed'] << [ name, type ]\n end","def access_rights_for_permission(perm)\n sym = Lockdown.get_symbol(perm)\n\n permissions[sym]\n rescue \n raise SecurityError, \"Permission requested is not defined: #{sym}\"\n end","def permissions\n Roles.type_map[role_type].permissions\n end","def require_other_permission\n respond_to_permission_error\n end","def permissions=(value)\n @permissions = value\n end","def can?(permission)\n permissions.include?(permission.to_s) || super_admin?\n end","def add_user_permission(u)\n\t\t\n\tend","def permission_for (collection)\n permission = Permission.find_or_create_by_user_id_and_collection_id(self.id, collection.id)\n end","def apply_superuser_permissions(permission_types)\n []\n end","def model_actions(perms)\n ActiveRecord::Base.descendants.each do |m|\n next unless m.respond_to?(:permission_definition)\n next if m.permission_definition.nil? || m.permission_definition == {}\n perms << PermissionsGenerator.new(m)\n end\n return perms\nend","def permissions\n Rails.cache.fetch(\"permissions_#{self.id}\", expire_in: 1.month) do\n self.roles.map(&:permissions).flatten\n end\n end","def overall_permissions(thing)\n global_permissions.merge!(permissions_for(thing))\n end","def required_permission\n #\n # return the permission record if we have the Permission model\n #\n @required_permission ||= defined?(Permission) ? wulin_permits_required_permission : OpenStruct.new(name: [controller_name, action_name].join(\"#\"))\n end","def set_acl_statement\n super\n end","def custom_permissions\n\n campus = \"bakersfield\" if current_user.email.include?(\"bakersfield.edu\")\n campus = \"chancellor\" if current_user.email.include?(\"calstate.edu\")\n campus = \"channel\" if current_user.email.include?(\"ci.edu\")\n campus = \"chico\" if current_user.email.include?(\"chico.edu\")\n campus = \"dominguez\" if current_user.email.include?(\"dh.edu\")\n campus = \"eastbay\" if current_user.email.include?(\"eb.edu\")\n campus = \"fresno\" if current_user.email.include?(\"fresno.edu\")\n campus = \"fullerton\" if current_user.email.include?(\"fullerton.edu\")\n campus = \"humboldt\" if current_user.email.include?(\"humboldt.edu\")\n campus = \"longbeach\" if current_user.email.include?(\"lb.edu\")\n campus = \"losangeles\" if current_user.email.include?(\"la.edu\")\n campus = \"maritime\" if current_user.email.include?(\"maritime.edu\")\n campus = \"mlml\" if current_user.email.include?(\"mlml.edu\")\n campus = \"northridge\" if current_user.email.include?(\"northridge.edu\")\n campus = \"pomona\" if current_user.email.include?(\"bronco.edu\")\n campus = \"sacramento\" if current_user.email.include?(\"sacramento.edu\")\n campus = \"sanfrancisco\" if current_user.email.include?(\"sf.edu\")\n campus = \"sanmarcos\" if current_user.email.include?(\"sanmarcos.edu\")\n campus = \"sonoma\" if current_user.email.include?(\"sonoma.edu\")\n campus = \"stanislaus\" if current_user.email.include?(\"stanislaus.edu\")\n\n user_groups.push(campus)\n\n # admin\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end","def permission_mapping\n super.merge(\n {\n 'index_role_screen' => 'index',\n 'index_role_field' => 'index',\n 'index_user_screen' => 'index',\n 'index_user_field' => 'index',\n 'fetch_row' => 'index'\n }\n )\n end","def readonly_user\n super\n end","def custom_permissions_read(_notebook, _user, _use_admin=false)\n true\n end","def user_permissions\n if current_user.id == params[:id].to_i\n @user = User.find(params[:id])\n else\n flash[:danger] = 'Unauthorized action.'\n redirect_to edit_user_path(current_user) \n end\n end","def permitted?; end","def permission_proxy\n @authorizable_permission_proxy ||= Authorizable::Proxy.new(self)\n end","def default(user)\n puts \"Rights: default\"\n # can :read, :all # doesn't do that ! We will authorize each actions\n can :read, [Doc, Gallery, Image, Place]\n can :manage, User, :id => user.id\n cannot :destroy, User, :id => user.id\n\n can :read, ForumCategory, [\"role <= ?\", user.role] do |forum_category|\n forum_category.role <= user.role\n end\n\n can :read, Forum, [\"role <= ?\", user.role] do |forum|\n if (forum.role <= user.role)\n can :read, Topic\n can :read, Message\n true\n else\n false\n end\n end\n\n # can read users profiles\n can :read, User\n\n # special actions\n can :mark_all_read, Forum\n end","def authorize_admin!\n authorize! :manage, :all\n end","def enforce_access_controls(opts={})\n controller_action = params[:action].to_s\n delegate_method = \"enforce_#{controller_action}_permissions\"\n if self.respond_to?(delegate_method.to_sym, true)\n self.send(delegate_method.to_sym)\n else\n true\n end\n end","def permissions\n read_attribute(:permissions) || {}\n end","def authorize (permission_name)\n self.allowances.detect {|a| a.permission.name == permission_name.to_s}\n end","def check_permissions\n authorize! :create, Employee\n end","def add_permissions\n [\"License\", \"Archive\", \"Contract\"].each do |doc|\n klass = doc.constantize\n doc_id = \"#{doc.downcase}_id\".to_sym\n permissions = self.send(\"#{doc.downcase.pluralize.singularize}_permissions\".to_sym)\n klass.find(:all).each { |record|\n permissions.create doc_id => record.id, :ycrole_id => self.id,\n :can_read => false, :can_write => false\n }\n end\n end","def effective_permissions\n source = self\n\n while source.inherit && source.forum.parent\n source = source.forum.parent.forum_permissions.find_by(group: group)\n end\n\n source = group if source.inherit\n\n source\n end","def set_access(*args)\n options = args.extract_options!\n options[:object] ||= Array(@_controller).first.to_s.singularize.to_sym if @_controller.present?\n permissions.add(*args, options)\n end","def restore_permissions; end","def restore_permissions; end","def effective_roles_authorization_level(controller, role, resource)\n authorization_method = EffectiveResources.authorization_method\n\n raise('expected an authorization method') unless (authorization_method.respond_to?(:call) || authorization_method.kind_of?(Symbol))\n return :unknown unless (controller.current_user rescue nil).respond_to?(:roles=)\n\n # Store the current ability (cancan support) and roles\n current_ability = controller.instance_variable_get(:@current_ability)\n current_user = controller.instance_variable_get(:@current_user)\n current_user_roles = controller.current_user.roles\n\n # Set up the user, so the check is done with the desired permission level\n controller.instance_variable_set(:@current_ability, nil)\n\n level = nil\n\n case role\n when :signed_in\n controller.current_user.roles = []\n when :public\n controller.instance_variable_set(:@current_user, nil)\n\n if defined?(EffectiveLogging)\n EffectiveLogging.supressed { (controller.request.env['warden'].set_user(false) rescue nil) }\n else\n (controller.request.env['warden'].set_user(false) rescue nil)\n end\n else\n controller.current_user.roles = [role]\n end\n\n # Find the actual authorization level\n level = effective_roles_item_authorization_level(controller, role, resource, authorization_method)\n\n # Restore the existing current_user stuff\n if role == :public\n ActiveRecord::Base.transaction do\n if defined?(EffectiveLogging)\n EffectiveLogging.supressed { (controller.request.env['warden'].set_user(current_user) rescue nil) }\n else\n (controller.request.env['warden'].set_user(current_user) rescue nil)\n end\n\n raise ActiveRecord::Rollback\n end\n end\n\n controller.instance_variable_set(:@current_ability, current_ability)\n controller.instance_variable_set(:@current_user, current_user)\n controller.current_user.roles = current_user_roles\n\n level\n end","def can?(*args)\n permissions.can?(*args)\n end","def authorize_inherited_resource!\n authorize! :show, parent if parent?\n authorize! authorizable_action, authorize_resource? ? resource : resource_class\n end","def check_write_access(obj)\n return obj unless LinkedData.settings.enable_security\n if obj.is_a?(LinkedData::Models::Base) && obj.write_restricted?\n writable = obj.writable?(env[\"REMOTE_USER\"])\n error 403, \"Access denied for this resource\" unless writable\n end\n end","def filter_access!\n treat_as get_current_role\n end","def can_do_member_scoped_actions\n can :show, :all\n can :edit, :all\n can :destroy, :all\n can :history, :all\n can :show_in_app, :all\n can :clone, :all\n # can :nested_set, :all\n can :nestable, :all\n can :change_state, :all\n end","def role_permissions=(value)\n @role_permissions = value\n end","def permissions\n return @permissions\n end","def build_permissions(perms, other)\n perms.permits! :read\n\n if self == other\n perms.permits! :write\n elsif other.admin?\n perms.permits! :write\n end\n end","def everyone(read, write)\n apply(PUBLIC, read, write)\n permissions[PUBLIC]\n end"],"string":"[\n \"def custom_permissions\\n # Limits deleting objects to a the admin user\\n #\\n # if current_user.admin?\\n # can [:destroy], ActiveFedora::Base\\n # end\\n\\n if current_user.admin?\\n # Role management\\n # don't allow :destroy, :edit, :create\\n # - destroy adds a 'delete' button that\\n # - could be clicked accidentally\\n # - would be very infrequently used (if ever)\\n # - implications of edit are unclear for associated actions\\n # - create is meaningless without associating actions which happens in code.\\n can [:read, :add_user, :remove_user], Role\\n end\\n\\n # Limits creating new objects to a specific group\\n #\\n # if user_groups.include? 'special_group'\\n # can [:create], ActiveFedora::Base\\n # end\\n end\",\n \"def custom_permissions\\n # Limits deleting objects to a the admin user\\n #\\n # if current_user.admin?\\n # can [:destroy], ActiveFedora::Base\\n # end\\n\\n # Limits creating new objects to a specific group\\n #\\n # if user_groups.include? 'special_group'\\n # can [:create], ActiveFedora::Base\\n # end\\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role if current_user.admin?\\n\\n can [:fa_overview], ActiveFedora::Base\\n can [:advanced], ActiveFedora::Base\\n can [:streets], ActiveFedora::Base\\n can [:pdf_page], ActiveFedora::Base\\n can [:pdf_page_metadata], ActiveFedora::Base\\n can [:bookreader], ActiveFedora::Base\\n can [:imageviewer], ActiveFedora::Base\\n can [:streetsviewer], ActiveFedora::Base\\n can [:fa_series], ActiveFedora::Base\\n can [:audio_transcriptonly], ActiveFedora::Base\\n can [:video_transcriptonly], ActiveFedora::Base\\n end\",\n \"def custom_permissions\\n discover_permissions\\n export_sets_permissions\\n batches_permissions\\n preservation_events_permissions\\n end\",\n \"def custom_permissions\\n # Limits deleting objects to a the admin user\\n #\\n # if current_user.admin?\\n # can [:destroy], ActiveFedora::Base\\n # end\\n\\n # Limits creating new objects to a specific group\\n #\\n # if user_groups.include? 'special_group'\\n # can [:create], ActiveFedora::Base\\n # end\\n end\",\n \"def custom_permissions\\n if current_user.admin?\\n can :manage, :all\\n end\\n end\",\n \"def custom_permissions\\n can [:file_status, :stage, :unstage], FileSet\\n\\n if current_user.ingest_from_external_sources?\\n end\\n\\n if current_user.manage_users?\\n can [:show, :add_user, :remove_user, :index], Role\\n end\\n\\n if current_user.manage_roles?\\n can [:create, :show, :index, :edit, :update, :destroy], Role\\n end\\n\\n if current_user.run_fixity_checks?\\n can [:fixity], FileSet\\n end\\n # Limits deleting objects to a the admin user\\n #\\n # if current_user.admin?\\n # can [:destroy], ActiveFedora::Base\\n # end\\n\\n # Limits creating new objects to a specific group\\n #\\n # if user_groups.include? 'special_group'\\n # can [:create], ActiveFedora::Base\\n # end\\n end\",\n \"def custom_permissions\\n # Limits deleting objects to a the admin user\\n #\\n # if current_user.admin?\\n # can [:destroy], ActiveFedora::Base\\n # end\\n if current_user.admin?\\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\\n # Admin user can create works of all work types\\n can :create, curation_concerns_models\\n end\\n # Limits creating new objects to a specific group\\n #\\n # if user_groups.include? 'special_group'\\n # can [:create], ActiveFedora::Base\\n # end\\n end\",\n \"def custom_permissions\\n # Limits deleting objects to a the admin user\\n #\\n # if current_user.admin?\\n # can [:destroy], ActiveFedora::Base\\n # end\\n\\n # Limits creating new objects to a specific group\\n #\\n # if user_groups.include? 'special_group'\\n # can [:create], ActiveFedora::Base\\n # end\\n\\n if current_user.admin?\\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\\n end\\n\\n# if current_user.contentadmin?\\n# can [:create, :destroy], GwWork\\n# can [:create, :destroy], GwEtd\\n# end\\n end\",\n \"def custom_permissions\\n # Limits deleting objects to a the admin user\\n #\\n # if current_user.admin?\\n # can [:destroy], ActiveFedora::Base\\n # end\\nif current_user.admin?\\n\\t can [:create, :show, :add_user, :remove_user, :index], Role\\n\\t end\\n # Limits creating new objects to a specific group\\n #\\n # if user_groups.include? 'special_group'\\n # can [:create], ActiveFedora::Base\\n # end\\n\\n\\n\\n end\",\n \"def custom_permissions\\n if current_user.admin?\\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\\n can [:create], Collection\\n can [:discover], Hydra::AccessControls::Embargo\\n can [:discover], Hydra::AccessControls::Lease\\n can [:create], [ CurationConcerns.config.curation_concerns ]\\n can [:destroy], ActiveFedora::Base\\n can [:permissions], [ CurationConcerns.config.curation_concerns ]\\n end\\n\\n # Limits deleting objects to a the admin user\\n #\\n #if current_user.admin?\\n # can [:destroy], ActiveFedora::Base\\n #end\\n\\n if current_user.has_role?('collection.manager')\\n # can [:create, :show, :index, :edit, :update, :destroy], Collection\\n can [:create], Collection\\n end\\n\\n if current_user.has_role?('collection.depositor') or current_user.has_group_role?('collection.depositor')\\n # can [:create, :show, :index, :edit, :update, :destroy], [ CurationConcerns.configuration.curation_concerns ]\\n can [:create], [ CurationConcerns.config.curation_concerns ]\\n # can [:show], Collection\\n end\\n\\n # Limits creating new objects to a specific group\\n #\\n # if user_groups.include? 'special_group'\\n # can [:create], ActiveFedora::Base\\n # end\\n end\",\n \"def custom_permissions\\n alias_action :show, :manifest, to: :read\\n alias_action :color_pdf, :pdf, :edit, :browse_everything_files, :structure, :file_manager, to: :modify\\n roles.each do |role|\\n send \\\"#{role}_permissions\\\" if current_user.send \\\"#{role}?\\\"\\n end\\n end\",\n \"def custom_permissions\\n alias_action :show, :manifest, to: :read\\n alias_action :color_pdf, :pdf, :edit, :browse_everything_files, :structure, :file_manager, to: :modify\\n roles.each do |role|\\n send \\\"#{role}_permissions\\\" if current_user.send \\\"#{role}?\\\"\\n end\\n end\",\n \"def custom_permissions # rubocop:disable Metrics/CyclomaticComplexity\\n can :read, ApplicationPresenter, &:can_read?\\n can :read, UsersPresenter, &:can_read?\\n can :read, UserPresenter, &:can_read?\\n can :read, RolesPresenter, &:can_read?\\n can :read, RolePresenter, &:can_read?\\n\\n can :read, Press\\n\\n grant_press_analyst_abiltites if press_analyst?\\n grant_press_editor_abilities if press_editor?\\n grant_press_admin_abilities if platform_admin? || press_admin?\\n grant_platform_admin_abilities if platform_admin?\\n end\",\n \"def load_permissions\\n authorize! :manage, :all\\n end\",\n \"def custom_permissions\\n #Collection Manager Permissions\\n #Higher power than edit user...[Dont want edit users to be able to DELETE a COLLECTION??, (Delete a DO?)]\\n if current_user.applicable_policy?(SETTING_POLICY_COLLECTION_MANAGER)\\n #Marked as being able to :manage_collection\\n can :manage_collection_flag, :all\\n can :create, [DRI::Batch, DRI::GenericFile]\\n end\\n\\n\\n #Admin Permissions\\n if current_user.applicable_policy?(SETTING_POLICY_ADMIN)\\n can :admin_flag, :all\\n #Disabled for now..\\n can :manage, :all\\n end\\n\\n #Create_do flag (alias for :edit collection)\\n can :create_do, String do |pid|\\n test_create(pid)\\n end\\n\\n can :create_do, DRI::Batch do |collection|\\n test_create(collection)\\n end\\n end\",\n \"def custom_permissions\\n # Limits deleting objects to a the admin user\\n #\\n # if current_user.admin?\\n # can [:destroy], ActiveFedora::Base\\n # end\\n\\n # Limits creating new objects to a specific group\\n\\n if user_groups.include? ['all_project_writers']\\n can [:create], PulStore::Base\\n can [:create], PulStore::Lae::Box\\n can [:create], PulStore::Lae::Folder\\n can [:create], Pulstore::Lae::HardDrive\\n end\\n\\n if user_groups.include? ['lae_project_writers']\\n can [:create], PulStore::Lae::Box\\n can [:create], PulStore::Lae::Folder\\n can [:create], Pulstore::Lae::HardDrive\\n end \\n\\n if user_groups.include? ['all_project_writers']\\n can [:destroy], PulStore::Base\\n end\\n\\n if user_groups.include? ['lae_project_readers', 'all_project_readers' ]\\n can [:show], PulStore::Base\\n end\\n end\",\n \"def custom_permissions\\n if admin?\\n can [:confirm_delete], ActiveFedora::Base\\n can [:allow_downloads, :prevent_downloads], AdminSet\\n\\n can :manage, Spotlight::HomePage\\n can :manage, Spotlight::Exhibit\\n end\\n\\n can :read, Spotlight::HomePage\\n can :read, Spotlight::Exhibit\\n\\n # Limits creating new objects to a specific group\\n #\\n # if user_groups.include? 'special_group'\\n # can [:create], ActiveFedora::Base\\n # end\\n end\",\n \"def paranoid_permissions\\n true\\n end\",\n \"def custom_permissions\\n if user_groups.include?(\\\"admin\\\")\\n can :manage, :all\\n end\\n end\",\n \"def standard_authorized_user_rights\\n public_access + protected_access \\n end\",\n \"def custom_permissions\\n can [:create], Account\\n end\",\n \"def custom_permissions\\n can [:create], Account\\n end\",\n \"def load_permissions \\n @current_permissions = current_user.role.permissions.collect{|i| [i.subject_class, i.action]} \\n end\",\n \"def set_permissions\\n self.permissions ||= \\\"guest\\\"\\n end\",\n \"def smart?; self.permission_level = 2; end\",\n \"def permission_set\\n if attributes[\\\"InheritedSecurity\\\"]\\n supersite.permission_set\\n else\\n PermissionSet.new(self)\\n end\\n end\",\n \"def write_permission_check(*args)\\n # Don't prevent writes if creating a new object (anyone should be able to do this)\\n return unless self.exist?\\n\\n if LinkedData.settings.enable_security\\n user = nil\\n options_hash = {}\\n args.each {|e| options_hash.merge!(e) if e.is_a?(Hash)}\\n user = options_hash[:user]\\n\\n # Allow a passed option to short-cut the security process\\n return if options_hash[:override_security]\\n\\n user ||= Thread.current[:remote_user]\\n\\n reference_object = self\\n\\n # If we have a modified object, we should do the security check\\n # on the original. This allows a user to change the ownsership of\\n # an object without having to add the owner and have the new owner\\n # remove the original owner.\\n reference_object = self.class.find(self.id).first if self.modified?\\n\\n # Allow everyone to write\\n return if reference_object.access_for_all?\\n\\n # Load attributes needed by security\\n if reference_object.access_control_load?\\n # Only load ones that aren't loaded so we don't overwrite changes\\n not_loaded = []\\n reference_object.access_control_load_attrs.each do |attr|\\n not_loaded << attr unless reference_object.loaded_attributes.include?(attr)\\n end\\n reference_object.bring(*not_loaded) unless not_loaded.empty?\\n end\\n\\n writable = reference_object.writable?(user)\\n raise LinkedData::Security::WriteAccessDeniedError, \\\"Write access denied: #{reference_object.id}\\\" unless writable\\n end\\n end\",\n \"def user_permissions\\n if user_signed_in? && (current_user.is_logistics? || current_user.is_clerical? || current_user.is_vendor? || current_user.is_customer?)\\n authorize! :edit, Element\\n end\\n end\",\n \"def load_permissions\\n @current_permissions = current_user.role.permissions.collect{|i| [i.subject_class, i.action]}\\n end\",\n \"def load_permissions\\n \\n @current_permissions = current_user.role.permissions.collect{|i| [i.subject_class, i.action]}\\n end\",\n \"def has_permission?\\n return true if administrator?\\n \\n # Load the Model based on the controller name\\n klass = self.controller_name.classify.constantize\\n \\n # Load the possible parent requested\\n @parents = (klass.has_parent?) ? get_parents_from_request_params(klass, params) : nil\\n \\n # Load the resource requested\\n if params[:id]\\n if [\\\"index\\\", \\\"destroy\\\", \\\"update\\\"].include?(params[:action]) && klass.respond_to?(:in_set)\\n @resource = klass.in_set(params[:id])\\n @resource = @resource.first if @resource.size == 1\\n else\\n @resource = klass.find(params[:id])\\n end\\n end\\n \\n # Let's let the Model decide what is acceptable\\n # NOTE: It is still the concrete controller's job to filter inaccessible resources (accessed via the index)!\\n # This presumably happens in the with_parent named scope\\n \\n authorized = case params[:action]\\n when \\\"edit\\\", \\\"update\\\"\\n if !@resource.is_a?(Array)\\n return @resource.updatable_by?(current_user, @parents) # this is 'returned' to authorized\\n end\\n \\n verify_set_accessablility(@resource, :updatable_by?) do |unauthorized_ids|\\n permission_denied(\\n :status => :conflict,\\n :message => \\\"#{unauthorized_ids.to_a.join(',')} is not available for update.\\\"\\n ) if unauthorized_ids.size > 0\\n end\\n true # if it gets past verification, authorized is true\\n \\n when \\\"destroy\\\" \\n if !@resource.is_a?(Array)\\n return @resource.deletable_by?(current_user, @parents)\\n end\\n \\n verify_set_accessablility(@resource, :deletable_by?) do |unauthorized_ids|\\n permission_denied(\\n :status => :conflict,\\n :message => \\\"#{unauthorized_ids.to_a.join(',')} is not available for deletion.\\\"\\n ) if unauthorized_ids.size > 0\\n end\\n true # if it gets past verification, authorized is true\\n \\n when \\\"index\\\" then klass.indexable_by?(current_user, @parents)\\n when \\\"new\\\", \\\"create\\\" then klass.creatable_by?(current_user, @parents)\\n when \\\"show\\\" then @resource.readable_by?(current_user, @parents)\\n else check_non_restful_route(current_user, klass, @resource, @parents)\\n end\\n \\n permission_denied unless authorized\\n \\n #rescue NoMethodError => e\\n # Misconfiguration: A RESTful_ACL specific method is missing.\\n #raise_error(klass, e)\\n #rescue\\n # Failsafe: If any funny business is going on, log and redirect\\n #routing_error\\n #end\\n end\",\n \"def permits_write_access_for(user)\\n end\",\n \"def set_default_permissions!\\n # Always allow to read the id\\n let :read, :id\\n # These shouldn't change after the first save.\\n let :write, [ :id, :created_at ], :if => :new?\\n # These can always change.\\n let :write, :updated_at\\n end\",\n \"def permitted?(model_name, requested_flags = 0)\\n return false if self.kind != Kind::ROLE\\n return true if admin?\\n\\n p = self.model_permissions.find_by_model(model_name)\\n if requested_flags == 0\\n p\\n else\\n p && p.permitted?(requested_flags)\\n end\\n end\",\n \"def my_permissions\\n @my_permissions ||= self.roles.map {|r| r.permissions.map {|p| p.name}}.flatten.freeze\\n end\",\n \"def permissions_policy(&block); end\",\n \"def custom_permissions\\n # Limits deleting objects to a the admin user\\n #\\n # if current_user.admin?\\n # can [:destroy], ActiveFedora::Base\\n # end\\n\\n # Limits creating new objects to a specific group\\n #\\n # if user_groups.include? 'special_group'\\n # can [:create], ActiveFedora::Base\\n # end\\n\\n # TODO: This area looks like it needs to be refactored.\\n\\n if current_user.admin?\\n editor_abilities\\n upload_abilities\\n publish_abilities\\n roles_abilities\\n hard_delete_abilities\\n import_admin_abilities\\n user_abilities\\n group_abilities\\n can [:create, :destroy, :update], FeaturedWork\\n can [:manage], Hydra::Admin::Collection\\n\\n can :create, TinymceAsset\\n can [:create, :update], ContentBlock\\n can :read, ContentBlock\\n can :characterize, GenericFile\\n end\\n\\n\\n if current_user.manager?\\n upload_abilities\\n publish_abilities\\n roles_abilities\\n import_user_abilities\\n can [:manage], Hydra::Admin::Collection do |admin_set|\\n # Can manage admin sets within their assigned unit.\\n current_user.osul_groups.include? admin_set.unit_group\\n end\\n can [:manage], Osul::Group do |group|\\n # Can manage the groups the user is in or the groups of the units a user is assigned to.\\n current_user.osul_groups.include? group or current_user.osul_groups.include? group.unit\\n end\\n can [:create], Osul::Group\\n can [:create, :destroy, :update], FeaturedWork\\n end\\n\\n if current_user.data_entry?\\n upload_abilities\\n publish_abilities\\n no_admin_set_abilities\\n end\\n\\n if current_user.data_entry_student?\\n upload_abilities\\n no_admin_set_abilities\\n end\\n\\n unless current_user.public?\\n can :view_full, GenericFile\\n end\\n\\n if current_user.role.nil?\\n no_file_abilities\\n no_admin_set_abilities\\n end\\n end\",\n \"def build_permissions(perms, other)\\n perms.permits! :read\\n perms.permits! :write if self == other\\n end\",\n \"def permissions\\n @resource_permissions\\n end\",\n \"def admin_permissions\\n can [:manage], :all\\n end\",\n \"def admin_permissions\\n can [:manage], :all\\n end\",\n \"def mass_assignment_authorizer(role = :default)\\n if accessible == :all\\n self.class.protected_attributes\\n else\\n super + (accessible || [])\\n end\\n end\",\n \"def set_perms\\n self.perms = Access.for_user(self)\\n end\",\n \"def permissions\\n attribute_prop(5)\\n end\",\n \"def deny_all_access\\n @permissions = 0\\n end\",\n \"def user_permission\\n has_controller_permission?('user')\\n end\",\n \"def permits_read_acccess_for(user)\\n end\",\n \"def enforce_delete_permissions\\n enforce_edit_permissions\\n end\",\n \"def permission\\n Ricer::Irc::Permission.by_permission(self.permissions, authenticated?)\\n end\",\n \"def setable_permissions\\n setable_permissions = Erp::AccessControl.permissions - Erp::AccessControl.public_permissions\\n setable_permissions -= Erp::AccessControl.members_only_permissions if builtin == BUILTIN_NON_MEMBER\\n setable_permissions -= Erp::AccessControl.loggedin_only_permissions if builtin == BUILTIN_ANONYMOUS\\n setable_permissions\\n end\",\n \"def project_permissions\\n user.project_permissions(rule.project)\\n end\",\n \"def standard_authorized_user_rights\\n Lockdown::System.public_access + Lockdown::System.protected_access \\n end\",\n \"def permissions = {}\",\n \"def make_permission_protected(name)\\n permission(name).is_protected\\n end\",\n \"def permissions( force_reload = false )\\n\\n # Two levels of joins here, so can't use has_many :through\\n if force_reload\\n @permissions = nil \\n @permissions_by_class_and_op = {}\\n end\\n\\n cond_str = 'role_id in ' + self.class.role_assigned_cond( '?' )\\n if !instance_variable_defined?(\\\"@permissions\\\") || @permissions.nil?\\n @permissions ||= Permission.where([cond_str, self]).to_a\\n end\\n\\n return @permissions\\n end\",\n \"def define_global_privileges\\n can :read, Project, public_can_view?: true\\n can :index, Project\\n can :read, Group\\n end\",\n \"def permissions\\n User.do_find_permissions session_id: kb_session_id\\n end\",\n \"def role\\n permission_type\\n end\",\n \"def permitted_to! (privilege, options = {} )\\n options = {\\n :user => Authorization.current_user,\\n :object => self\\n }.merge(options)\\n\\nlogger.debug \\\"Checking for: #{self.class.name}\\\"\\n\\n Authorization::Engine.instance.permit!(privilege,\\n {:user => options[:user],\\n :object => options[:object]})\\n end\",\n \"def can_change( record, type = '*' )\\n name, type = get_name_and_type_from_param( record, type )\\n self.permissions['allowed'] << [ name, type ]\\n end\",\n \"def access_rights_for_permission(perm)\\n sym = Lockdown.get_symbol(perm)\\n\\n permissions[sym]\\n rescue \\n raise SecurityError, \\\"Permission requested is not defined: #{sym}\\\"\\n end\",\n \"def permissions\\n Roles.type_map[role_type].permissions\\n end\",\n \"def require_other_permission\\n respond_to_permission_error\\n end\",\n \"def permissions=(value)\\n @permissions = value\\n end\",\n \"def can?(permission)\\n permissions.include?(permission.to_s) || super_admin?\\n end\",\n \"def add_user_permission(u)\\n\\t\\t\\n\\tend\",\n \"def permission_for (collection)\\n permission = Permission.find_or_create_by_user_id_and_collection_id(self.id, collection.id)\\n end\",\n \"def apply_superuser_permissions(permission_types)\\n []\\n end\",\n \"def model_actions(perms)\\n ActiveRecord::Base.descendants.each do |m|\\n next unless m.respond_to?(:permission_definition)\\n next if m.permission_definition.nil? || m.permission_definition == {}\\n perms << PermissionsGenerator.new(m)\\n end\\n return perms\\nend\",\n \"def permissions\\n Rails.cache.fetch(\\\"permissions_#{self.id}\\\", expire_in: 1.month) do\\n self.roles.map(&:permissions).flatten\\n end\\n end\",\n \"def overall_permissions(thing)\\n global_permissions.merge!(permissions_for(thing))\\n end\",\n \"def required_permission\\n #\\n # return the permission record if we have the Permission model\\n #\\n @required_permission ||= defined?(Permission) ? wulin_permits_required_permission : OpenStruct.new(name: [controller_name, action_name].join(\\\"#\\\"))\\n end\",\n \"def set_acl_statement\\n super\\n end\",\n \"def custom_permissions\\n\\n campus = \\\"bakersfield\\\" if current_user.email.include?(\\\"bakersfield.edu\\\")\\n campus = \\\"chancellor\\\" if current_user.email.include?(\\\"calstate.edu\\\")\\n campus = \\\"channel\\\" if current_user.email.include?(\\\"ci.edu\\\")\\n campus = \\\"chico\\\" if current_user.email.include?(\\\"chico.edu\\\")\\n campus = \\\"dominguez\\\" if current_user.email.include?(\\\"dh.edu\\\")\\n campus = \\\"eastbay\\\" if current_user.email.include?(\\\"eb.edu\\\")\\n campus = \\\"fresno\\\" if current_user.email.include?(\\\"fresno.edu\\\")\\n campus = \\\"fullerton\\\" if current_user.email.include?(\\\"fullerton.edu\\\")\\n campus = \\\"humboldt\\\" if current_user.email.include?(\\\"humboldt.edu\\\")\\n campus = \\\"longbeach\\\" if current_user.email.include?(\\\"lb.edu\\\")\\n campus = \\\"losangeles\\\" if current_user.email.include?(\\\"la.edu\\\")\\n campus = \\\"maritime\\\" if current_user.email.include?(\\\"maritime.edu\\\")\\n campus = \\\"mlml\\\" if current_user.email.include?(\\\"mlml.edu\\\")\\n campus = \\\"northridge\\\" if current_user.email.include?(\\\"northridge.edu\\\")\\n campus = \\\"pomona\\\" if current_user.email.include?(\\\"bronco.edu\\\")\\n campus = \\\"sacramento\\\" if current_user.email.include?(\\\"sacramento.edu\\\")\\n campus = \\\"sanfrancisco\\\" if current_user.email.include?(\\\"sf.edu\\\")\\n campus = \\\"sanmarcos\\\" if current_user.email.include?(\\\"sanmarcos.edu\\\")\\n campus = \\\"sonoma\\\" if current_user.email.include?(\\\"sonoma.edu\\\")\\n campus = \\\"stanislaus\\\" if current_user.email.include?(\\\"stanislaus.edu\\\")\\n\\n user_groups.push(campus)\\n\\n # admin\\n if current_user.admin?\\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\\n end\\n\\n # Limits creating new objects to a specific group\\n #\\n # if user_groups.include? 'special_group'\\n # can [:create], ActiveFedora::Base\\n # end\\n end\",\n \"def permission_mapping\\n super.merge(\\n {\\n 'index_role_screen' => 'index',\\n 'index_role_field' => 'index',\\n 'index_user_screen' => 'index',\\n 'index_user_field' => 'index',\\n 'fetch_row' => 'index'\\n }\\n )\\n end\",\n \"def readonly_user\\n super\\n end\",\n \"def custom_permissions_read(_notebook, _user, _use_admin=false)\\n true\\n end\",\n \"def user_permissions\\n if current_user.id == params[:id].to_i\\n @user = User.find(params[:id])\\n else\\n flash[:danger] = 'Unauthorized action.'\\n redirect_to edit_user_path(current_user) \\n end\\n end\",\n \"def permitted?; end\",\n \"def permission_proxy\\n @authorizable_permission_proxy ||= Authorizable::Proxy.new(self)\\n end\",\n \"def default(user)\\n puts \\\"Rights: default\\\"\\n # can :read, :all # doesn't do that ! We will authorize each actions\\n can :read, [Doc, Gallery, Image, Place]\\n can :manage, User, :id => user.id\\n cannot :destroy, User, :id => user.id\\n\\n can :read, ForumCategory, [\\\"role <= ?\\\", user.role] do |forum_category|\\n forum_category.role <= user.role\\n end\\n\\n can :read, Forum, [\\\"role <= ?\\\", user.role] do |forum|\\n if (forum.role <= user.role)\\n can :read, Topic\\n can :read, Message\\n true\\n else\\n false\\n end\\n end\\n\\n # can read users profiles\\n can :read, User\\n\\n # special actions\\n can :mark_all_read, Forum\\n end\",\n \"def authorize_admin!\\n authorize! :manage, :all\\n end\",\n \"def enforce_access_controls(opts={})\\n controller_action = params[:action].to_s\\n delegate_method = \\\"enforce_#{controller_action}_permissions\\\"\\n if self.respond_to?(delegate_method.to_sym, true)\\n self.send(delegate_method.to_sym)\\n else\\n true\\n end\\n end\",\n \"def permissions\\n read_attribute(:permissions) || {}\\n end\",\n \"def authorize (permission_name)\\n self.allowances.detect {|a| a.permission.name == permission_name.to_s}\\n end\",\n \"def check_permissions\\n authorize! :create, Employee\\n end\",\n \"def add_permissions\\n [\\\"License\\\", \\\"Archive\\\", \\\"Contract\\\"].each do |doc|\\n klass = doc.constantize\\n doc_id = \\\"#{doc.downcase}_id\\\".to_sym\\n permissions = self.send(\\\"#{doc.downcase.pluralize.singularize}_permissions\\\".to_sym)\\n klass.find(:all).each { |record|\\n permissions.create doc_id => record.id, :ycrole_id => self.id,\\n :can_read => false, :can_write => false\\n }\\n end\\n end\",\n \"def effective_permissions\\n source = self\\n\\n while source.inherit && source.forum.parent\\n source = source.forum.parent.forum_permissions.find_by(group: group)\\n end\\n\\n source = group if source.inherit\\n\\n source\\n end\",\n \"def set_access(*args)\\n options = args.extract_options!\\n options[:object] ||= Array(@_controller).first.to_s.singularize.to_sym if @_controller.present?\\n permissions.add(*args, options)\\n end\",\n \"def restore_permissions; end\",\n \"def restore_permissions; end\",\n \"def effective_roles_authorization_level(controller, role, resource)\\n authorization_method = EffectiveResources.authorization_method\\n\\n raise('expected an authorization method') unless (authorization_method.respond_to?(:call) || authorization_method.kind_of?(Symbol))\\n return :unknown unless (controller.current_user rescue nil).respond_to?(:roles=)\\n\\n # Store the current ability (cancan support) and roles\\n current_ability = controller.instance_variable_get(:@current_ability)\\n current_user = controller.instance_variable_get(:@current_user)\\n current_user_roles = controller.current_user.roles\\n\\n # Set up the user, so the check is done with the desired permission level\\n controller.instance_variable_set(:@current_ability, nil)\\n\\n level = nil\\n\\n case role\\n when :signed_in\\n controller.current_user.roles = []\\n when :public\\n controller.instance_variable_set(:@current_user, nil)\\n\\n if defined?(EffectiveLogging)\\n EffectiveLogging.supressed { (controller.request.env['warden'].set_user(false) rescue nil) }\\n else\\n (controller.request.env['warden'].set_user(false) rescue nil)\\n end\\n else\\n controller.current_user.roles = [role]\\n end\\n\\n # Find the actual authorization level\\n level = effective_roles_item_authorization_level(controller, role, resource, authorization_method)\\n\\n # Restore the existing current_user stuff\\n if role == :public\\n ActiveRecord::Base.transaction do\\n if defined?(EffectiveLogging)\\n EffectiveLogging.supressed { (controller.request.env['warden'].set_user(current_user) rescue nil) }\\n else\\n (controller.request.env['warden'].set_user(current_user) rescue nil)\\n end\\n\\n raise ActiveRecord::Rollback\\n end\\n end\\n\\n controller.instance_variable_set(:@current_ability, current_ability)\\n controller.instance_variable_set(:@current_user, current_user)\\n controller.current_user.roles = current_user_roles\\n\\n level\\n end\",\n \"def can?(*args)\\n permissions.can?(*args)\\n end\",\n \"def authorize_inherited_resource!\\n authorize! :show, parent if parent?\\n authorize! authorizable_action, authorize_resource? ? resource : resource_class\\n end\",\n \"def check_write_access(obj)\\n return obj unless LinkedData.settings.enable_security\\n if obj.is_a?(LinkedData::Models::Base) && obj.write_restricted?\\n writable = obj.writable?(env[\\\"REMOTE_USER\\\"])\\n error 403, \\\"Access denied for this resource\\\" unless writable\\n end\\n end\",\n \"def filter_access!\\n treat_as get_current_role\\n end\",\n \"def can_do_member_scoped_actions\\n can :show, :all\\n can :edit, :all\\n can :destroy, :all\\n can :history, :all\\n can :show_in_app, :all\\n can :clone, :all\\n # can :nested_set, :all\\n can :nestable, :all\\n can :change_state, :all\\n end\",\n \"def role_permissions=(value)\\n @role_permissions = value\\n end\",\n \"def permissions\\n return @permissions\\n end\",\n \"def build_permissions(perms, other)\\n perms.permits! :read\\n\\n if self == other\\n perms.permits! :write\\n elsif other.admin?\\n perms.permits! :write\\n end\\n end\",\n \"def everyone(read, write)\\n apply(PUBLIC, read, write)\\n permissions[PUBLIC]\\n end\"\n]"},"negative_scores":{"kind":"list like","value":["0.7124058","0.70427585","0.6954191","0.69149697","0.6909459","0.6890503","0.68741816","0.6855458","0.68015546","0.6762293","0.66815597","0.66815597","0.6657583","0.6640195","0.6627914","0.66278124","0.6593337","0.64492166","0.64396954","0.64392996","0.6315201","0.6315201","0.63095075","0.6278138","0.6235062","0.6220439","0.6216728","0.62075436","0.6189672","0.61532354","0.6152184","0.6147287","0.6130627","0.6115335","0.608766","0.60838884","0.6064977","0.6052751","0.60269153","0.6020001","0.6020001","0.60028356","0.60021436","0.5998134","0.5994391","0.5986655","0.59793115","0.5974346","0.5967649","0.59665316","0.592944","0.59270465","0.58969057","0.589072","0.5864652","0.5863857","0.5795321","0.578898","0.57750213","0.57723695","0.5770938","0.5763758","0.5760234","0.5751763","0.57502776","0.57502186","0.5747722","0.57413733","0.5733787","0.573319","0.57017004","0.56990373","0.56962395","0.5695053","0.5694021","0.56920457","0.56903553","0.5652278","0.56487584","0.564229","0.5635702","0.56307256","0.5630705","0.56256294","0.56251633","0.56249714","0.5624051","0.5620177","0.5618885","0.56182003","0.56182003","0.5617081","0.561568","0.56140167","0.56109643","0.5608456","0.560806","0.56023973","0.559919","0.55984443","0.55951214"],"string":"[\n \"0.7124058\",\n \"0.70427585\",\n \"0.6954191\",\n \"0.69149697\",\n \"0.6909459\",\n \"0.6890503\",\n \"0.68741816\",\n \"0.6855458\",\n \"0.68015546\",\n \"0.6762293\",\n \"0.66815597\",\n \"0.66815597\",\n \"0.6657583\",\n \"0.6640195\",\n \"0.6627914\",\n \"0.66278124\",\n \"0.6593337\",\n \"0.64492166\",\n \"0.64396954\",\n \"0.64392996\",\n \"0.6315201\",\n \"0.6315201\",\n \"0.63095075\",\n \"0.6278138\",\n \"0.6235062\",\n \"0.6220439\",\n \"0.6216728\",\n \"0.62075436\",\n \"0.6189672\",\n \"0.61532354\",\n \"0.6152184\",\n \"0.6147287\",\n \"0.6130627\",\n \"0.6115335\",\n \"0.608766\",\n \"0.60838884\",\n \"0.6064977\",\n \"0.6052751\",\n \"0.60269153\",\n \"0.6020001\",\n \"0.6020001\",\n \"0.60028356\",\n \"0.60021436\",\n \"0.5998134\",\n \"0.5994391\",\n \"0.5986655\",\n \"0.59793115\",\n \"0.5974346\",\n \"0.5967649\",\n \"0.59665316\",\n \"0.592944\",\n \"0.59270465\",\n \"0.58969057\",\n \"0.589072\",\n \"0.5864652\",\n \"0.5863857\",\n \"0.5795321\",\n \"0.578898\",\n \"0.57750213\",\n \"0.57723695\",\n \"0.5770938\",\n \"0.5763758\",\n \"0.5760234\",\n \"0.5751763\",\n \"0.57502776\",\n \"0.57502186\",\n \"0.5747722\",\n \"0.57413733\",\n \"0.5733787\",\n \"0.573319\",\n \"0.57017004\",\n \"0.56990373\",\n \"0.56962395\",\n \"0.5695053\",\n \"0.5694021\",\n \"0.56920457\",\n \"0.56903553\",\n \"0.5652278\",\n \"0.56487584\",\n \"0.564229\",\n \"0.5635702\",\n \"0.56307256\",\n \"0.5630705\",\n \"0.56256294\",\n \"0.56251633\",\n \"0.56249714\",\n \"0.5624051\",\n \"0.5620177\",\n \"0.5618885\",\n \"0.56182003\",\n \"0.56182003\",\n \"0.5617081\",\n \"0.561568\",\n \"0.56140167\",\n \"0.56109643\",\n \"0.5608456\",\n \"0.560806\",\n \"0.56023973\",\n \"0.559919\",\n \"0.55984443\",\n \"0.55951214\"\n]"},"document_score":{"kind":"string","value":"0.0"},"document_rank":{"kind":"string","value":"-1"}}},{"rowIdx":124,"cells":{"query":{"kind":"string","value":"Checks given file against pattern. file File, Pathname or String"},"document":{"kind":"string","value":"def matches?(path)\n return false if path.nil?\n\n send match_method, Pathname.new(path)\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def assert_match_in_file(pattern, file)\n File.file?(file) ? assert_match(pattern, File.read(file)) : assert_file_exists(file)\n end","def pattern_match(file, pattern)\n case\n when pattern.is_a?(Regexp)\n return file.match(pattern)\n when pattern.is_a?(String)\n return File.fnmatch(pattern, file)\n when pattern.is_a?(Proc)\n return pattern.call(file)\n when pattern.is_a?(Rake::FileTask)\n return pattern.to_s.match(file)\n else\n raise \"Cannot interpret pattern #{pattern}\"\n end\n end","def assert_match_in_file(pattern, file)\n assert File.exist?(file), \"File '#{file}' does not exist!\"\n assert_match pattern, File.read(file)\n end","def assert_match_in_file(pattern, file)\n assert File.exist?(file), \"File '#{file}' does not exist!\"\n assert_match pattern, File.read(file)\n end","def file_contains(filename, pattern)\n unless pattern.kind_of?(Regexp)\n pattern = Regexp.new(pattern)\n end\n detected = nil\n File.open(filename) { |f|\n detected = f.detect { |line|\n line =~ pattern\n }\n }\n ! detected.nil?\n end","def file_match(file)\n end","def fnmatch(pattern, *args) File.fnmatch(pattern, path, *args) end","def fnmatch?( pattern, *args ) File.fnmatch?( pattern, self, *args ) end","def fnmatch?(pattern, *args) File.fnmatch?(pattern, @path, *args) end","def fnmatch(pattern, *args) File.fnmatch(pattern, @path, *args) end","def fnmatch?(pattern, *args) File.fnmatch?(pattern, path, *args) end","def fnmatch( pattern, *args ) File.fnmatch( pattern, self, *args ) end","def match_against filename\n @regexp.match(filename)\n end","def filename_matches_pattern?(filename)\n @file_matchers.each do |pattern|\n return true if File.fnmatch(pattern, filename)\n end\n return false\n end","def is_valid_file_name?(filename)\n return $filepattern.match(filename)\nend","def matching_file_regex\n file_regex ? file_regex : /\\.js$/\n end","def validate_file(file)\n end","def matches_filename?(filename)\r\n basename = File.basename(filename)\r\n @glob_patterns.any? {|pattern| File.fnmatch pattern, basename.downcase}\r\n end","def check_file_patterns\n FILE_PATTERNS.each do |attr_name|\n if respond_to?(\"_validate_#{attr_name}\", true)\n send(\"_validate_#{attr_name}\")\n else\n validate_nonempty_patterns(attr_name, :error)\n end\n end\n\n _validate_header_mappings_dir\n if consumer.spec.root?\n _validate_license\n _validate_module_map\n end\n end","def search_file(pattern, file)\n node = ast_from_file(file)\n search node, pattern\n end","def matches_path?(pattern, path)\n File.fnmatch?(\n pattern, path,\n File::FNM_PATHNAME | # Wildcard doesn't match separator\n File::FNM_DOTMATCH # Wildcards match dotfiles\n )\n end","def file_pattern(name)\n if name.to_s !~ FILE_PATTERN_NAME_REGEX\n raise ArgumentError.new(\"A file pattern name must match this regex: #{ FILE_PATTERN_NAME_REGEX.inspect }\")\n end\n get_config_val(@file_patterns, name)\n end","def matches_file?(f)\r\n @magics.any? {|m| m =~ f }\r\n end","def file_pattern( pattern )\n self.class_eval { @file_pattern = pattern }\n end","def matches_path?(pattern, path); end","def valid_file?(path)\n case path\n when %r|/abcdef$|, %r|^\\./tmp/db/\\w+?/database.yml$|\n return false\n end\n return true\n end","def matches?(file); matches_exprs?(file,[@reg_expr]); end","def gsub_file_with_match_check(relative_destination, regexp, *args, &block)\n path = destination_path(relative_destination)\n matches = File.read(path).match(regexp)\n raise \"Regexp not found in #{relative_destination}\\n called from #{caller.first}\" unless matches\n gsub_file(relative_destination, regexp, *args, &block)\nend","def grep_file(file_path, grep_pattern)\n logc(\"method: #{__method__}, params: #{file_path}, #{grep_pattern}\")\n\n # with File.open(file_path, 'r').each.grep(grep_pattern) possible invalid byte sequence in UTF-8 (ArgumentError)\n # so we use \"match\" to check if line match pattern and 'scrub' to skip bad encoding symbols\n res = []\n File.open(file_path, 'r').each {|line| res << line if line.scrub.match(grep_pattern)}\n return res\nend","def glob_matches?(rule)\n File.fnmatch?(rule, @host_name)\n end","def check(filename)\r\n check_special(filename) ||\r\n open(filename) { |f|\r\n check_magics_gt80(f) ||\r\n check_globs(filename) ||\r\n check_magics_lt80(f) ||\r\n check_default(f)\r\n }\r\n end","def only(files,patterns)\n if !patterns.kind_of?(Array)\n patterns = [patterns]\n end\n files.select do |file|\n matches = false\n patterns.each do |pattern|\n if File.fnmatch(pattern,file)\n matches = true\n break\n end\n end\n matches\n end\n end","def matchFn(filename)\n\treturn [\".txt\", \".pdf\"].include? File.extname(filename)\nend","def matcher(pattern)\n case pattern\n when Regexp then lambda{|p| p =~ pattern}\n when String then lambda{|p| File.fnmatch?(pattern, p)}\n when Proc then pattern\n else raise ArgumentError, \"Expected a Regexp, String, or Proc\"\n end\n end","def resolve_as_file_pattern name\n pattern = /(?:\\b|_)#{Regexp.escape name}(?:\\b|_)/\n all_matching_files.select {|p| p =~ pattern }\n end","def resolve_as_file_pattern name\n pattern = /(?:\\b|_)#{Regexp.escape name}(?:\\b|_)/\n all_matching_files.select {|p| p =~ pattern }\n end","def match(pattern, flags = 0)\n\t\t\t\tpath = pattern.start_with?('/') ? full_path : relative_path\n\t\t\t\t\n\t\t\t\treturn File.fnmatch(pattern, path, flags)\n\t\t\tend","def valid_file_name\n (@file_name.match(/((\\d)|([a-zA-Z])|(_))*.log/).to_s == @file_name)\n end","def relevant_file?(file)\n file.end_with?('_spec.rb')\n end","def test_file\n assert_pattern_match [ \"/directory\", \"component.vwf\", nil, nil ], \"/directory/component.vwf/\"\n end","def validate_file(file)\n if file.respond_to? :read\n src = file.read\n else\n src = read_local_file(file)\n end \n\n return validate_text(src)\n end","def matched_in_patternfile?(filepath, matchthis)\n\n patternlist = []\n\n begin\n open(filepath).each do |l|\n l.chomp!\n\n next if l =~ /^$/\n next if l =~ /^#/\n\n if l =~ /^\\s*(\\S+)/\n m = Regexp.last_match\n log(\"found a non-comment line, transforming [#{l}] into [#{m[1]}]\")\n l.gsub!(l,m[1])\n else\n next l\n end\n\n pattern = %r{#{l}}\n patternlist << pattern\n log(\"appending [#{pattern}] to patternlist for [#{filepath}]\")\n end\n rescue StandardError\n log(\"Problem reading #{filepath}: #{$!}\",:err)\n exit(1)\n end\n\n log(\"list of patterns for #{filepath}: #{patternlist}\")\n\n if matchthis =~ Regexp.union(patternlist)\n log(\"matched #{$~} in #{matchthis}, returning true\")\n return true\n\n else # hostname didn't match anything in patternlist\n log(\"#{matchthis} unmatched, returning false\")\n return nil\n end\n\n end","def validate_file_patterns\n attributes = DSL.attributes.values.select(&:file_patterns?)\n attributes.each do |attrb|\n patterns = consumer.send(attrb.name)\n if patterns.is_a?(Hash)\n patterns = patterns.values.flatten(1)\n end\n patterns.each do |pattern|\n if pattern.start_with?('/')\n error \"File patterns must be relative and cannot start with a \" \\\n \"slash (#{attrb.name}).\"\n end\n end\n end\n end","def check\n file_nil\n if @file.end_with?(\".txt\")\n if File.exist?(@file)\n @f = Command_File.new(@file)\n else\n raise \"File \\\"#{@file}\\\" does not Exist\n Please choose a \\\".txt\\\" file that exists\"\n end\n else\n raise \"Invalid Input File \\\"#{@file}\\\"\n File must end in \\\".txt\\\"\"\n end\n end","def filepath_match?(path, *acceptable_matches)\n acceptable_matches.any? { |match| path.fnmatch?(match, File::FNM_EXTGLOB) }\n end","def filepath_match?(path, *acceptable_matches)\n acceptable_matches.any? { |match| path.fnmatch?(match, File::FNM_EXTGLOB) }\n end","def validate_file_patterns\n attributes = DSL.attributes.values.select(&:file_patterns?)\n attributes.each do |attrb|\n patterns = consumer.send(attrb.name)\n if patterns.is_a?(Hash)\n patterns = patterns.values.flatten(1)\n end\n patterns.each do |pattern|\n if pattern.start_with?('/')\n error '[File Patterns] File patterns must be relative ' \\\n \"and cannot start with a slash (#{attrb.name}).\"\n end\n end\n end\n end","def music_file(file)\n ext_list = $config[\"music_file\"][\"media_extentions\"].gsub(/,/,\"|\")\n \n ext = \".*\\.(#{ext_list})$\" \n name = \"\"\n\n $config['music_file']['regex'].each do |pattern|\n if file =~ /.*#{pattern}#{ext}/i\n name = $1 if $1\n return false if name =~ /^sample/i\n return true\n end\n end\n return false\nend","def check_file\n @files.each do |file|\n case \n when file.fnmatch(\"*Verbale autorizzativo*\") then check_verbale(estrai_allegato(file))\n when file.fnmatch(\"*Prezzi_Offerte*\") then check_controllo_offerte(file)\n when file.fnmatch(\"*Validate_Eni*\") then check_offerte(file)\n when file.fnmatch(\"*Esitate_Eni*\") then check_offerte(file)\n when file.fnmatch(\"*ProgrFisica*\") then check_offerte_pce(file)\n when file.fnmatch(\"*Scheduling & Bilateral Program*\") then check_scheduling_bilateral(file)\n when file.fnmatch(\"*tool autorizzazione offerte belpex*\") then check_tool_belgio(file)\n when file.fnmatch(\"*Export E-prog46_ita.xls\") then check_tool_olanda(file) \n when file.fnmatch(\"*Validate_*_*.docx\") then check_validate_epex(file) \n when file.fnmatch(\"*Esitate_Francia_*.csv\") then check_esitate_epex(file)\n when file.fnmatch(\"*Esitate_Germania_*.csv\") then check_esitate_epex(file) \n when file.fnmatch(\"*Esitate_Svizzera_*.csv\") then check_esitate_epex(file) \n else\n\n end\n end\n end","def contain?(filename); end","def matches(_ext); end","def matches(_ext); end","def glob_match (filenames, pattern)\n\t# Escape the '*', '?', and '.' characters\n\tpattern.gsub!(/[\\*\\?\\.]/, '*' => '.*', '?' => '.', '.' => '\\.') \t\n\tregex = Regexp.new(pattern)\n\t#select returns a new array\n\tfilenames.select do |filename|\n\t\tfilename =~ regex\n\tend\nend","def file_patterns_errors_for_spec(spec, file, platform_name)\n Dir.chdir(config.project_pods_root + spec.name ) do\n messages = []\n messages += check_spec_files_exists(spec, :source_files, platform_name, '*.{h,m,mm,c,cpp}')\n messages += check_spec_files_exists(spec, :resources, platform_name)\n messages << \"license[:file] = '#{spec.license[:file]}' -> did not match any file\" if spec.license[:file] && Pathname.pwd.glob(spec.license[:file]).empty?\n messages.compact\n end\n end","def accept_file(file, name, kind)\n logger.debug \"FileHelper is accepting file: filename=#{file.filename}, name=#{name}, kind=#{kind}\"\n\n fm = FileMagic.new(FileMagic::MAGIC_MIME)\n mime = fm.file file.tempfile.path\n logger.debug \"#{name} has MIME type: #{mime}\"\n\n valid = true\n\n case kind\n when 'image'\n accept = [\"image/png\", \"image/gif\", \"image/bmp\", \"image/tiff\", \"image/jpeg\", \"image/x-ms-bmp\"]\n when 'code'\n accept = [\"text/x-pascal\", \"text/x-c\", \"text/x-c++\", \"text/plain\", \"text/\"]\n when 'document'\n accept = [ # -- one day\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n # --\"application/msword\",\n \"application/pdf\" ]\n valid = pdf_valid? file.tempfile.path\n else\n logger.error \"Unknown type '#{kind}' provided for '#{name}'\"\n return false\n end\n\n # result is true when...\n mime.start_with?(*accept) && valid\n end","def matches?(cmd)\n files_match? && file_content_match?\n end","def file?(path)\n eval(FILE_CHECK, binding, __FILE__, FILE_CHECK_LINE)\n nil\nend","def check_file?(path)\n Actions.check_file path\n rescue FileError\n false\n else true\n end","def glob_match(filenames, pattern)\n pattern = pattern.gsub(/[\\*\\?\\.]/, '*' => '.*', '.' => '\\.', '?' => '.')\n regex = Regexp.new(pattern)\n filenames.select do |filename|\n filename =~ regex\n end\nend","def is_match?(file)\n return Match.new file, 'No Destinatin for file'\n end","def validate_file(file_path)\n if file_path.respond_to? :read\n src = file_path.read\n else\n src = read_local_file(file_path)\n end\n return validate_text(src)\n end","def validate_file(filename)\n return true\nend","def doc_file?(file)\n DOC_FILES.any? do |doc|\n doc.is_a?(Regexp) ? doc.match(file) : doc == file\n end\n end","def glob_match(filenames, pattern)\n\t\n\tnewPattern = pattern.gsub( '*', '.*').gsub( '?', '.')\n\n\treturn filenames.select{|i| i.match(/#{newPattern}/)}\n\t\nend","def match?(path)\n path =~ to_regexp\n end","def match_folder(name, patterns = '*')\n Array(patterns).any? do |pattern|\n if pattern.is_a?(String)\n File.fnmatch(pattern.downcase, name.downcase)\n elsif pattern.is_a?(Regexp)\n name =~ pattern\n else\n nil\n end\n end\n end","def file?(f)\n File.file? f\n end","def ruby_grep(filename, pattern)\n regexp = Regexp.new(pattern)\n File.open(filename, 'r') do |file|\n file.each_line {|line| puts line if regexp =~ line}\n end\nend","def content_exists(file, regex, mode)\n\tooo = File.stat(file)\n\toatime=foo.atime #atime before edit\n\tomtime=foo.mtime #mtime before edit\n\n\tif mode.to_i == 1\n\t\tf = File.open(file, 'r')\n\telse\n\t\tf = File.open(file, 'rb') #Open file in binary mode (utmp/wtmp/etc)\n\tend\n\tfoo = f.readlines #Read file into array we can search through as wel like\n\tf.close\n\tif foo.to_s.match(/#{regex}/im) #Check for needle in haystack :p\n\t\tif mode.to_i == 1\n\t\t\tputs \"#{HC}#{FGRN}Found in Non-Binary File#{FWHT}: #{file}#{RS}\"\n\t\telse\n\t\t\tputs \"#{HC}#{FGRN}Found in Binary File#{FWHT}: #{file}#{RS}\"\n\t\tend\n\t\tocc = foo.to_s.scan(/#{regex}/im).count #How many times does it occur in file?\n\t\tputs \"\\t#{FGRN}Number of Occurances#{FWHT}: #{occ}#{RS}\"\n\tend\n\n\tFile.utime(oatime, omtime, file) #Keep timestamp preserved\nend","def validFile? filename\n if !filename.kind_of? String\n return false\n elsif File.exists? filename\n return File.readable? filename\n else\n return false\n end\nend","def matching_file(spec, path) # :doc:\n glob = \"#{@lib_dirs[spec.object_id]}/#{path}#{SUFFIX_PATTERN}\"\n return true unless Dir[glob].select { |f| File.file?(f) }.empty?\n end","def matches_patterns(relative_path, patterns)\n patterns.each do |pattern|\n if relative_path.fnmatch?(pattern)\n return true\n end\n end\n return false\n end","def single?(file)\n file !~ /\\*/\n end","def check_file(filename)\n lines = []\n line_num = 0\n # Get tags to search in file\n pattern = define_regexp\n # Read lines of file\n File.open(filename, 'r') do |file|\n file.each_line do |line|\n line_num += 1\n lines << [line_num, line] if line =~ /#{pattern}/i\n end\n end\n # Report results in json file\n report_results(filename, lines, 'tags') if @options[:report]\n # Print results if required\n unless @options[:quiet] || lines.empty?\n puts\n @options[:jenkins] ?\n puts(\"=== #{filename} ===\") :\n puts(\"=== #{filename} ===\".bold)\n print_tags(lines)\n end\n 0\n end","def match?(path)\n @regex.match?(path)\n end","def replace(pattern, replacement, file)\n was = sftp.file.open(file, \"r\") { |f| f.read }\n found = case pattern\n when :all, :any, :everything\n log \"replace \\e[1m%s\\e[0m in '%s'\" % [pattern, file]\n true\n when Regexp\n log \"replace \\e[1m%s\\e[0m in '%s'\" % [pattern.inspect, file]\n replacement = was.gsub(pattern, replacement)\n was =~ pattern\n when String\n log \"replace \\e[1m%s\\e[0m in '%s'\" % [\"String\", file]\n replacement = was.gsub(pattern, replacement)\n was.include?(pattern)\n else raise \"%s is not a valid. You can use a String, Regexp or :all, :any and :everything\" % pattern.inspect\n end\n\n if found\n sftp.file.open(file, \"w\") { |f| f.write replacement }\n else\n log \"\\e[31m '%s' does not include your \\e[1mpattern\\e[0m\" % file unless was =~ pattern\n end\n end","def valid_file?(file)\n case file\n when 'exclude.exclude', 'include.include',\n 'include_exclude.exclude', 'include_exclude.include',\n 'env_exclude.env.exclude', 'env_include.env.include',\n 'include_env_exclude.include', 'include_env_exclude.env.exclude',\n 'include_exclude_env_include.exclude',\n 'include_exclude_env_exclude.include',\n 'include_env_include_env_exclude.env.exclude',\n 'exclude_env_include.exclude',\n 'exclude_env_include.env.include',\n /^include_env_include\\..*include$/,\n /^include_exclude_env_include\\..*include$/,\n /^include_exclude_env_exclude\\..*exclude$/,\n /^include_env_include_env_exclude\\..*include$/,\n /^exclude_env_exclude\\..*exclude$/,\n /^env_include_env_exclude\\.env\\./,\n /^exclude_env_include_env_exclude\\.(env\\.|exclude$)/,\n /^include_exclude_env_include_env_exclude\\./,\n /^env_symbol\\..*include$/\n return true\n when /^default\\./, /^exclude\\./, /^include\\./,\n /^env_exclude\\./, /^env_include\\./, /^include_env_include\\./,\n /^include_env_exclude\\./, /^include_exclude_env_include\\./,\n /^include_exclude_env_exclude\\./, /^exclude_env_include\\./,\n /^include_env_include_env_exclude\\./, /^exclude_env_exclude\\./,\n /^env_include_env_exclude\\./, /^exclude_env_include_env_exclude/,\n /^env_symbol\\./\n return false\n end\n\n # Raise an error if the file was not handled by existing logic.\n raise \"Invalid file (#{file}) specified in #{__method__}.\"\n end","def file_matches_criteria?(full_path)\n full_path.file? && proper_ext?(full_path) &&\n !LokaliseRails.skip_file_export.call(full_path)\n end","def matches(ext); end","def match?( path )\n path_matcher =~ path\n end","def validate_file(file_path)\n if file_path.respond_to? :read\n src = file_path.read\n else\n src = read_local_file(file_path)\n end \n # we force the :post mode otherwise it fails for\n # big files\n return validate_text(src, :post)\n end","def capture_file(pattern, file)\n node = ast_from_file(file)\n capture node, pattern\n end","def matches?(pattern); end","def valid_file_type filename\n # avoid hacks that break out of single quotes echoed to shell\n filename.gsub!(\"'\", '')\n `file '#{filename}'`.split(':').last.downcase =~ Regexp.union(*valid_file_types)\n end","def check_format(file)\n \tbegin\n content = file_content(file)\n content = content.split(\"\\n\").reject { |c| c.empty? }\n read_file(content)\n rescue\n raise_error ERROR_READING_FILE\n end\n end","def check_file_existence (file_path)\n \"[ -f '#{file_path}' ]\"\n end","def filter_files(pattern)\n regexp=Regexp.new(pattern || '.*')\n @filtered_files=@files.inject([]) do |matches,file| \n file_without_basepath=file[@basepath.length .. -1]\n matches << file if file_without_basepath=~regexp\n matches\n end\n @table.reloadData\n end","def match(pattern); end","def =~(options)\n options && options[:file].respond_to?(:open) ? true : false\n end","def valid?\n # is it a valid pattern (i.e. does not contain funny characters)? @TODO\n # all characters are valid, except for the /, directory limiter., files cannot start with a dot (hidden files)\n # is the file a web-savvy image?\n valid_types = ['image/jpeg', 'image/png', 'image/gif']\n return false unless valid_types.include? @entry.metadata.mime_type\n # does the file have thumbnails?\n return false unless @entry.metadata.thumb_exists\n # is the file not the special, reserved thumb.*? (see thumb_for_dir)\n # @TODO: return false if basename.match /^thumb\\.[A-z]*$/\n return true\n end","def find_file_by_text (start_dir, file_mask=\"*.*\", text_pattern='')\n match_files = Dir[ File.join(start_dir.split(/\\\\/), \"**\", file_mask)]\n if match_files.length > 0\n file_path = nil\n match_files.each do |file|\n matching_text = File.read(file).include?(text_pattern) rescue false\n if matching_text\n file_path = file\n break\n end\n end\n p \"#{file_path ? 'First searching file is: '+file_path : 'No files found'}\"\n else\n \"No files with mask '#{file_mask}' in directory '#{start_dir}'\"\n end\n end","def test_file(path)\n return File.file?(path)\nend","def whitelist_file(file)\n file = Regexp.new(file) unless file.is_a?(Regexp)\n whitelist_files << file\n whitelist_files.dup\n end","def filter(file, fixture)\n # return ['affix_InterveningEmpty.json'].include?(File.basename(file))\n # File.basename(file) =~ /bugreports_greek/i\n # File.basename(file) =~ /sort_stripmark/i\n # return File.basename(file) =~ /^date_rawparsesimpledate/i\n true\nend","def file?(name)\n File.file?(path(name))\n end","def valid_file?(file,type)\n\tif type == \"csv\"\n\t\tif file.nil?\n\t\t\tputs \"Please provide a source .csv file\"\n\t\t\texit 0\n\t\tend\n\tend\n\tif !File.exists?(file)\n\t\tputs \"#{file} doesn't seem to exist. Please check\\nyour file path and try again.\"\n\t\texit 0\n\tend\n\ttrue\nend","def file?(file_path)\n nlst(file_path)[0] == file_path\n end","def check\n prefix = File.basename(@file)\n if File.exist?(@file)\n @message = \"#{prefix} : Expected file exists\"\n true\n else\n @message = \"#{prefix} : Expected file not found.\"\n false\n end\n end","def scan_file(source_path, filename)\n found = 0\n File.open(source_path) do |source_file|\n source_file.each do |line|\n if line.include?(MAGIC_STRING)\n found += 1\n end\n end\n end\n\n if found == 0\n @stats.record_no_tag(filename, source_path)\n elsif found == 1\n @stats.record_tag(filename)\n else\n raise(\"File contains #{found} license lines: #{source_path}\")\n end\n end","def check_file(path)\n raise Error, \"The path '#{path}' does not exist or is not a file\" unless path.file? || attrs[:exists] == false\n end","def user_path?(file); end"],"string":"[\n \"def assert_match_in_file(pattern, file)\\n File.file?(file) ? assert_match(pattern, File.read(file)) : assert_file_exists(file)\\n end\",\n \"def pattern_match(file, pattern)\\n case\\n when pattern.is_a?(Regexp)\\n return file.match(pattern)\\n when pattern.is_a?(String)\\n return File.fnmatch(pattern, file)\\n when pattern.is_a?(Proc)\\n return pattern.call(file)\\n when pattern.is_a?(Rake::FileTask)\\n return pattern.to_s.match(file)\\n else\\n raise \\\"Cannot interpret pattern #{pattern}\\\"\\n end\\n end\",\n \"def assert_match_in_file(pattern, file)\\n assert File.exist?(file), \\\"File '#{file}' does not exist!\\\"\\n assert_match pattern, File.read(file)\\n end\",\n \"def assert_match_in_file(pattern, file)\\n assert File.exist?(file), \\\"File '#{file}' does not exist!\\\"\\n assert_match pattern, File.read(file)\\n end\",\n \"def file_contains(filename, pattern)\\n unless pattern.kind_of?(Regexp)\\n pattern = Regexp.new(pattern)\\n end\\n detected = nil\\n File.open(filename) { |f|\\n detected = f.detect { |line|\\n line =~ pattern\\n }\\n }\\n ! detected.nil?\\n end\",\n \"def file_match(file)\\n end\",\n \"def fnmatch(pattern, *args) File.fnmatch(pattern, path, *args) end\",\n \"def fnmatch?( pattern, *args ) File.fnmatch?( pattern, self, *args ) end\",\n \"def fnmatch?(pattern, *args) File.fnmatch?(pattern, @path, *args) end\",\n \"def fnmatch(pattern, *args) File.fnmatch(pattern, @path, *args) end\",\n \"def fnmatch?(pattern, *args) File.fnmatch?(pattern, path, *args) end\",\n \"def fnmatch( pattern, *args ) File.fnmatch( pattern, self, *args ) end\",\n \"def match_against filename\\n @regexp.match(filename)\\n end\",\n \"def filename_matches_pattern?(filename)\\n @file_matchers.each do |pattern|\\n return true if File.fnmatch(pattern, filename)\\n end\\n return false\\n end\",\n \"def is_valid_file_name?(filename)\\n return $filepattern.match(filename)\\nend\",\n \"def matching_file_regex\\n file_regex ? file_regex : /\\\\.js$/\\n end\",\n \"def validate_file(file)\\n end\",\n \"def matches_filename?(filename)\\r\\n basename = File.basename(filename)\\r\\n @glob_patterns.any? {|pattern| File.fnmatch pattern, basename.downcase}\\r\\n end\",\n \"def check_file_patterns\\n FILE_PATTERNS.each do |attr_name|\\n if respond_to?(\\\"_validate_#{attr_name}\\\", true)\\n send(\\\"_validate_#{attr_name}\\\")\\n else\\n validate_nonempty_patterns(attr_name, :error)\\n end\\n end\\n\\n _validate_header_mappings_dir\\n if consumer.spec.root?\\n _validate_license\\n _validate_module_map\\n end\\n end\",\n \"def search_file(pattern, file)\\n node = ast_from_file(file)\\n search node, pattern\\n end\",\n \"def matches_path?(pattern, path)\\n File.fnmatch?(\\n pattern, path,\\n File::FNM_PATHNAME | # Wildcard doesn't match separator\\n File::FNM_DOTMATCH # Wildcards match dotfiles\\n )\\n end\",\n \"def file_pattern(name)\\n if name.to_s !~ FILE_PATTERN_NAME_REGEX\\n raise ArgumentError.new(\\\"A file pattern name must match this regex: #{ FILE_PATTERN_NAME_REGEX.inspect }\\\")\\n end\\n get_config_val(@file_patterns, name)\\n end\",\n \"def matches_file?(f)\\r\\n @magics.any? {|m| m =~ f }\\r\\n end\",\n \"def file_pattern( pattern )\\n self.class_eval { @file_pattern = pattern }\\n end\",\n \"def matches_path?(pattern, path); end\",\n \"def valid_file?(path)\\n case path\\n when %r|/abcdef$|, %r|^\\\\./tmp/db/\\\\w+?/database.yml$|\\n return false\\n end\\n return true\\n end\",\n \"def matches?(file); matches_exprs?(file,[@reg_expr]); end\",\n \"def gsub_file_with_match_check(relative_destination, regexp, *args, &block)\\n path = destination_path(relative_destination)\\n matches = File.read(path).match(regexp)\\n raise \\\"Regexp not found in #{relative_destination}\\\\n called from #{caller.first}\\\" unless matches\\n gsub_file(relative_destination, regexp, *args, &block)\\nend\",\n \"def grep_file(file_path, grep_pattern)\\n logc(\\\"method: #{__method__}, params: #{file_path}, #{grep_pattern}\\\")\\n\\n # with File.open(file_path, 'r').each.grep(grep_pattern) possible invalid byte sequence in UTF-8 (ArgumentError)\\n # so we use \\\"match\\\" to check if line match pattern and 'scrub' to skip bad encoding symbols\\n res = []\\n File.open(file_path, 'r').each {|line| res << line if line.scrub.match(grep_pattern)}\\n return res\\nend\",\n \"def glob_matches?(rule)\\n File.fnmatch?(rule, @host_name)\\n end\",\n \"def check(filename)\\r\\n check_special(filename) ||\\r\\n open(filename) { |f|\\r\\n check_magics_gt80(f) ||\\r\\n check_globs(filename) ||\\r\\n check_magics_lt80(f) ||\\r\\n check_default(f)\\r\\n }\\r\\n end\",\n \"def only(files,patterns)\\n if !patterns.kind_of?(Array)\\n patterns = [patterns]\\n end\\n files.select do |file|\\n matches = false\\n patterns.each do |pattern|\\n if File.fnmatch(pattern,file)\\n matches = true\\n break\\n end\\n end\\n matches\\n end\\n end\",\n \"def matchFn(filename)\\n\\treturn [\\\".txt\\\", \\\".pdf\\\"].include? File.extname(filename)\\nend\",\n \"def matcher(pattern)\\n case pattern\\n when Regexp then lambda{|p| p =~ pattern}\\n when String then lambda{|p| File.fnmatch?(pattern, p)}\\n when Proc then pattern\\n else raise ArgumentError, \\\"Expected a Regexp, String, or Proc\\\"\\n end\\n end\",\n \"def resolve_as_file_pattern name\\n pattern = /(?:\\\\b|_)#{Regexp.escape name}(?:\\\\b|_)/\\n all_matching_files.select {|p| p =~ pattern }\\n end\",\n \"def resolve_as_file_pattern name\\n pattern = /(?:\\\\b|_)#{Regexp.escape name}(?:\\\\b|_)/\\n all_matching_files.select {|p| p =~ pattern }\\n end\",\n \"def match(pattern, flags = 0)\\n\\t\\t\\t\\tpath = pattern.start_with?('/') ? full_path : relative_path\\n\\t\\t\\t\\t\\n\\t\\t\\t\\treturn File.fnmatch(pattern, path, flags)\\n\\t\\t\\tend\",\n \"def valid_file_name\\n (@file_name.match(/((\\\\d)|([a-zA-Z])|(_))*.log/).to_s == @file_name)\\n end\",\n \"def relevant_file?(file)\\n file.end_with?('_spec.rb')\\n end\",\n \"def test_file\\n assert_pattern_match [ \\\"/directory\\\", \\\"component.vwf\\\", nil, nil ], \\\"/directory/component.vwf/\\\"\\n end\",\n \"def validate_file(file)\\n if file.respond_to? :read\\n src = file.read\\n else\\n src = read_local_file(file)\\n end \\n\\n return validate_text(src)\\n end\",\n \"def matched_in_patternfile?(filepath, matchthis)\\n\\n patternlist = []\\n\\n begin\\n open(filepath).each do |l|\\n l.chomp!\\n\\n next if l =~ /^$/\\n next if l =~ /^#/\\n\\n if l =~ /^\\\\s*(\\\\S+)/\\n m = Regexp.last_match\\n log(\\\"found a non-comment line, transforming [#{l}] into [#{m[1]}]\\\")\\n l.gsub!(l,m[1])\\n else\\n next l\\n end\\n\\n pattern = %r{#{l}}\\n patternlist << pattern\\n log(\\\"appending [#{pattern}] to patternlist for [#{filepath}]\\\")\\n end\\n rescue StandardError\\n log(\\\"Problem reading #{filepath}: #{$!}\\\",:err)\\n exit(1)\\n end\\n\\n log(\\\"list of patterns for #{filepath}: #{patternlist}\\\")\\n\\n if matchthis =~ Regexp.union(patternlist)\\n log(\\\"matched #{$~} in #{matchthis}, returning true\\\")\\n return true\\n\\n else # hostname didn't match anything in patternlist\\n log(\\\"#{matchthis} unmatched, returning false\\\")\\n return nil\\n end\\n\\n end\",\n \"def validate_file_patterns\\n attributes = DSL.attributes.values.select(&:file_patterns?)\\n attributes.each do |attrb|\\n patterns = consumer.send(attrb.name)\\n if patterns.is_a?(Hash)\\n patterns = patterns.values.flatten(1)\\n end\\n patterns.each do |pattern|\\n if pattern.start_with?('/')\\n error \\\"File patterns must be relative and cannot start with a \\\" \\\\\\n \\\"slash (#{attrb.name}).\\\"\\n end\\n end\\n end\\n end\",\n \"def check\\n file_nil\\n if @file.end_with?(\\\".txt\\\")\\n if File.exist?(@file)\\n @f = Command_File.new(@file)\\n else\\n raise \\\"File \\\\\\\"#{@file}\\\\\\\" does not Exist\\n Please choose a \\\\\\\".txt\\\\\\\" file that exists\\\"\\n end\\n else\\n raise \\\"Invalid Input File \\\\\\\"#{@file}\\\\\\\"\\n File must end in \\\\\\\".txt\\\\\\\"\\\"\\n end\\n end\",\n \"def filepath_match?(path, *acceptable_matches)\\n acceptable_matches.any? { |match| path.fnmatch?(match, File::FNM_EXTGLOB) }\\n end\",\n \"def filepath_match?(path, *acceptable_matches)\\n acceptable_matches.any? { |match| path.fnmatch?(match, File::FNM_EXTGLOB) }\\n end\",\n \"def validate_file_patterns\\n attributes = DSL.attributes.values.select(&:file_patterns?)\\n attributes.each do |attrb|\\n patterns = consumer.send(attrb.name)\\n if patterns.is_a?(Hash)\\n patterns = patterns.values.flatten(1)\\n end\\n patterns.each do |pattern|\\n if pattern.start_with?('/')\\n error '[File Patterns] File patterns must be relative ' \\\\\\n \\\"and cannot start with a slash (#{attrb.name}).\\\"\\n end\\n end\\n end\\n end\",\n \"def music_file(file)\\n ext_list = $config[\\\"music_file\\\"][\\\"media_extentions\\\"].gsub(/,/,\\\"|\\\")\\n \\n ext = \\\".*\\\\.(#{ext_list})$\\\" \\n name = \\\"\\\"\\n\\n $config['music_file']['regex'].each do |pattern|\\n if file =~ /.*#{pattern}#{ext}/i\\n name = $1 if $1\\n return false if name =~ /^sample/i\\n return true\\n end\\n end\\n return false\\nend\",\n \"def check_file\\n @files.each do |file|\\n case \\n when file.fnmatch(\\\"*Verbale autorizzativo*\\\") then check_verbale(estrai_allegato(file))\\n when file.fnmatch(\\\"*Prezzi_Offerte*\\\") then check_controllo_offerte(file)\\n when file.fnmatch(\\\"*Validate_Eni*\\\") then check_offerte(file)\\n when file.fnmatch(\\\"*Esitate_Eni*\\\") then check_offerte(file)\\n when file.fnmatch(\\\"*ProgrFisica*\\\") then check_offerte_pce(file)\\n when file.fnmatch(\\\"*Scheduling & Bilateral Program*\\\") then check_scheduling_bilateral(file)\\n when file.fnmatch(\\\"*tool autorizzazione offerte belpex*\\\") then check_tool_belgio(file)\\n when file.fnmatch(\\\"*Export E-prog46_ita.xls\\\") then check_tool_olanda(file) \\n when file.fnmatch(\\\"*Validate_*_*.docx\\\") then check_validate_epex(file) \\n when file.fnmatch(\\\"*Esitate_Francia_*.csv\\\") then check_esitate_epex(file)\\n when file.fnmatch(\\\"*Esitate_Germania_*.csv\\\") then check_esitate_epex(file) \\n when file.fnmatch(\\\"*Esitate_Svizzera_*.csv\\\") then check_esitate_epex(file) \\n else\\n\\n end\\n end\\n end\",\n \"def contain?(filename); end\",\n \"def matches(_ext); end\",\n \"def matches(_ext); end\",\n \"def glob_match (filenames, pattern)\\n\\t# Escape the '*', '?', and '.' characters\\n\\tpattern.gsub!(/[\\\\*\\\\?\\\\.]/, '*' => '.*', '?' => '.', '.' => '\\\\.') \\t\\n\\tregex = Regexp.new(pattern)\\n\\t#select returns a new array\\n\\tfilenames.select do |filename|\\n\\t\\tfilename =~ regex\\n\\tend\\nend\",\n \"def file_patterns_errors_for_spec(spec, file, platform_name)\\n Dir.chdir(config.project_pods_root + spec.name ) do\\n messages = []\\n messages += check_spec_files_exists(spec, :source_files, platform_name, '*.{h,m,mm,c,cpp}')\\n messages += check_spec_files_exists(spec, :resources, platform_name)\\n messages << \\\"license[:file] = '#{spec.license[:file]}' -> did not match any file\\\" if spec.license[:file] && Pathname.pwd.glob(spec.license[:file]).empty?\\n messages.compact\\n end\\n end\",\n \"def accept_file(file, name, kind)\\n logger.debug \\\"FileHelper is accepting file: filename=#{file.filename}, name=#{name}, kind=#{kind}\\\"\\n\\n fm = FileMagic.new(FileMagic::MAGIC_MIME)\\n mime = fm.file file.tempfile.path\\n logger.debug \\\"#{name} has MIME type: #{mime}\\\"\\n\\n valid = true\\n\\n case kind\\n when 'image'\\n accept = [\\\"image/png\\\", \\\"image/gif\\\", \\\"image/bmp\\\", \\\"image/tiff\\\", \\\"image/jpeg\\\", \\\"image/x-ms-bmp\\\"]\\n when 'code'\\n accept = [\\\"text/x-pascal\\\", \\\"text/x-c\\\", \\\"text/x-c++\\\", \\\"text/plain\\\", \\\"text/\\\"]\\n when 'document'\\n accept = [ # -- one day\\\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\\\",\\n # --\\\"application/msword\\\",\\n \\\"application/pdf\\\" ]\\n valid = pdf_valid? file.tempfile.path\\n else\\n logger.error \\\"Unknown type '#{kind}' provided for '#{name}'\\\"\\n return false\\n end\\n\\n # result is true when...\\n mime.start_with?(*accept) && valid\\n end\",\n \"def matches?(cmd)\\n files_match? && file_content_match?\\n end\",\n \"def file?(path)\\n eval(FILE_CHECK, binding, __FILE__, FILE_CHECK_LINE)\\n nil\\nend\",\n \"def check_file?(path)\\n Actions.check_file path\\n rescue FileError\\n false\\n else true\\n end\",\n \"def glob_match(filenames, pattern)\\n pattern = pattern.gsub(/[\\\\*\\\\?\\\\.]/, '*' => '.*', '.' => '\\\\.', '?' => '.')\\n regex = Regexp.new(pattern)\\n filenames.select do |filename|\\n filename =~ regex\\n end\\nend\",\n \"def is_match?(file)\\n return Match.new file, 'No Destinatin for file'\\n end\",\n \"def validate_file(file_path)\\n if file_path.respond_to? :read\\n src = file_path.read\\n else\\n src = read_local_file(file_path)\\n end\\n return validate_text(src)\\n end\",\n \"def validate_file(filename)\\n return true\\nend\",\n \"def doc_file?(file)\\n DOC_FILES.any? do |doc|\\n doc.is_a?(Regexp) ? doc.match(file) : doc == file\\n end\\n end\",\n \"def glob_match(filenames, pattern)\\n\\t\\n\\tnewPattern = pattern.gsub( '*', '.*').gsub( '?', '.')\\n\\n\\treturn filenames.select{|i| i.match(/#{newPattern}/)}\\n\\t\\nend\",\n \"def match?(path)\\n path =~ to_regexp\\n end\",\n \"def match_folder(name, patterns = '*')\\n Array(patterns).any? do |pattern|\\n if pattern.is_a?(String)\\n File.fnmatch(pattern.downcase, name.downcase)\\n elsif pattern.is_a?(Regexp)\\n name =~ pattern\\n else\\n nil\\n end\\n end\\n end\",\n \"def file?(f)\\n File.file? f\\n end\",\n \"def ruby_grep(filename, pattern)\\n regexp = Regexp.new(pattern)\\n File.open(filename, 'r') do |file|\\n file.each_line {|line| puts line if regexp =~ line}\\n end\\nend\",\n \"def content_exists(file, regex, mode)\\n\\tooo = File.stat(file)\\n\\toatime=foo.atime #atime before edit\\n\\tomtime=foo.mtime #mtime before edit\\n\\n\\tif mode.to_i == 1\\n\\t\\tf = File.open(file, 'r')\\n\\telse\\n\\t\\tf = File.open(file, 'rb') #Open file in binary mode (utmp/wtmp/etc)\\n\\tend\\n\\tfoo = f.readlines #Read file into array we can search through as wel like\\n\\tf.close\\n\\tif foo.to_s.match(/#{regex}/im) #Check for needle in haystack :p\\n\\t\\tif mode.to_i == 1\\n\\t\\t\\tputs \\\"#{HC}#{FGRN}Found in Non-Binary File#{FWHT}: #{file}#{RS}\\\"\\n\\t\\telse\\n\\t\\t\\tputs \\\"#{HC}#{FGRN}Found in Binary File#{FWHT}: #{file}#{RS}\\\"\\n\\t\\tend\\n\\t\\tocc = foo.to_s.scan(/#{regex}/im).count #How many times does it occur in file?\\n\\t\\tputs \\\"\\\\t#{FGRN}Number of Occurances#{FWHT}: #{occ}#{RS}\\\"\\n\\tend\\n\\n\\tFile.utime(oatime, omtime, file) #Keep timestamp preserved\\nend\",\n \"def validFile? filename\\n if !filename.kind_of? String\\n return false\\n elsif File.exists? filename\\n return File.readable? filename\\n else\\n return false\\n end\\nend\",\n \"def matching_file(spec, path) # :doc:\\n glob = \\\"#{@lib_dirs[spec.object_id]}/#{path}#{SUFFIX_PATTERN}\\\"\\n return true unless Dir[glob].select { |f| File.file?(f) }.empty?\\n end\",\n \"def matches_patterns(relative_path, patterns)\\n patterns.each do |pattern|\\n if relative_path.fnmatch?(pattern)\\n return true\\n end\\n end\\n return false\\n end\",\n \"def single?(file)\\n file !~ /\\\\*/\\n end\",\n \"def check_file(filename)\\n lines = []\\n line_num = 0\\n # Get tags to search in file\\n pattern = define_regexp\\n # Read lines of file\\n File.open(filename, 'r') do |file|\\n file.each_line do |line|\\n line_num += 1\\n lines << [line_num, line] if line =~ /#{pattern}/i\\n end\\n end\\n # Report results in json file\\n report_results(filename, lines, 'tags') if @options[:report]\\n # Print results if required\\n unless @options[:quiet] || lines.empty?\\n puts\\n @options[:jenkins] ?\\n puts(\\\"=== #{filename} ===\\\") :\\n puts(\\\"=== #{filename} ===\\\".bold)\\n print_tags(lines)\\n end\\n 0\\n end\",\n \"def match?(path)\\n @regex.match?(path)\\n end\",\n \"def replace(pattern, replacement, file)\\n was = sftp.file.open(file, \\\"r\\\") { |f| f.read }\\n found = case pattern\\n when :all, :any, :everything\\n log \\\"replace \\\\e[1m%s\\\\e[0m in '%s'\\\" % [pattern, file]\\n true\\n when Regexp\\n log \\\"replace \\\\e[1m%s\\\\e[0m in '%s'\\\" % [pattern.inspect, file]\\n replacement = was.gsub(pattern, replacement)\\n was =~ pattern\\n when String\\n log \\\"replace \\\\e[1m%s\\\\e[0m in '%s'\\\" % [\\\"String\\\", file]\\n replacement = was.gsub(pattern, replacement)\\n was.include?(pattern)\\n else raise \\\"%s is not a valid. You can use a String, Regexp or :all, :any and :everything\\\" % pattern.inspect\\n end\\n\\n if found\\n sftp.file.open(file, \\\"w\\\") { |f| f.write replacement }\\n else\\n log \\\"\\\\e[31m '%s' does not include your \\\\e[1mpattern\\\\e[0m\\\" % file unless was =~ pattern\\n end\\n end\",\n \"def valid_file?(file)\\n case file\\n when 'exclude.exclude', 'include.include',\\n 'include_exclude.exclude', 'include_exclude.include',\\n 'env_exclude.env.exclude', 'env_include.env.include',\\n 'include_env_exclude.include', 'include_env_exclude.env.exclude',\\n 'include_exclude_env_include.exclude',\\n 'include_exclude_env_exclude.include',\\n 'include_env_include_env_exclude.env.exclude',\\n 'exclude_env_include.exclude',\\n 'exclude_env_include.env.include',\\n /^include_env_include\\\\..*include$/,\\n /^include_exclude_env_include\\\\..*include$/,\\n /^include_exclude_env_exclude\\\\..*exclude$/,\\n /^include_env_include_env_exclude\\\\..*include$/,\\n /^exclude_env_exclude\\\\..*exclude$/,\\n /^env_include_env_exclude\\\\.env\\\\./,\\n /^exclude_env_include_env_exclude\\\\.(env\\\\.|exclude$)/,\\n /^include_exclude_env_include_env_exclude\\\\./,\\n /^env_symbol\\\\..*include$/\\n return true\\n when /^default\\\\./, /^exclude\\\\./, /^include\\\\./,\\n /^env_exclude\\\\./, /^env_include\\\\./, /^include_env_include\\\\./,\\n /^include_env_exclude\\\\./, /^include_exclude_env_include\\\\./,\\n /^include_exclude_env_exclude\\\\./, /^exclude_env_include\\\\./,\\n /^include_env_include_env_exclude\\\\./, /^exclude_env_exclude\\\\./,\\n /^env_include_env_exclude\\\\./, /^exclude_env_include_env_exclude/,\\n /^env_symbol\\\\./\\n return false\\n end\\n\\n # Raise an error if the file was not handled by existing logic.\\n raise \\\"Invalid file (#{file}) specified in #{__method__}.\\\"\\n end\",\n \"def file_matches_criteria?(full_path)\\n full_path.file? && proper_ext?(full_path) &&\\n !LokaliseRails.skip_file_export.call(full_path)\\n end\",\n \"def matches(ext); end\",\n \"def match?( path )\\n path_matcher =~ path\\n end\",\n \"def validate_file(file_path)\\n if file_path.respond_to? :read\\n src = file_path.read\\n else\\n src = read_local_file(file_path)\\n end \\n # we force the :post mode otherwise it fails for\\n # big files\\n return validate_text(src, :post)\\n end\",\n \"def capture_file(pattern, file)\\n node = ast_from_file(file)\\n capture node, pattern\\n end\",\n \"def matches?(pattern); end\",\n \"def valid_file_type filename\\n # avoid hacks that break out of single quotes echoed to shell\\n filename.gsub!(\\\"'\\\", '')\\n `file '#{filename}'`.split(':').last.downcase =~ Regexp.union(*valid_file_types)\\n end\",\n \"def check_format(file)\\n \\tbegin\\n content = file_content(file)\\n content = content.split(\\\"\\\\n\\\").reject { |c| c.empty? }\\n read_file(content)\\n rescue\\n raise_error ERROR_READING_FILE\\n end\\n end\",\n \"def check_file_existence (file_path)\\n \\\"[ -f '#{file_path}' ]\\\"\\n end\",\n \"def filter_files(pattern)\\n regexp=Regexp.new(pattern || '.*')\\n @filtered_files=@files.inject([]) do |matches,file| \\n file_without_basepath=file[@basepath.length .. -1]\\n matches << file if file_without_basepath=~regexp\\n matches\\n end\\n @table.reloadData\\n end\",\n \"def match(pattern); end\",\n \"def =~(options)\\n options && options[:file].respond_to?(:open) ? true : false\\n end\",\n \"def valid?\\n # is it a valid pattern (i.e. does not contain funny characters)? @TODO\\n # all characters are valid, except for the /, directory limiter., files cannot start with a dot (hidden files)\\n # is the file a web-savvy image?\\n valid_types = ['image/jpeg', 'image/png', 'image/gif']\\n return false unless valid_types.include? @entry.metadata.mime_type\\n # does the file have thumbnails?\\n return false unless @entry.metadata.thumb_exists\\n # is the file not the special, reserved thumb.*? (see thumb_for_dir)\\n # @TODO: return false if basename.match /^thumb\\\\.[A-z]*$/\\n return true\\n end\",\n \"def find_file_by_text (start_dir, file_mask=\\\"*.*\\\", text_pattern='')\\n match_files = Dir[ File.join(start_dir.split(/\\\\\\\\/), \\\"**\\\", file_mask)]\\n if match_files.length > 0\\n file_path = nil\\n match_files.each do |file|\\n matching_text = File.read(file).include?(text_pattern) rescue false\\n if matching_text\\n file_path = file\\n break\\n end\\n end\\n p \\\"#{file_path ? 'First searching file is: '+file_path : 'No files found'}\\\"\\n else\\n \\\"No files with mask '#{file_mask}' in directory '#{start_dir}'\\\"\\n end\\n end\",\n \"def test_file(path)\\n return File.file?(path)\\nend\",\n \"def whitelist_file(file)\\n file = Regexp.new(file) unless file.is_a?(Regexp)\\n whitelist_files << file\\n whitelist_files.dup\\n end\",\n \"def filter(file, fixture)\\n # return ['affix_InterveningEmpty.json'].include?(File.basename(file))\\n # File.basename(file) =~ /bugreports_greek/i\\n # File.basename(file) =~ /sort_stripmark/i\\n # return File.basename(file) =~ /^date_rawparsesimpledate/i\\n true\\nend\",\n \"def file?(name)\\n File.file?(path(name))\\n end\",\n \"def valid_file?(file,type)\\n\\tif type == \\\"csv\\\"\\n\\t\\tif file.nil?\\n\\t\\t\\tputs \\\"Please provide a source .csv file\\\"\\n\\t\\t\\texit 0\\n\\t\\tend\\n\\tend\\n\\tif !File.exists?(file)\\n\\t\\tputs \\\"#{file} doesn't seem to exist. Please check\\\\nyour file path and try again.\\\"\\n\\t\\texit 0\\n\\tend\\n\\ttrue\\nend\",\n \"def file?(file_path)\\n nlst(file_path)[0] == file_path\\n end\",\n \"def check\\n prefix = File.basename(@file)\\n if File.exist?(@file)\\n @message = \\\"#{prefix} : Expected file exists\\\"\\n true\\n else\\n @message = \\\"#{prefix} : Expected file not found.\\\"\\n false\\n end\\n end\",\n \"def scan_file(source_path, filename)\\n found = 0\\n File.open(source_path) do |source_file|\\n source_file.each do |line|\\n if line.include?(MAGIC_STRING)\\n found += 1\\n end\\n end\\n end\\n\\n if found == 0\\n @stats.record_no_tag(filename, source_path)\\n elsif found == 1\\n @stats.record_tag(filename)\\n else\\n raise(\\\"File contains #{found} license lines: #{source_path}\\\")\\n end\\n end\",\n \"def check_file(path)\\n raise Error, \\\"The path '#{path}' does not exist or is not a file\\\" unless path.file? || attrs[:exists] == false\\n end\",\n \"def user_path?(file); end\"\n]"},"negative_scores":{"kind":"list like","value":["0.79040873","0.7767663","0.76429737","0.76429737","0.7590968","0.7568827","0.7403286","0.7375396","0.73636085","0.7363439","0.7358617","0.7326869","0.7273945","0.7269795","0.7238025","0.6862911","0.68055886","0.6743549","0.6728241","0.66884166","0.6675093","0.6653235","0.6576527","0.6548926","0.6543279","0.648704","0.64228153","0.6417274","0.6408644","0.63953525","0.6373208","0.63664865","0.6366071","0.6348171","0.628341","0.628341","0.6257425","0.6219057","0.6213776","0.62120414","0.6209805","0.6204705","0.6187954","0.6182593","0.61798555","0.61798555","0.61789584","0.6174286","0.61536515","0.61442995","0.6141073","0.6141073","0.61215436","0.6116957","0.61150265","0.6113575","0.61111933","0.60989046","0.6092424","0.60879904","0.60763025","0.6043449","0.6012909","0.5998234","0.59977925","0.59867334","0.59781486","0.59718806","0.59716934","0.5966373","0.59617513","0.59460914","0.5940775","0.5939083","0.593737","0.5928927","0.5920568","0.59139985","0.5909214","0.5905697","0.5896314","0.5890101","0.5887249","0.58824915","0.58808404","0.58591664","0.5849631","0.58466077","0.5844259","0.582351","0.58223397","0.58166903","0.5798955","0.5783257","0.5783222","0.57816815","0.57760787","0.5766191","0.5755416","0.57457507","0.57445884"],"string":"[\n \"0.79040873\",\n \"0.7767663\",\n \"0.76429737\",\n \"0.76429737\",\n \"0.7590968\",\n \"0.7568827\",\n \"0.7403286\",\n \"0.7375396\",\n \"0.73636085\",\n \"0.7363439\",\n \"0.7358617\",\n \"0.7326869\",\n \"0.7273945\",\n \"0.7269795\",\n \"0.7238025\",\n \"0.6862911\",\n \"0.68055886\",\n \"0.6743549\",\n \"0.6728241\",\n \"0.66884166\",\n \"0.6675093\",\n \"0.6653235\",\n \"0.6576527\",\n \"0.6548926\",\n \"0.6543279\",\n \"0.648704\",\n \"0.64228153\",\n \"0.6417274\",\n \"0.6408644\",\n \"0.63953525\",\n \"0.6373208\",\n \"0.63664865\",\n \"0.6366071\",\n \"0.6348171\",\n \"0.628341\",\n \"0.628341\",\n \"0.6257425\",\n \"0.6219057\",\n \"0.6213776\",\n \"0.62120414\",\n \"0.6209805\",\n \"0.6204705\",\n \"0.6187954\",\n \"0.6182593\",\n \"0.61798555\",\n \"0.61798555\",\n \"0.61789584\",\n \"0.6174286\",\n \"0.61536515\",\n \"0.61442995\",\n \"0.6141073\",\n \"0.6141073\",\n \"0.61215436\",\n \"0.6116957\",\n \"0.61150265\",\n \"0.6113575\",\n \"0.61111933\",\n \"0.60989046\",\n \"0.6092424\",\n \"0.60879904\",\n \"0.60763025\",\n \"0.6043449\",\n \"0.6012909\",\n \"0.5998234\",\n \"0.59977925\",\n \"0.59867334\",\n \"0.59781486\",\n \"0.59718806\",\n \"0.59716934\",\n \"0.5966373\",\n \"0.59617513\",\n \"0.59460914\",\n \"0.5940775\",\n \"0.5939083\",\n \"0.593737\",\n \"0.5928927\",\n \"0.5920568\",\n \"0.59139985\",\n \"0.5909214\",\n \"0.5905697\",\n \"0.5896314\",\n \"0.5890101\",\n \"0.5887249\",\n \"0.58824915\",\n \"0.58808404\",\n \"0.58591664\",\n \"0.5849631\",\n \"0.58466077\",\n \"0.5844259\",\n \"0.582351\",\n \"0.58223397\",\n \"0.58166903\",\n \"0.5798955\",\n \"0.5783257\",\n \"0.5783222\",\n \"0.57816815\",\n \"0.57760787\",\n \"0.5766191\",\n \"0.5755416\",\n \"0.57457507\",\n \"0.57445884\"\n]"},"document_score":{"kind":"string","value":"0.0"},"document_rank":{"kind":"string","value":"-1"}}},{"rowIdx":125,"cells":{"query":{"kind":"string","value":"GET /stay_times GET /stay_times.json"},"document":{"kind":"string","value":"def index\n @stay_times = StayTime.all\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def index\n @service_times = ServiceTime.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @service_times }\n end\n end","def index\n @tea_times = TeaTime.all\n respond_to do |format|\n format.html { render layout: !request.xhr? }\n format.json { render json: @tea_times }\n end\n end","def index\n render json: {time: Time.now}\n end","def show\n @time_gap = TimeGap.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_gap }\n end\n end","def hours\n render json: Pings::Selector.new.hours(params)\n end","def index\n @days = @trip.days.order(trip_day: :asc)\n render json: @days, include: [:activities]\n end","def index\n @mealtimes = Mealtime.all\n end","def index\n @time_entry ||= current_user.time_entries.build(\n :tdate => Date.today\n )\n \n @time_entries = current_firm.all_time_entries\n\n respond_to do |format|\n format.html { render :index }# index.html.erb\n format.json { render json: @time_entries }\n end\n end","def show\n render json: @timer\n end","def index\n @timecards = TimeCard.all\n render :json => @timecards.to_json(:include => :time_entry), status: :ok\n end","def query_times_graphs\n controller = params[:controller_name]\n action = params[:action_name]\n data = redis(logger: true).zrangebyscore(\"request_timings/total/by_action/#{controller}##{action}\",\n 1.month.ago.to_i, '+inf',\n with_scores: true)\n .map { |y, x| [x.to_f, y.to_f] }\n throw 'No Data' if data.nil? || data.empty?\n smoothed = moving_avg(data)\n final = (params[:raw].present? ? data : smoothed).map { |x, y| [Time.at(x.to_i).to_datetime, y] }\n render json: [\n { name: 'Timings', data: final }\n ]\n end","def index\n @timers = Timer.all\n\n render json: @timers\n end","def index\n\n @hurdle_times = HurdleTime.order('time, hurdle_match_id, lane')\n\n if params[:hurdle_match_id]\n @hurdle_times = @hurdle_times.where(:hurdle_match_id => params[:hurdle_match_id])\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hurdle_times }\n end\n end","def show\n\n trip = Trip.find(params[:id])\n\n departureOrder = LineStation.find_by_station_id(trip.departureStation_id).order\n arrivalOrder = LineStation.find_by_station_id(trip.arrivalStation_id).order\n\n lineStations = LineStation.where(:order => departureOrder..arrivalOrder)\n lineStations = lineStations.where(:line_id => trip.line_id)\n if departureOrder < arrivalOrder\n lineStations.order('order ASC')\n else\n lineStations.order('order DESC')\n end\n\n times = Array.new\n currentTime = trip.beginTime\n lineStations.each do |ls|\n \n station = Station.find(ls.station_id)\n train = Train.find(trip.train_id)\n\n times << { :station => station, :time => currentTime.strftime('%H:%M') }\n\n timeElapsed = ls.distance.to_f / train.velocity\n currentTime = currentTime + timeElapsed.hours\n end\n\n render :json => { :trip => trip, :times => times }\n\n end","def index\n @location_times = LocationTime.all\n end","def open_appointments\n date = Date.parse(params[:date])\n clinic = Clinic.find(params[:clinic_id])\n doctor = Doctor.find(params[:doctor_id])\n # @times = doctor.open_appointment_times(date)\n @times = clinic.open_appointment_times(date, doctor)\n if @times.is_a?(Hash)\n render json: {status: 1, error: @times[:error]}\n else\n render json: { status: 0, times: @times }\n end\n #@appointment = Appointment.new\n #render json: {open_times: @open_times}\n # render json: {times: [\n # {time: '8:00 AM', enabled: true, selected: false, index: 0},\n # {time: '8:30 AM', enabled: false, selected: false, index: 1},\n # {time: '9:00 AM', enabled: true, selected: false, index: 2},\n # {time: '9:30 AM', enabled: true, selected: false, index: 3},\n # {time: '10:00 AM', enabled: false, selected: false, index: 4},\n # {time: '10:30 AM', enabled: false, selected: false, index: 5},\n # {time: '11:00 AM', enabled: false, selected: false, index: 6},\n # {time: '11:30 AM', enabled: true, selected: false, index: 7},\n # {time: '12:00 PM', enabled: true, selected: false, index: 8},\n # {time: '12:30 PM', enabled: true, selected: false, index: 9},\n # {time: '1:00 PM', enabled: false, selected: false, index: 10},\n # {time: '1:30 PM', enabled: true, selected: false, index: 11},\n # {time: '2:00 PM', enabled: false, selected: false, index: 12},\n # {time: '2:30 PM', enabled: false, selected: false, index: 13},\n # {time: '3:00 PM', enabled: true, selected: false, index: 14},\n # {time: '3:30 PM', enabled: true, selected: false, index: 15},\n # {time: '4:00 PM', enabled: true, selected: false, index: 16},\n # {time: '4:30 PM', enabled: false, selected: false, index: 17},\n # {time: '5:00 PM', enabled: true, selected: false, index: 18},\n # {time: '5:30 PM', enabled: true, selected: false, index: 19}]}\n\n end","def index\n date_range = unix_date(params[:date])\n @timeslots = Timeslot.where('start_time >= ? and start_time <= ?', date_range[:beginning_of_day], date_range[:end_of_day])\n # render :json => @timeslots.as_json(only: [])\n end","def show\n render :json => @timecard.to_json(:include => :time_entry), status: :ok\n end","def index\n @timeslots = Timeslot.all\n end","def index\n @timeslots = Timeslot.all\n end","def index\n @allocated_times = AllocatedTime.all\n end","def index\n @session_times = SessionTime.all\n end","def index\n @cooking_times = CookingTime.all\n end","def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clock_time }\n end\n end","def index\n @clock = @employee.clock_in_out\n render json: @clock\n end","def index\n @wait_times = WaitTime.all\n end","def index\n schedules = Schedule.where(trip_id: params[:trip_id])\n respond_with schedules\n end","def index\n @working_start_times = WorkingStartTime.all\n end","def index\n @meeting_times = MeetingTime.order(:time).all\n end","def index\n @time_of_days = TimeOfDay.all\n end","def getTimes()\n return @times\n end","def index\n @timetables = Timetable.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @timetables }\n end\n end","def index\n @vehicle_realtimes = VehicleRealtime.all\n \n respond_to do |format|\n format.html\n format.json { render :json => @vehicle_realtimes.to_json(:include => [:vehicle_trip, :vehicle_route, :vehicle_stop]) }\n end\n end","def index\n @jobtimes = current_company.jobtimes.find_all_by_job_id(params[:job_id])\n respond_to do |format|\n format.xml {render :xml => @jobtimes }\n format.json { render :json => @jobtimes }\n end\n end","def time_trackings\n Easybill::Api::TimeTrackings\n end","def index\n @timings = Timing.all\n end","def index\n @announces = Announce.not_finished.order(\"stime DESC\")\n\t\t@pannounces = Announce.finished.last_24_hours.limit(20).order(\"etime DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @announces }\n end\n end","def chatting_time(*args)\n @client.get \"#{@path}/chatting_time\", Hash[*args]\n end","def index\n @times_games = TimesGame.all\n end","def index\n @section_times = SectionTime.all\n end","def index\r\n @clocks = ClockResult.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @clocks }\r\n end\r\n end","def index\n streaks = Streak.active.all\n render_jsonapi(streaks)\n end","def index\n @poi_times = PoiTime.all\n end","def index\n @day_timeslots = DayTimeslot.all\n end","def index\n @appointments = Appointment.all \n render json: @appointments\n end","def index\n @class_times = ClassTime.all\n end","def index\n @reservations = @user.reservations\n @reservations_json = []\n @reservations.each do |r|\n ro = r\n r = r.as_json\n %w{arrived email no_show owner_id}.each {|k| r.delete(k)}\n r[:start_time] = ro.start_time_format\n r[:end_time] = ro.end_time_format\n @reservations_json << r\n end\n\n render json: @reservations_json, status: 200 \n end","def station_times(name, mins)\n ier = IERailGet.new(\"getStationDataByNameXML_withNumMins?StationDesc=#{name}&NumMins=#{mins}\", \"arrayofobjstationdata\", \"objstationdata\")\n \n ier.response.map { |sd| StationData.new(sd) }\n end","def show\n @stop_time = StopTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stop_time }\n end\n end","def index\n ok_request current_user, %w(user, opinion_polls, opinion_polls.time_slots)\n end","def index\n @p_times = PTime.all\n end","def region_slots\n if(current_user.customer_id?)\n @timeslots = Timeslot.where(\"region_id = ?\", current_user.customer.region_id)\n else\n @timeslots = Timeslot.where(\"region_id = ?\", current_user.driver.region_id)\n end\n render json: @timeslot, status: 200\n end","def index\n @cal_times = CalTime.paginate(page: params[:page])\n end","def show\n @working_time = WorkingTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @working_time }\n end\n end","def index\n @tombstone_timeholds = TombstoneTimehold.all\n end","def get_data_for_time_span()\n set_schedule_query_params\n\n @t1 = Time.at(@t1.to_i)\n @t2 = Time.at(@t2.to_i)\n\n @rsrcs = @config.resource_list # ScheduledResource.resource_list\n\n @blockss = ScheduledResource.get_all_blocks(@config, @t1, @t2, @inc)\n\n json_adjustments\n end","def set_stay_time\n @stay_time = StayTime.find(params[:id])\n end","def dates\n render json: @standings\n end","def work_schedules\n @work_schedules = WorkSchedule.all\n\n render json: @work_schedules.to_json\n end","def index\n if !time_slot_params[:start].present? && !time_slot_params[:end].present?\n @appointments = Appointment.all\n else\n #time_slot_params[:start], time_slot_params[:end]\n @appointments = Appointment.in_time_slot_only(time_slot_params).all\n end\n render :json => @appointments, :status => :ok\n end","def index\n @hour_logs = HourLog.all\n render json: @hour_logs, status: 200\n end","def index\n vehicle_id = params[:vehicle_id]\n shift_date = Date.today\n\n begin\n @shifts = Shift.by_vehicle_and_date(vehicle_id, shift_date)\n rescue\n errors = \"Error\"\n render json: errors.to_json, status: 400\n return\n end\n\n respond_with(@shifts)\n\n # render json: trips, status: :ok\n end","def index\n @hours = Hour.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hours }\n end\n end","def show\n @where_to_stay = WhereToStay.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @where_to_stay }\n end\n end","def index\n @timecard = Timecard.find(params[:timecard_id])\n render :json => Hour.timecard_hours(@timecard)\n end","def index\n render json: meeting.all\n end","def show\n @student = Student.find(params[:id])\n @times = times\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end","def create\n @stay_time = StayTime.new(stay_time_params)\n\n respond_to do |format|\n if @stay_time.save\n format.html { redirect_to @stay_time, notice: 'Stay time was successfully created.' }\n format.json { render :show, status: :created, location: @stay_time }\n else\n format.html { render :new }\n format.json { render json: @stay_time.errors, status: :unprocessable_entity }\n end\n end\n end","def show\n @meal_time = MealTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @meal_time }\n end\n end","def show\n @hurdle_time = HurdleTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hurdle_time }\n end\n end","def show\n @service_time = ServiceTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @service_time }\n end\n end","def index\n workouts = @ws.workouts\n render json: workouts\n end","def showtimes_json(day)\n showtimes_by_cinemas_json(CONST::WORD_DAY_HASH[day]).to_json\n end","def show\n @wait_time = WaitTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @wait_time }\n end\n end","def index\n @regimes = Regime.all\n # respond_to do |format|\n # format.html # index.html.erb\n # format.json { render json: @regimes }\n # end\n end","def index\n @slots = Slot.opening_hours.where(:company_id => current_user.company.id)\n @slots = @slots.sort { |a, b| a.cwday <=> b.cwday }\n\n @blockers = Slot.blockers.where(:company_id => current_user.company.id)\n @blockers = @blockers.sort { |a, b| a.cwday <=> b.cwday }\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: { slots: @slots, blockers: @blockers } }\n end\n end","def index\n @title = t('view.shifts.index_title')\n \n if params[:pay_pending_shifts_for_user_between]\n param = params[:pay_pending_shifts_for_user_between]\n start, finish = make_datetime_range(\n from: param[:start], to: param[:finish]\n ).map(&:to_date)\n\n user = User.find(param[:user_id])\n @shifts = user.shifts.pending_between(start, finish)\n else\n @shifts = shifts_scope.order('start DESC').paginate(\n page: params[:page], per_page: lines_per_page\n )\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shifts }\n end\n end","def index\n set_user\n @time_offs = TimeOff.all\n end","def index\n @delivery_times = DeliveryTime.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @delivery_times }\n end\n end","def schedule\n @users = User.includes(:shifts => :position).where(shifts: {show: @current_show}).order(\"users.first_name, users.last_name, shifts.updated_at\")\n @start = @current_show.start - 4.5.hours\n @end = @current_show.start + 7.5.hours\n @shift_data = Hash[@users.map { |u| u.shifts }.flatten.map { |s| [s.id, { url: shift_path(s, :json), start_time: s.start_time, end_time: s.end_time }] }]\n\n respond_to do |format|\n format.html\n format.json { render 'schedule' }\n end\n end","def index\n @course_timings = CourseTiming.all\n end","def index\n render json: { bookings: @site.bookings.order(datetime: :asc) }, status: 200\n end","def show\n @restaurant = Restaurant.find(params[:id])\n @reservation = Reservation.new\n @image_tag_string = \"/assets/slideshow-rest.jpg\"\n\n @google_map = \"http://maps.google.com/maps/api/staticmap?key=AIzaSyC77WBfl-zki0vS7h9zyKyYg3htKcERvuo&size=400x300\"\n @google_map << \"&markers=icon:http://i42.tinypic.com/rj2txf.png%7C#{@restaurant.lat}%2C#{@restaurant.lng}\"\n @google_map << '&sensor=false&zoom=16'\n\n @today = true\n if @restaurant.inventories.available.size >= 3\n @times = @restaurant.inventories.available.limit(3).map{|inv| inv.start_time.to_s.slice(11..15)}\n else\n @today = false\n @times = @restaurant.inventories.available((Time.zone.today + 1.day), \"00:00\").limit(3).map{|inv| inv.start_time.to_s.slice(11..15)}\n end\n\n @times = [\"18:30\",\"19:00\",\"19:30\"]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restaurant }\n end\n end","def stops\n get '/gtfs/stops'\n end","def days\n @trainings = Training.all\n @activities = Activity.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trainings }\n end\n end","def index\n @timed_tasks = TimedTask.all\n end","def index\n #@shifts = Shift.all\n @shifts = Shift.where(tenant_id: current_tenant.id)\n render json: {\n message: 'Your Shift',\n shifttransaction: @shift\n }\n end","def index\n @timecharts = Timechart.find(:all, order: \"stop_time DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @timecharts }\n end\n end","def show\n @time_off_request = TimeOffRequest.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_off_request }\n end\n end","def index\n @scheduled_appointments = ScheduledAppointment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @scheduled_appointments }\n end\n end","def index\n\n if params[:meeting_id]\n @meeting = Meeting.find(params[:meeting_id])\n end\n\n respond_to do |f|\n f.json {\n @meetings = Meeting\n start_p = Time.parse(params[:start])\n end_p = Time.parse(params[:end])\n @meetings = @meetings.where(\"start_at > ?\", params[:start])\n if start_p and end_p\n duration = end_p - start_p\n @meetings = @meetings.where(\"duration < ?\", duration)\n end\n\n render :json => @meetings.map{|m|\n {\n :id => m.id,\n :title => m.label,\n :start => m.start_at,\n :end => m.end_at,\n :url => \"/reunions/#{m.id}.js\",\n color: '#D42700',\n textColor: 'white'\n }\n }\n }\n f.html\n end\n end","def goals\n get(\"/user/#{@user_id}/activities/goals/daily.json\")\n end","def index\n @timesheets = Timesheet.all\n render json: @timesheets\n end","def index\n @workout_days = WorkoutDay.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @workout_days }\n end\n end","def goals\n get(\"/user/#{@user_id}/activities/goals/daily.json\")\n end","def index\n trips = Trip.all\n render json: trips\n end","def index\n if current_doctor.present?\n @availibility_time_slots = current_doctor.availibility_time_slots\n else\n @availibility_time_slots = AvailibilityTimeSlot.all\n end\n end","def index\n respond_to do |format|\n format.html\n format.json {\n\n render :json => TimeOff.joins('LEFT OUTER JOIN request_types ON time_offs.request_type_id = request_types.id')\n .joins('INNER JOIN users ON time_offs.user_id = users.id')\n .select(\n 'time_offs.id,\n time_offs.request_start_date,\n time_offs.request_end_date,\n time_offs.status,\n time_offs.comments,\n users.name as users_name,\n request_types.name as request_type_name') }\n end\n end","def index\n @timers = Timer.all\n @load_push = true\n\n @write_right = userCould :timer\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @timers }\n end\n end","def index\n @trip_schedules = TripSchedule.all\n end"],"string":"[\n \"def index\\n @service_times = ServiceTime.all\\n\\n respond_to do |format|\\n format.html # index.html.erb\\n format.json { render json: @service_times }\\n end\\n end\",\n \"def index\\n @tea_times = TeaTime.all\\n respond_to do |format|\\n format.html { render layout: !request.xhr? }\\n format.json { render json: @tea_times }\\n end\\n end\",\n \"def index\\n render json: {time: Time.now}\\n end\",\n \"def show\\n @time_gap = TimeGap.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @time_gap }\\n end\\n end\",\n \"def hours\\n render json: Pings::Selector.new.hours(params)\\n end\",\n \"def index\\n @days = @trip.days.order(trip_day: :asc)\\n render json: @days, include: [:activities]\\n end\",\n \"def index\\n @mealtimes = Mealtime.all\\n end\",\n \"def index\\n @time_entry ||= current_user.time_entries.build(\\n :tdate => Date.today\\n )\\n \\n @time_entries = current_firm.all_time_entries\\n\\n respond_to do |format|\\n format.html { render :index }# index.html.erb\\n format.json { render json: @time_entries }\\n end\\n end\",\n \"def show\\n render json: @timer\\n end\",\n \"def index\\n @timecards = TimeCard.all\\n render :json => @timecards.to_json(:include => :time_entry), status: :ok\\n end\",\n \"def query_times_graphs\\n controller = params[:controller_name]\\n action = params[:action_name]\\n data = redis(logger: true).zrangebyscore(\\\"request_timings/total/by_action/#{controller}##{action}\\\",\\n 1.month.ago.to_i, '+inf',\\n with_scores: true)\\n .map { |y, x| [x.to_f, y.to_f] }\\n throw 'No Data' if data.nil? || data.empty?\\n smoothed = moving_avg(data)\\n final = (params[:raw].present? ? data : smoothed).map { |x, y| [Time.at(x.to_i).to_datetime, y] }\\n render json: [\\n { name: 'Timings', data: final }\\n ]\\n end\",\n \"def index\\n @timers = Timer.all\\n\\n render json: @timers\\n end\",\n \"def index\\n\\n @hurdle_times = HurdleTime.order('time, hurdle_match_id, lane')\\n\\n if params[:hurdle_match_id]\\n @hurdle_times = @hurdle_times.where(:hurdle_match_id => params[:hurdle_match_id])\\n end\\n\\n respond_to do |format|\\n format.html # index.html.erb\\n format.json { render json: @hurdle_times }\\n end\\n end\",\n \"def show\\n\\n trip = Trip.find(params[:id])\\n\\n departureOrder = LineStation.find_by_station_id(trip.departureStation_id).order\\n arrivalOrder = LineStation.find_by_station_id(trip.arrivalStation_id).order\\n\\n lineStations = LineStation.where(:order => departureOrder..arrivalOrder)\\n lineStations = lineStations.where(:line_id => trip.line_id)\\n if departureOrder < arrivalOrder\\n lineStations.order('order ASC')\\n else\\n lineStations.order('order DESC')\\n end\\n\\n times = Array.new\\n currentTime = trip.beginTime\\n lineStations.each do |ls|\\n \\n station = Station.find(ls.station_id)\\n train = Train.find(trip.train_id)\\n\\n times << { :station => station, :time => currentTime.strftime('%H:%M') }\\n\\n timeElapsed = ls.distance.to_f / train.velocity\\n currentTime = currentTime + timeElapsed.hours\\n end\\n\\n render :json => { :trip => trip, :times => times }\\n\\n end\",\n \"def index\\n @location_times = LocationTime.all\\n end\",\n \"def open_appointments\\n date = Date.parse(params[:date])\\n clinic = Clinic.find(params[:clinic_id])\\n doctor = Doctor.find(params[:doctor_id])\\n # @times = doctor.open_appointment_times(date)\\n @times = clinic.open_appointment_times(date, doctor)\\n if @times.is_a?(Hash)\\n render json: {status: 1, error: @times[:error]}\\n else\\n render json: { status: 0, times: @times }\\n end\\n #@appointment = Appointment.new\\n #render json: {open_times: @open_times}\\n # render json: {times: [\\n # {time: '8:00 AM', enabled: true, selected: false, index: 0},\\n # {time: '8:30 AM', enabled: false, selected: false, index: 1},\\n # {time: '9:00 AM', enabled: true, selected: false, index: 2},\\n # {time: '9:30 AM', enabled: true, selected: false, index: 3},\\n # {time: '10:00 AM', enabled: false, selected: false, index: 4},\\n # {time: '10:30 AM', enabled: false, selected: false, index: 5},\\n # {time: '11:00 AM', enabled: false, selected: false, index: 6},\\n # {time: '11:30 AM', enabled: true, selected: false, index: 7},\\n # {time: '12:00 PM', enabled: true, selected: false, index: 8},\\n # {time: '12:30 PM', enabled: true, selected: false, index: 9},\\n # {time: '1:00 PM', enabled: false, selected: false, index: 10},\\n # {time: '1:30 PM', enabled: true, selected: false, index: 11},\\n # {time: '2:00 PM', enabled: false, selected: false, index: 12},\\n # {time: '2:30 PM', enabled: false, selected: false, index: 13},\\n # {time: '3:00 PM', enabled: true, selected: false, index: 14},\\n # {time: '3:30 PM', enabled: true, selected: false, index: 15},\\n # {time: '4:00 PM', enabled: true, selected: false, index: 16},\\n # {time: '4:30 PM', enabled: false, selected: false, index: 17},\\n # {time: '5:00 PM', enabled: true, selected: false, index: 18},\\n # {time: '5:30 PM', enabled: true, selected: false, index: 19}]}\\n\\n end\",\n \"def index\\n date_range = unix_date(params[:date])\\n @timeslots = Timeslot.where('start_time >= ? and start_time <= ?', date_range[:beginning_of_day], date_range[:end_of_day])\\n # render :json => @timeslots.as_json(only: [])\\n end\",\n \"def show\\n render :json => @timecard.to_json(:include => :time_entry), status: :ok\\n end\",\n \"def index\\n @timeslots = Timeslot.all\\n end\",\n \"def index\\n @timeslots = Timeslot.all\\n end\",\n \"def index\\n @allocated_times = AllocatedTime.all\\n end\",\n \"def index\\n @session_times = SessionTime.all\\n end\",\n \"def index\\n @cooking_times = CookingTime.all\\n end\",\n \"def show\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @clock_time }\\n end\\n end\",\n \"def index\\n @clock = @employee.clock_in_out\\n render json: @clock\\n end\",\n \"def index\\n @wait_times = WaitTime.all\\n end\",\n \"def index\\n schedules = Schedule.where(trip_id: params[:trip_id])\\n respond_with schedules\\n end\",\n \"def index\\n @working_start_times = WorkingStartTime.all\\n end\",\n \"def index\\n @meeting_times = MeetingTime.order(:time).all\\n end\",\n \"def index\\n @time_of_days = TimeOfDay.all\\n end\",\n \"def getTimes()\\n return @times\\n end\",\n \"def index\\n @timetables = Timetable.all\\n\\n respond_to do |format|\\n format.html # index.html.erb\\n format.json { render json: @timetables }\\n end\\n end\",\n \"def index\\n @vehicle_realtimes = VehicleRealtime.all\\n \\n respond_to do |format|\\n format.html\\n format.json { render :json => @vehicle_realtimes.to_json(:include => [:vehicle_trip, :vehicle_route, :vehicle_stop]) }\\n end\\n end\",\n \"def index\\n @jobtimes = current_company.jobtimes.find_all_by_job_id(params[:job_id])\\n respond_to do |format|\\n format.xml {render :xml => @jobtimes }\\n format.json { render :json => @jobtimes }\\n end\\n end\",\n \"def time_trackings\\n Easybill::Api::TimeTrackings\\n end\",\n \"def index\\n @timings = Timing.all\\n end\",\n \"def index\\n @announces = Announce.not_finished.order(\\\"stime DESC\\\")\\n\\t\\t@pannounces = Announce.finished.last_24_hours.limit(20).order(\\\"etime DESC\\\")\\n\\n respond_to do |format|\\n format.html # index.html.erb\\n format.json { render json: @announces }\\n end\\n end\",\n \"def chatting_time(*args)\\n @client.get \\\"#{@path}/chatting_time\\\", Hash[*args]\\n end\",\n \"def index\\n @times_games = TimesGame.all\\n end\",\n \"def index\\n @section_times = SectionTime.all\\n end\",\n \"def index\\r\\n @clocks = ClockResult.all\\r\\n\\r\\n respond_to do |format|\\r\\n format.html # index.html.erb\\r\\n format.json { render json: @clocks }\\r\\n end\\r\\n end\",\n \"def index\\n streaks = Streak.active.all\\n render_jsonapi(streaks)\\n end\",\n \"def index\\n @poi_times = PoiTime.all\\n end\",\n \"def index\\n @day_timeslots = DayTimeslot.all\\n end\",\n \"def index\\n @appointments = Appointment.all \\n render json: @appointments\\n end\",\n \"def index\\n @class_times = ClassTime.all\\n end\",\n \"def index\\n @reservations = @user.reservations\\n @reservations_json = []\\n @reservations.each do |r|\\n ro = r\\n r = r.as_json\\n %w{arrived email no_show owner_id}.each {|k| r.delete(k)}\\n r[:start_time] = ro.start_time_format\\n r[:end_time] = ro.end_time_format\\n @reservations_json << r\\n end\\n\\n render json: @reservations_json, status: 200 \\n end\",\n \"def station_times(name, mins)\\n ier = IERailGet.new(\\\"getStationDataByNameXML_withNumMins?StationDesc=#{name}&NumMins=#{mins}\\\", \\\"arrayofobjstationdata\\\", \\\"objstationdata\\\")\\n \\n ier.response.map { |sd| StationData.new(sd) }\\n end\",\n \"def show\\n @stop_time = StopTime.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @stop_time }\\n end\\n end\",\n \"def index\\n ok_request current_user, %w(user, opinion_polls, opinion_polls.time_slots)\\n end\",\n \"def index\\n @p_times = PTime.all\\n end\",\n \"def region_slots\\n if(current_user.customer_id?)\\n @timeslots = Timeslot.where(\\\"region_id = ?\\\", current_user.customer.region_id)\\n else\\n @timeslots = Timeslot.where(\\\"region_id = ?\\\", current_user.driver.region_id)\\n end\\n render json: @timeslot, status: 200\\n end\",\n \"def index\\n @cal_times = CalTime.paginate(page: params[:page])\\n end\",\n \"def show\\n @working_time = WorkingTime.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @working_time }\\n end\\n end\",\n \"def index\\n @tombstone_timeholds = TombstoneTimehold.all\\n end\",\n \"def get_data_for_time_span()\\n set_schedule_query_params\\n\\n @t1 = Time.at(@t1.to_i)\\n @t2 = Time.at(@t2.to_i)\\n\\n @rsrcs = @config.resource_list # ScheduledResource.resource_list\\n\\n @blockss = ScheduledResource.get_all_blocks(@config, @t1, @t2, @inc)\\n\\n json_adjustments\\n end\",\n \"def set_stay_time\\n @stay_time = StayTime.find(params[:id])\\n end\",\n \"def dates\\n render json: @standings\\n end\",\n \"def work_schedules\\n @work_schedules = WorkSchedule.all\\n\\n render json: @work_schedules.to_json\\n end\",\n \"def index\\n if !time_slot_params[:start].present? && !time_slot_params[:end].present?\\n @appointments = Appointment.all\\n else\\n #time_slot_params[:start], time_slot_params[:end]\\n @appointments = Appointment.in_time_slot_only(time_slot_params).all\\n end\\n render :json => @appointments, :status => :ok\\n end\",\n \"def index\\n @hour_logs = HourLog.all\\n render json: @hour_logs, status: 200\\n end\",\n \"def index\\n vehicle_id = params[:vehicle_id]\\n shift_date = Date.today\\n\\n begin\\n @shifts = Shift.by_vehicle_and_date(vehicle_id, shift_date)\\n rescue\\n errors = \\\"Error\\\"\\n render json: errors.to_json, status: 400\\n return\\n end\\n\\n respond_with(@shifts)\\n\\n # render json: trips, status: :ok\\n end\",\n \"def index\\n @hours = Hour.all\\n\\n respond_to do |format|\\n format.html # index.html.erb\\n format.json { render json: @hours }\\n end\\n end\",\n \"def show\\n @where_to_stay = WhereToStay.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @where_to_stay }\\n end\\n end\",\n \"def index\\n @timecard = Timecard.find(params[:timecard_id])\\n render :json => Hour.timecard_hours(@timecard)\\n end\",\n \"def index\\n render json: meeting.all\\n end\",\n \"def show\\n @student = Student.find(params[:id])\\n @times = times\\n\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @student }\\n end\\n end\",\n \"def create\\n @stay_time = StayTime.new(stay_time_params)\\n\\n respond_to do |format|\\n if @stay_time.save\\n format.html { redirect_to @stay_time, notice: 'Stay time was successfully created.' }\\n format.json { render :show, status: :created, location: @stay_time }\\n else\\n format.html { render :new }\\n format.json { render json: @stay_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def show\\n @meal_time = MealTime.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @meal_time }\\n end\\n end\",\n \"def show\\n @hurdle_time = HurdleTime.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @hurdle_time }\\n end\\n end\",\n \"def show\\n @service_time = ServiceTime.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @service_time }\\n end\\n end\",\n \"def index\\n workouts = @ws.workouts\\n render json: workouts\\n end\",\n \"def showtimes_json(day)\\n showtimes_by_cinemas_json(CONST::WORD_DAY_HASH[day]).to_json\\n end\",\n \"def show\\n @wait_time = WaitTime.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @wait_time }\\n end\\n end\",\n \"def index\\n @regimes = Regime.all\\n # respond_to do |format|\\n # format.html # index.html.erb\\n # format.json { render json: @regimes }\\n # end\\n end\",\n \"def index\\n @slots = Slot.opening_hours.where(:company_id => current_user.company.id)\\n @slots = @slots.sort { |a, b| a.cwday <=> b.cwday }\\n\\n @blockers = Slot.blockers.where(:company_id => current_user.company.id)\\n @blockers = @blockers.sort { |a, b| a.cwday <=> b.cwday }\\n\\n respond_to do |format|\\n format.html # index.html.erb\\n format.json { render json: { slots: @slots, blockers: @blockers } }\\n end\\n end\",\n \"def index\\n @title = t('view.shifts.index_title')\\n \\n if params[:pay_pending_shifts_for_user_between]\\n param = params[:pay_pending_shifts_for_user_between]\\n start, finish = make_datetime_range(\\n from: param[:start], to: param[:finish]\\n ).map(&:to_date)\\n\\n user = User.find(param[:user_id])\\n @shifts = user.shifts.pending_between(start, finish)\\n else\\n @shifts = shifts_scope.order('start DESC').paginate(\\n page: params[:page], per_page: lines_per_page\\n )\\n end\\n \\n respond_to do |format|\\n format.html # index.html.erb\\n format.json { render json: @shifts }\\n end\\n end\",\n \"def index\\n set_user\\n @time_offs = TimeOff.all\\n end\",\n \"def index\\n @delivery_times = DeliveryTime.all\\n\\n respond_to do |format|\\n format.html # index.html.erb\\n format.xml { render :xml => @delivery_times }\\n end\\n end\",\n \"def schedule\\n @users = User.includes(:shifts => :position).where(shifts: {show: @current_show}).order(\\\"users.first_name, users.last_name, shifts.updated_at\\\")\\n @start = @current_show.start - 4.5.hours\\n @end = @current_show.start + 7.5.hours\\n @shift_data = Hash[@users.map { |u| u.shifts }.flatten.map { |s| [s.id, { url: shift_path(s, :json), start_time: s.start_time, end_time: s.end_time }] }]\\n\\n respond_to do |format|\\n format.html\\n format.json { render 'schedule' }\\n end\\n end\",\n \"def index\\n @course_timings = CourseTiming.all\\n end\",\n \"def index\\n render json: { bookings: @site.bookings.order(datetime: :asc) }, status: 200\\n end\",\n \"def show\\n @restaurant = Restaurant.find(params[:id])\\n @reservation = Reservation.new\\n @image_tag_string = \\\"/assets/slideshow-rest.jpg\\\"\\n\\n @google_map = \\\"http://maps.google.com/maps/api/staticmap?key=AIzaSyC77WBfl-zki0vS7h9zyKyYg3htKcERvuo&size=400x300\\\"\\n @google_map << \\\"&markers=icon:http://i42.tinypic.com/rj2txf.png%7C#{@restaurant.lat}%2C#{@restaurant.lng}\\\"\\n @google_map << '&sensor=false&zoom=16'\\n\\n @today = true\\n if @restaurant.inventories.available.size >= 3\\n @times = @restaurant.inventories.available.limit(3).map{|inv| inv.start_time.to_s.slice(11..15)}\\n else\\n @today = false\\n @times = @restaurant.inventories.available((Time.zone.today + 1.day), \\\"00:00\\\").limit(3).map{|inv| inv.start_time.to_s.slice(11..15)}\\n end\\n\\n @times = [\\\"18:30\\\",\\\"19:00\\\",\\\"19:30\\\"]\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @restaurant }\\n end\\n end\",\n \"def stops\\n get '/gtfs/stops'\\n end\",\n \"def days\\n @trainings = Training.all\\n @activities = Activity.all\\n\\n respond_to do |format|\\n format.html # index.html.erb\\n format.json { render json: @trainings }\\n end\\n end\",\n \"def index\\n @timed_tasks = TimedTask.all\\n end\",\n \"def index\\n #@shifts = Shift.all\\n @shifts = Shift.where(tenant_id: current_tenant.id)\\n render json: {\\n message: 'Your Shift',\\n shifttransaction: @shift\\n }\\n end\",\n \"def index\\n @timecharts = Timechart.find(:all, order: \\\"stop_time DESC\\\")\\n\\n respond_to do |format|\\n format.html # index.html.erb\\n format.json { render json: @timecharts }\\n end\\n end\",\n \"def show\\n @time_off_request = TimeOffRequest.find(params[:id])\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @time_off_request }\\n end\\n end\",\n \"def index\\n @scheduled_appointments = ScheduledAppointment.all\\n\\n respond_to do |format|\\n format.html # index.html.erb\\n format.json { render json: @scheduled_appointments }\\n end\\n end\",\n \"def index\\n\\n if params[:meeting_id]\\n @meeting = Meeting.find(params[:meeting_id])\\n end\\n\\n respond_to do |f|\\n f.json {\\n @meetings = Meeting\\n start_p = Time.parse(params[:start])\\n end_p = Time.parse(params[:end])\\n @meetings = @meetings.where(\\\"start_at > ?\\\", params[:start])\\n if start_p and end_p\\n duration = end_p - start_p\\n @meetings = @meetings.where(\\\"duration < ?\\\", duration)\\n end\\n\\n render :json => @meetings.map{|m|\\n {\\n :id => m.id,\\n :title => m.label,\\n :start => m.start_at,\\n :end => m.end_at,\\n :url => \\\"/reunions/#{m.id}.js\\\",\\n color: '#D42700',\\n textColor: 'white'\\n }\\n }\\n }\\n f.html\\n end\\n end\",\n \"def goals\\n get(\\\"/user/#{@user_id}/activities/goals/daily.json\\\")\\n end\",\n \"def index\\n @timesheets = Timesheet.all\\n render json: @timesheets\\n end\",\n \"def index\\n @workout_days = WorkoutDay.all\\n\\n respond_to do |format|\\n format.html # index.html.erb\\n format.json { render json: @workout_days }\\n end\\n end\",\n \"def goals\\n get(\\\"/user/#{@user_id}/activities/goals/daily.json\\\")\\n end\",\n \"def index\\n trips = Trip.all\\n render json: trips\\n end\",\n \"def index\\n if current_doctor.present?\\n @availibility_time_slots = current_doctor.availibility_time_slots\\n else\\n @availibility_time_slots = AvailibilityTimeSlot.all\\n end\\n end\",\n \"def index\\n respond_to do |format|\\n format.html\\n format.json {\\n\\n render :json => TimeOff.joins('LEFT OUTER JOIN request_types ON time_offs.request_type_id = request_types.id')\\n .joins('INNER JOIN users ON time_offs.user_id = users.id')\\n .select(\\n 'time_offs.id,\\n time_offs.request_start_date,\\n time_offs.request_end_date,\\n time_offs.status,\\n time_offs.comments,\\n users.name as users_name,\\n request_types.name as request_type_name') }\\n end\\n end\",\n \"def index\\n @timers = Timer.all\\n @load_push = true\\n\\n @write_right = userCould :timer\\n\\n respond_to do |format|\\n format.html # index.html.erb\\n format.json { render json: @timers }\\n end\\n end\",\n \"def index\\n @trip_schedules = TripSchedule.all\\n end\"\n]"},"negative_scores":{"kind":"list like","value":["0.66211087","0.63165516","0.6313331","0.6311019","0.62858325","0.6283367","0.62432575","0.6238713","0.62150556","0.6213193","0.6212546","0.6203579","0.62031066","0.616202","0.61575663","0.6142375","0.61341816","0.612905","0.6113712","0.6113712","0.6102728","0.6096498","0.60754645","0.6056405","0.6045273","0.60075766","0.59995395","0.59892344","0.5986988","0.59824556","0.59811115","0.5979923","0.59673095","0.5949065","0.59384114","0.5935644","0.5931015","0.5922557","0.5921649","0.5914588","0.590357","0.58898044","0.5887441","0.58829236","0.5880038","0.58720446","0.58717144","0.5867209","0.5861266","0.5859719","0.58573174","0.5850239","0.58498895","0.58401","0.5835706","0.5822799","0.58211184","0.58150584","0.5803993","0.5800533","0.5787348","0.57797897","0.5775032","0.57629585","0.5759606","0.5758356","0.5756584","0.575208","0.57422143","0.5740982","0.57385874","0.5735396","0.57230955","0.5720771","0.5719829","0.571978","0.57144105","0.5708345","0.5706722","0.5705671","0.5705125","0.57041544","0.5703877","0.56931394","0.5692799","0.56902176","0.5686381","0.56817585","0.5676591","0.5673124","0.5671317","0.56708896","0.5670852","0.56707865","0.56703115","0.56642365","0.5662852","0.5659484","0.56556964","0.56491315"],"string":"[\n \"0.66211087\",\n \"0.63165516\",\n \"0.6313331\",\n \"0.6311019\",\n \"0.62858325\",\n \"0.6283367\",\n \"0.62432575\",\n \"0.6238713\",\n \"0.62150556\",\n \"0.6213193\",\n \"0.6212546\",\n \"0.6203579\",\n \"0.62031066\",\n \"0.616202\",\n \"0.61575663\",\n \"0.6142375\",\n \"0.61341816\",\n \"0.612905\",\n \"0.6113712\",\n \"0.6113712\",\n \"0.6102728\",\n \"0.6096498\",\n \"0.60754645\",\n \"0.6056405\",\n \"0.6045273\",\n \"0.60075766\",\n \"0.59995395\",\n \"0.59892344\",\n \"0.5986988\",\n \"0.59824556\",\n \"0.59811115\",\n \"0.5979923\",\n \"0.59673095\",\n \"0.5949065\",\n \"0.59384114\",\n \"0.5935644\",\n \"0.5931015\",\n \"0.5922557\",\n \"0.5921649\",\n \"0.5914588\",\n \"0.590357\",\n \"0.58898044\",\n \"0.5887441\",\n \"0.58829236\",\n \"0.5880038\",\n \"0.58720446\",\n \"0.58717144\",\n \"0.5867209\",\n \"0.5861266\",\n \"0.5859719\",\n \"0.58573174\",\n \"0.5850239\",\n \"0.58498895\",\n \"0.58401\",\n \"0.5835706\",\n \"0.5822799\",\n \"0.58211184\",\n \"0.58150584\",\n \"0.5803993\",\n \"0.5800533\",\n \"0.5787348\",\n \"0.57797897\",\n \"0.5775032\",\n \"0.57629585\",\n \"0.5759606\",\n \"0.5758356\",\n \"0.5756584\",\n \"0.575208\",\n \"0.57422143\",\n \"0.5740982\",\n \"0.57385874\",\n \"0.5735396\",\n \"0.57230955\",\n \"0.5720771\",\n \"0.5719829\",\n \"0.571978\",\n \"0.57144105\",\n \"0.5708345\",\n \"0.5706722\",\n \"0.5705671\",\n \"0.5705125\",\n \"0.57041544\",\n \"0.5703877\",\n \"0.56931394\",\n \"0.5692799\",\n \"0.56902176\",\n \"0.5686381\",\n \"0.56817585\",\n \"0.5676591\",\n \"0.5673124\",\n \"0.5671317\",\n \"0.56708896\",\n \"0.5670852\",\n \"0.56707865\",\n \"0.56703115\",\n \"0.56642365\",\n \"0.5662852\",\n \"0.5659484\",\n \"0.56556964\",\n \"0.56491315\"\n]"},"document_score":{"kind":"string","value":"0.75969326"},"document_rank":{"kind":"string","value":"0"}}},{"rowIdx":126,"cells":{"query":{"kind":"string","value":"GET /stay_times/1 GET /stay_times/1.json"},"document":{"kind":"string","value":"def show\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def index\n @stay_times = StayTime.all\n end","def show\n @time_gap = TimeGap.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_gap }\n end\n end","def index\n @service_times = ServiceTime.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @service_times }\n end\n end","def index\n render json: {time: Time.now}\n end","def show\n render json: @timer\n end","def show\n @working_time = WorkingTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @working_time }\n end\n end","def show\n @stop_time = StopTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stop_time }\n end\n end","def index\n @time_entry ||= current_user.time_entries.build(\n :tdate => Date.today\n )\n \n @time_entries = current_firm.all_time_entries\n\n respond_to do |format|\n format.html { render :index }# index.html.erb\n format.json { render json: @time_entries }\n end\n end","def index\n @mealtimes = Mealtime.all\n end","def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clock_time }\n end\n end","def show\n @meal_time = MealTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @meal_time }\n end\n end","def show\n render :json => @timecard.to_json(:include => :time_entry), status: :ok\n end","def hours\n render json: Pings::Selector.new.hours(params)\n end","def show\n @service_time = ServiceTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @service_time }\n end\n end","def show\n\n trip = Trip.find(params[:id])\n\n departureOrder = LineStation.find_by_station_id(trip.departureStation_id).order\n arrivalOrder = LineStation.find_by_station_id(trip.arrivalStation_id).order\n\n lineStations = LineStation.where(:order => departureOrder..arrivalOrder)\n lineStations = lineStations.where(:line_id => trip.line_id)\n if departureOrder < arrivalOrder\n lineStations.order('order ASC')\n else\n lineStations.order('order DESC')\n end\n\n times = Array.new\n currentTime = trip.beginTime\n lineStations.each do |ls|\n \n station = Station.find(ls.station_id)\n train = Train.find(trip.train_id)\n\n times << { :station => station, :time => currentTime.strftime('%H:%M') }\n\n timeElapsed = ls.distance.to_f / train.velocity\n currentTime = currentTime + timeElapsed.hours\n end\n\n render :json => { :trip => trip, :times => times }\n\n end","def index\n\n @hurdle_times = HurdleTime.order('time, hurdle_match_id, lane')\n\n if params[:hurdle_match_id]\n @hurdle_times = @hurdle_times.where(:hurdle_match_id => params[:hurdle_match_id])\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hurdle_times }\n end\n end","def show\n @hurdle_time = HurdleTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hurdle_time }\n end\n end","def open_appointments\n date = Date.parse(params[:date])\n clinic = Clinic.find(params[:clinic_id])\n doctor = Doctor.find(params[:doctor_id])\n # @times = doctor.open_appointment_times(date)\n @times = clinic.open_appointment_times(date, doctor)\n if @times.is_a?(Hash)\n render json: {status: 1, error: @times[:error]}\n else\n render json: { status: 0, times: @times }\n end\n #@appointment = Appointment.new\n #render json: {open_times: @open_times}\n # render json: {times: [\n # {time: '8:00 AM', enabled: true, selected: false, index: 0},\n # {time: '8:30 AM', enabled: false, selected: false, index: 1},\n # {time: '9:00 AM', enabled: true, selected: false, index: 2},\n # {time: '9:30 AM', enabled: true, selected: false, index: 3},\n # {time: '10:00 AM', enabled: false, selected: false, index: 4},\n # {time: '10:30 AM', enabled: false, selected: false, index: 5},\n # {time: '11:00 AM', enabled: false, selected: false, index: 6},\n # {time: '11:30 AM', enabled: true, selected: false, index: 7},\n # {time: '12:00 PM', enabled: true, selected: false, index: 8},\n # {time: '12:30 PM', enabled: true, selected: false, index: 9},\n # {time: '1:00 PM', enabled: false, selected: false, index: 10},\n # {time: '1:30 PM', enabled: true, selected: false, index: 11},\n # {time: '2:00 PM', enabled: false, selected: false, index: 12},\n # {time: '2:30 PM', enabled: false, selected: false, index: 13},\n # {time: '3:00 PM', enabled: true, selected: false, index: 14},\n # {time: '3:30 PM', enabled: true, selected: false, index: 15},\n # {time: '4:00 PM', enabled: true, selected: false, index: 16},\n # {time: '4:30 PM', enabled: false, selected: false, index: 17},\n # {time: '5:00 PM', enabled: true, selected: false, index: 18},\n # {time: '5:30 PM', enabled: true, selected: false, index: 19}]}\n\n end","def index\n @timers = Timer.all\n\n render json: @timers\n end","def show\n @time_off_request = TimeOffRequest.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_off_request }\n end\n end","def index\n @tea_times = TeaTime.all\n respond_to do |format|\n format.html { render layout: !request.xhr? }\n format.json { render json: @tea_times }\n end\n end","def index\n schedules = Schedule.where(trip_id: params[:trip_id])\n respond_with schedules\n end","def show\n @timer = Timer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @timer }\n end\n end","def show\n @wait_time = WaitTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @wait_time }\n end\n end","def index\n @days = @trip.days.order(trip_day: :asc)\n render json: @days, include: [:activities]\n end","def show\n @time_entry = TimeEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_entry }\n end\n end","def show\n @time_entry = TimeEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_entry }\n end\n end","def show\n @timetable = Timetable.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @timetable }\n end\n end","def show\n @timetable = Timetable.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @timetable }\n end\n end","def show\n @my_time_trial = MyTimeTrial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @my_time_trial }\n end\n end","def index\n @timecards = TimeCard.all\n render :json => @timecards.to_json(:include => :time_entry), status: :ok\n end","def show\n @nursing_time = NursingTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @nursing_time }\n end\n end","def index\n @clock = @employee.clock_in_out\n render json: @clock\n end","def show\n @time_log = TimeLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_log }\n end\n end","def show\n @one_time_stop = OneTimeStop.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @one_time_stop }\n end\n end","def index\n @timeslots = Timeslot.all\n end","def index\n @timeslots = Timeslot.all\n end","def index\n @timetables = Timetable.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @timetables }\n end\n end","def set_stay_time\n @stay_time = StayTime.find(params[:id])\n end","def index\n @location_times = LocationTime.all\n end","def show\n @time_slot = TimeSlot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_slot }\n end\n end","def show\n @clinic_timing = ClinicTiming.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clinic_timing }\n end\n end","def index\n @timings = Timing.all\n end","def index\n @trips = Trip.desc.all\n @latest_trip = @trips.first\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trips }\n end\n end","def index\n date_range = unix_date(params[:date])\n @timeslots = Timeslot.where('start_time >= ? and start_time <= ?', date_range[:beginning_of_day], date_range[:end_of_day])\n # render :json => @timeslots.as_json(only: [])\n end","def show\n @student = Student.find(params[:id])\n @times = times\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end","def show\n @where_to_stay = WhereToStay.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @where_to_stay }\n end\n end","def index\n @appointments = Appointment.all \n render json: @appointments\n end","def index\n @vehicle_realtimes = VehicleRealtime.all\n \n respond_to do |format|\n format.html\n format.json { render :json => @vehicle_realtimes.to_json(:include => [:vehicle_trip, :vehicle_route, :vehicle_stop]) }\n end\n end","def show\n @timeentry = Timeentry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @timeentry }\n end\n end","def index\r\n @clocks = ClockResult.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @clocks }\r\n end\r\n end","def index\n @jobtimes = current_company.jobtimes.find_all_by_job_id(params[:job_id])\n respond_to do |format|\n format.xml {render :xml => @jobtimes }\n format.json { render :json => @jobtimes }\n end\n end","def index\n @hours = Hour.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hours }\n end\n end","def show\n @time_record = TimeRecord.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_record }\n end\n end","def show\n @time_record = TimeRecord.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_record }\n end\n end","def index\n @working_start_times = WorkingStartTime.all\n end","def show\n @daytime = Daytime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @daytime }\n end\n end","def show\n @restaurant = Restaurant.find(params[:id])\n @reservation = Reservation.new\n @image_tag_string = \"/assets/slideshow-rest.jpg\"\n\n @google_map = \"http://maps.google.com/maps/api/staticmap?key=AIzaSyC77WBfl-zki0vS7h9zyKyYg3htKcERvuo&size=400x300\"\n @google_map << \"&markers=icon:http://i42.tinypic.com/rj2txf.png%7C#{@restaurant.lat}%2C#{@restaurant.lng}\"\n @google_map << '&sensor=false&zoom=16'\n\n @today = true\n if @restaurant.inventories.available.size >= 3\n @times = @restaurant.inventories.available.limit(3).map{|inv| inv.start_time.to_s.slice(11..15)}\n else\n @today = false\n @times = @restaurant.inventories.available((Time.zone.today + 1.day), \"00:00\").limit(3).map{|inv| inv.start_time.to_s.slice(11..15)}\n end\n\n @times = [\"18:30\",\"19:00\",\"19:30\"]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restaurant }\n end\n end","def show\n @schedule = Schedule.find_by_id(params[:id])\n if @schedule\n #schedule_appointments = @schedule.appointments\n render json: @schedule,status: :ok\n else\n render json: {errorMessage:\"no schedule with id: #{params[:id]}\"}, status: :not_found\n end\n end","def index\n @cooking_times = CookingTime.all\n end","def index\n @announces = Announce.not_finished.order(\"stime DESC\")\n\t\t@pannounces = Announce.finished.last_24_hours.limit(20).order(\"etime DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @announces }\n end\n end","def index\n @regimes = Regime.all\n # respond_to do |format|\n # format.html # index.html.erb\n # format.json { render json: @regimes }\n # end\n end","def show\n @planned_time = PlannedTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @planned_time }\n end\n end","def new\n @working_time = WorkingTime.new\n @working_time.time_table_id = current_user.time_tables[0].id\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @working_time }\n end\n end","def index\n @session_times = SessionTime.all\n end","def index\n @poi_times = PoiTime.all\n end","def index\n streaks = Streak.active.all\n render_jsonapi(streaks)\n end","def index\n vehicle_id = params[:vehicle_id]\n shift_date = Date.today\n\n begin\n @shifts = Shift.by_vehicle_and_date(vehicle_id, shift_date)\n rescue\n errors = \"Error\"\n render json: errors.to_json, status: 400\n return\n end\n\n respond_with(@shifts)\n\n # render json: trips, status: :ok\n end","def index\n @hour_logs = HourLog.all\n render json: @hour_logs, status: 200\n end","def index\n render json: meeting.all\n end","def index\n @allocated_times = AllocatedTime.all\n end","def create\n @stay_time = StayTime.new(stay_time_params)\n\n respond_to do |format|\n if @stay_time.save\n format.html { redirect_to @stay_time, notice: 'Stay time was successfully created.' }\n format.json { render :show, status: :created, location: @stay_time }\n else\n format.html { render :new }\n format.json { render json: @stay_time.errors, status: :unprocessable_entity }\n end\n end\n end","def show\n @offset_time = OffsetTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @offset_time }\n end\n end","def show\n @planning_time = PlanningTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @planning_time }\n end\n end","def new\n @time_gap = TimeGap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @time_gap }\n end\n end","def show\n @receiver_time = ReceiverTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @receiver_time }\n end\n end","def show\n @time_section = TimeSection.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_section }\n end\n end","def index\n @times_games = TimesGame.all\n end","def index\n @timecard = Timecard.find(params[:timecard_id])\n render :json => Hour.timecard_hours(@timecard)\n end","def query_times_graphs\n controller = params[:controller_name]\n action = params[:action_name]\n data = redis(logger: true).zrangebyscore(\"request_timings/total/by_action/#{controller}##{action}\",\n 1.month.ago.to_i, '+inf',\n with_scores: true)\n .map { |y, x| [x.to_f, y.to_f] }\n throw 'No Data' if data.nil? || data.empty?\n smoothed = moving_avg(data)\n final = (params[:raw].present? ? data : smoothed).map { |x, y| [Time.at(x.to_i).to_datetime, y] }\n render json: [\n { name: 'Timings', data: final }\n ]\n end","def index\n @time_of_days = TimeOfDay.all\n end","def index\n @meeting_times = MeetingTime.order(:time).all\n end","def get_data_for_time_span()\n set_schedule_query_params\n\n @t1 = Time.at(@t1.to_i)\n @t2 = Time.at(@t2.to_i)\n\n @rsrcs = @config.resource_list # ScheduledResource.resource_list\n\n @blockss = ScheduledResource.get_all_blocks(@config, @t1, @t2, @inc)\n\n json_adjustments\n end","def index\n @p_times = PTime.all\n end","def show\n @hotel_stay = HotelStay.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hotel_stay }\n end\n end","def index\n @section_times = SectionTime.all\n end","def station_times(name, mins)\n ier = IERailGet.new(\"getStationDataByNameXML_withNumMins?StationDesc=#{name}&NumMins=#{mins}\", \"arrayofobjstationdata\", \"objstationdata\")\n \n ier.response.map { |sd| StationData.new(sd) }\n end","def index\n @day_timeslots = DayTimeslot.all\n end","def index\n @class_times = ClassTime.all\n end","def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_frame }\n end\n end","def new\n @my_time_trial = MyTimeTrial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @my_time_trial }\n end\n end","def index\n @wait_times = WaitTime.all\n end","def show\n @time_track = TimeTrack.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_track }\n end\n end","def show\n @time_point = TimePoint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_point }\n end\n end","def index\n respond_to do |format|\n format.html\n format.json {\n\n render :json => TimeOff.joins('LEFT OUTER JOIN request_types ON time_offs.request_type_id = request_types.id')\n .joins('INNER JOIN users ON time_offs.user_id = users.id')\n .select(\n 'time_offs.id,\n time_offs.request_start_date,\n time_offs.request_end_date,\n time_offs.status,\n time_offs.comments,\n users.name as users_name,\n request_types.name as request_type_name') }\n end\n end","def index\n #@shifts = Shift.all\n @shifts = Shift.where(tenant_id: current_tenant.id)\n render json: {\n message: 'Your Shift',\n shifttransaction: @shift\n }\n end","def chatting_time(*args)\n @client.get \"#{@path}/chatting_time\", Hash[*args]\n end","def show\n @breadcrumb = 'read'\n @time_record = TimeRecord.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_record }\n end\n end","def index\n trips = Trip.all\n render json: trips\n end","def index\n set_user\n @time_offs = TimeOff.all\n end","def index\n @scheduled_appointments = ScheduledAppointment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @scheduled_appointments }\n end\n end"],"string":"[\n \"def index\\n @stay_times = StayTime.all\\n end\",\n \"def show\\n @time_gap = TimeGap.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @time_gap }\\n end\\n end\",\n \"def index\\n @service_times = ServiceTime.all\\n\\n respond_to do |format|\\n format.html # index.html.erb\\n format.json { render json: @service_times }\\n end\\n end\",\n \"def index\\n render json: {time: Time.now}\\n end\",\n \"def show\\n render json: @timer\\n end\",\n \"def show\\n @working_time = WorkingTime.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @working_time }\\n end\\n end\",\n \"def show\\n @stop_time = StopTime.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @stop_time }\\n end\\n end\",\n \"def index\\n @time_entry ||= current_user.time_entries.build(\\n :tdate => Date.today\\n )\\n \\n @time_entries = current_firm.all_time_entries\\n\\n respond_to do |format|\\n format.html { render :index }# index.html.erb\\n format.json { render json: @time_entries }\\n end\\n end\",\n \"def index\\n @mealtimes = Mealtime.all\\n end\",\n \"def show\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @clock_time }\\n end\\n end\",\n \"def show\\n @meal_time = MealTime.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @meal_time }\\n end\\n end\",\n \"def show\\n render :json => @timecard.to_json(:include => :time_entry), status: :ok\\n end\",\n \"def hours\\n render json: Pings::Selector.new.hours(params)\\n end\",\n \"def show\\n @service_time = ServiceTime.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @service_time }\\n end\\n end\",\n \"def show\\n\\n trip = Trip.find(params[:id])\\n\\n departureOrder = LineStation.find_by_station_id(trip.departureStation_id).order\\n arrivalOrder = LineStation.find_by_station_id(trip.arrivalStation_id).order\\n\\n lineStations = LineStation.where(:order => departureOrder..arrivalOrder)\\n lineStations = lineStations.where(:line_id => trip.line_id)\\n if departureOrder < arrivalOrder\\n lineStations.order('order ASC')\\n else\\n lineStations.order('order DESC')\\n end\\n\\n times = Array.new\\n currentTime = trip.beginTime\\n lineStations.each do |ls|\\n \\n station = Station.find(ls.station_id)\\n train = Train.find(trip.train_id)\\n\\n times << { :station => station, :time => currentTime.strftime('%H:%M') }\\n\\n timeElapsed = ls.distance.to_f / train.velocity\\n currentTime = currentTime + timeElapsed.hours\\n end\\n\\n render :json => { :trip => trip, :times => times }\\n\\n end\",\n \"def index\\n\\n @hurdle_times = HurdleTime.order('time, hurdle_match_id, lane')\\n\\n if params[:hurdle_match_id]\\n @hurdle_times = @hurdle_times.where(:hurdle_match_id => params[:hurdle_match_id])\\n end\\n\\n respond_to do |format|\\n format.html # index.html.erb\\n format.json { render json: @hurdle_times }\\n end\\n end\",\n \"def show\\n @hurdle_time = HurdleTime.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @hurdle_time }\\n end\\n end\",\n \"def open_appointments\\n date = Date.parse(params[:date])\\n clinic = Clinic.find(params[:clinic_id])\\n doctor = Doctor.find(params[:doctor_id])\\n # @times = doctor.open_appointment_times(date)\\n @times = clinic.open_appointment_times(date, doctor)\\n if @times.is_a?(Hash)\\n render json: {status: 1, error: @times[:error]}\\n else\\n render json: { status: 0, times: @times }\\n end\\n #@appointment = Appointment.new\\n #render json: {open_times: @open_times}\\n # render json: {times: [\\n # {time: '8:00 AM', enabled: true, selected: false, index: 0},\\n # {time: '8:30 AM', enabled: false, selected: false, index: 1},\\n # {time: '9:00 AM', enabled: true, selected: false, index: 2},\\n # {time: '9:30 AM', enabled: true, selected: false, index: 3},\\n # {time: '10:00 AM', enabled: false, selected: false, index: 4},\\n # {time: '10:30 AM', enabled: false, selected: false, index: 5},\\n # {time: '11:00 AM', enabled: false, selected: false, index: 6},\\n # {time: '11:30 AM', enabled: true, selected: false, index: 7},\\n # {time: '12:00 PM', enabled: true, selected: false, index: 8},\\n # {time: '12:30 PM', enabled: true, selected: false, index: 9},\\n # {time: '1:00 PM', enabled: false, selected: false, index: 10},\\n # {time: '1:30 PM', enabled: true, selected: false, index: 11},\\n # {time: '2:00 PM', enabled: false, selected: false, index: 12},\\n # {time: '2:30 PM', enabled: false, selected: false, index: 13},\\n # {time: '3:00 PM', enabled: true, selected: false, index: 14},\\n # {time: '3:30 PM', enabled: true, selected: false, index: 15},\\n # {time: '4:00 PM', enabled: true, selected: false, index: 16},\\n # {time: '4:30 PM', enabled: false, selected: false, index: 17},\\n # {time: '5:00 PM', enabled: true, selected: false, index: 18},\\n # {time: '5:30 PM', enabled: true, selected: false, index: 19}]}\\n\\n end\",\n \"def index\\n @timers = Timer.all\\n\\n render json: @timers\\n end\",\n \"def show\\n @time_off_request = TimeOffRequest.find(params[:id])\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @time_off_request }\\n end\\n end\",\n \"def index\\n @tea_times = TeaTime.all\\n respond_to do |format|\\n format.html { render layout: !request.xhr? }\\n format.json { render json: @tea_times }\\n end\\n end\",\n \"def index\\n schedules = Schedule.where(trip_id: params[:trip_id])\\n respond_with schedules\\n end\",\n \"def show\\n @timer = Timer.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @timer }\\n end\\n end\",\n \"def show\\n @wait_time = WaitTime.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @wait_time }\\n end\\n end\",\n \"def index\\n @days = @trip.days.order(trip_day: :asc)\\n render json: @days, include: [:activities]\\n end\",\n \"def show\\n @time_entry = TimeEntry.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @time_entry }\\n end\\n end\",\n \"def show\\n @time_entry = TimeEntry.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @time_entry }\\n end\\n end\",\n \"def show\\n @timetable = Timetable.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @timetable }\\n end\\n end\",\n \"def show\\n @timetable = Timetable.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @timetable }\\n end\\n end\",\n \"def show\\n @my_time_trial = MyTimeTrial.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render :json => @my_time_trial }\\n end\\n end\",\n \"def index\\n @timecards = TimeCard.all\\n render :json => @timecards.to_json(:include => :time_entry), status: :ok\\n end\",\n \"def show\\n @nursing_time = NursingTime.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @nursing_time }\\n end\\n end\",\n \"def index\\n @clock = @employee.clock_in_out\\n render json: @clock\\n end\",\n \"def show\\n @time_log = TimeLog.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @time_log }\\n end\\n end\",\n \"def show\\n @one_time_stop = OneTimeStop.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @one_time_stop }\\n end\\n end\",\n \"def index\\n @timeslots = Timeslot.all\\n end\",\n \"def index\\n @timeslots = Timeslot.all\\n end\",\n \"def index\\n @timetables = Timetable.all\\n\\n respond_to do |format|\\n format.html # index.html.erb\\n format.json { render json: @timetables }\\n end\\n end\",\n \"def set_stay_time\\n @stay_time = StayTime.find(params[:id])\\n end\",\n \"def index\\n @location_times = LocationTime.all\\n end\",\n \"def show\\n @time_slot = TimeSlot.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @time_slot }\\n end\\n end\",\n \"def show\\n @clinic_timing = ClinicTiming.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @clinic_timing }\\n end\\n end\",\n \"def index\\n @timings = Timing.all\\n end\",\n \"def index\\n @trips = Trip.desc.all\\n @latest_trip = @trips.first\\n\\n respond_to do |format|\\n format.html # index.html.erb\\n format.json { render json: @trips }\\n end\\n end\",\n \"def index\\n date_range = unix_date(params[:date])\\n @timeslots = Timeslot.where('start_time >= ? and start_time <= ?', date_range[:beginning_of_day], date_range[:end_of_day])\\n # render :json => @timeslots.as_json(only: [])\\n end\",\n \"def show\\n @student = Student.find(params[:id])\\n @times = times\\n\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @student }\\n end\\n end\",\n \"def show\\n @where_to_stay = WhereToStay.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @where_to_stay }\\n end\\n end\",\n \"def index\\n @appointments = Appointment.all \\n render json: @appointments\\n end\",\n \"def index\\n @vehicle_realtimes = VehicleRealtime.all\\n \\n respond_to do |format|\\n format.html\\n format.json { render :json => @vehicle_realtimes.to_json(:include => [:vehicle_trip, :vehicle_route, :vehicle_stop]) }\\n end\\n end\",\n \"def show\\n @timeentry = Timeentry.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @timeentry }\\n end\\n end\",\n \"def index\\r\\n @clocks = ClockResult.all\\r\\n\\r\\n respond_to do |format|\\r\\n format.html # index.html.erb\\r\\n format.json { render json: @clocks }\\r\\n end\\r\\n end\",\n \"def index\\n @jobtimes = current_company.jobtimes.find_all_by_job_id(params[:job_id])\\n respond_to do |format|\\n format.xml {render :xml => @jobtimes }\\n format.json { render :json => @jobtimes }\\n end\\n end\",\n \"def index\\n @hours = Hour.all\\n\\n respond_to do |format|\\n format.html # index.html.erb\\n format.json { render json: @hours }\\n end\\n end\",\n \"def show\\n @time_record = TimeRecord.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @time_record }\\n end\\n end\",\n \"def show\\n @time_record = TimeRecord.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @time_record }\\n end\\n end\",\n \"def index\\n @working_start_times = WorkingStartTime.all\\n end\",\n \"def show\\n @daytime = Daytime.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @daytime }\\n end\\n end\",\n \"def show\\n @restaurant = Restaurant.find(params[:id])\\n @reservation = Reservation.new\\n @image_tag_string = \\\"/assets/slideshow-rest.jpg\\\"\\n\\n @google_map = \\\"http://maps.google.com/maps/api/staticmap?key=AIzaSyC77WBfl-zki0vS7h9zyKyYg3htKcERvuo&size=400x300\\\"\\n @google_map << \\\"&markers=icon:http://i42.tinypic.com/rj2txf.png%7C#{@restaurant.lat}%2C#{@restaurant.lng}\\\"\\n @google_map << '&sensor=false&zoom=16'\\n\\n @today = true\\n if @restaurant.inventories.available.size >= 3\\n @times = @restaurant.inventories.available.limit(3).map{|inv| inv.start_time.to_s.slice(11..15)}\\n else\\n @today = false\\n @times = @restaurant.inventories.available((Time.zone.today + 1.day), \\\"00:00\\\").limit(3).map{|inv| inv.start_time.to_s.slice(11..15)}\\n end\\n\\n @times = [\\\"18:30\\\",\\\"19:00\\\",\\\"19:30\\\"]\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @restaurant }\\n end\\n end\",\n \"def show\\n @schedule = Schedule.find_by_id(params[:id])\\n if @schedule\\n #schedule_appointments = @schedule.appointments\\n render json: @schedule,status: :ok\\n else\\n render json: {errorMessage:\\\"no schedule with id: #{params[:id]}\\\"}, status: :not_found\\n end\\n end\",\n \"def index\\n @cooking_times = CookingTime.all\\n end\",\n \"def index\\n @announces = Announce.not_finished.order(\\\"stime DESC\\\")\\n\\t\\t@pannounces = Announce.finished.last_24_hours.limit(20).order(\\\"etime DESC\\\")\\n\\n respond_to do |format|\\n format.html # index.html.erb\\n format.json { render json: @announces }\\n end\\n end\",\n \"def index\\n @regimes = Regime.all\\n # respond_to do |format|\\n # format.html # index.html.erb\\n # format.json { render json: @regimes }\\n # end\\n end\",\n \"def show\\n @planned_time = PlannedTime.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @planned_time }\\n end\\n end\",\n \"def new\\n @working_time = WorkingTime.new\\n @working_time.time_table_id = current_user.time_tables[0].id\\n\\n respond_to do |format|\\n format.html # new.html.erb\\n format.json { render json: @working_time }\\n end\\n end\",\n \"def index\\n @session_times = SessionTime.all\\n end\",\n \"def index\\n @poi_times = PoiTime.all\\n end\",\n \"def index\\n streaks = Streak.active.all\\n render_jsonapi(streaks)\\n end\",\n \"def index\\n vehicle_id = params[:vehicle_id]\\n shift_date = Date.today\\n\\n begin\\n @shifts = Shift.by_vehicle_and_date(vehicle_id, shift_date)\\n rescue\\n errors = \\\"Error\\\"\\n render json: errors.to_json, status: 400\\n return\\n end\\n\\n respond_with(@shifts)\\n\\n # render json: trips, status: :ok\\n end\",\n \"def index\\n @hour_logs = HourLog.all\\n render json: @hour_logs, status: 200\\n end\",\n \"def index\\n render json: meeting.all\\n end\",\n \"def index\\n @allocated_times = AllocatedTime.all\\n end\",\n \"def create\\n @stay_time = StayTime.new(stay_time_params)\\n\\n respond_to do |format|\\n if @stay_time.save\\n format.html { redirect_to @stay_time, notice: 'Stay time was successfully created.' }\\n format.json { render :show, status: :created, location: @stay_time }\\n else\\n format.html { render :new }\\n format.json { render json: @stay_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def show\\n @offset_time = OffsetTime.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @offset_time }\\n end\\n end\",\n \"def show\\n @planning_time = PlanningTime.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @planning_time }\\n end\\n end\",\n \"def new\\n @time_gap = TimeGap.new\\n\\n respond_to do |format|\\n format.html # new.html.erb\\n format.json { render json: @time_gap }\\n end\\n end\",\n \"def show\\n @receiver_time = ReceiverTime.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @receiver_time }\\n end\\n end\",\n \"def show\\n @time_section = TimeSection.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @time_section }\\n end\\n end\",\n \"def index\\n @times_games = TimesGame.all\\n end\",\n \"def index\\n @timecard = Timecard.find(params[:timecard_id])\\n render :json => Hour.timecard_hours(@timecard)\\n end\",\n \"def query_times_graphs\\n controller = params[:controller_name]\\n action = params[:action_name]\\n data = redis(logger: true).zrangebyscore(\\\"request_timings/total/by_action/#{controller}##{action}\\\",\\n 1.month.ago.to_i, '+inf',\\n with_scores: true)\\n .map { |y, x| [x.to_f, y.to_f] }\\n throw 'No Data' if data.nil? || data.empty?\\n smoothed = moving_avg(data)\\n final = (params[:raw].present? ? data : smoothed).map { |x, y| [Time.at(x.to_i).to_datetime, y] }\\n render json: [\\n { name: 'Timings', data: final }\\n ]\\n end\",\n \"def index\\n @time_of_days = TimeOfDay.all\\n end\",\n \"def index\\n @meeting_times = MeetingTime.order(:time).all\\n end\",\n \"def get_data_for_time_span()\\n set_schedule_query_params\\n\\n @t1 = Time.at(@t1.to_i)\\n @t2 = Time.at(@t2.to_i)\\n\\n @rsrcs = @config.resource_list # ScheduledResource.resource_list\\n\\n @blockss = ScheduledResource.get_all_blocks(@config, @t1, @t2, @inc)\\n\\n json_adjustments\\n end\",\n \"def index\\n @p_times = PTime.all\\n end\",\n \"def show\\n @hotel_stay = HotelStay.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @hotel_stay }\\n end\\n end\",\n \"def index\\n @section_times = SectionTime.all\\n end\",\n \"def station_times(name, mins)\\n ier = IERailGet.new(\\\"getStationDataByNameXML_withNumMins?StationDesc=#{name}&NumMins=#{mins}\\\", \\\"arrayofobjstationdata\\\", \\\"objstationdata\\\")\\n \\n ier.response.map { |sd| StationData.new(sd) }\\n end\",\n \"def index\\n @day_timeslots = DayTimeslot.all\\n end\",\n \"def index\\n @class_times = ClassTime.all\\n end\",\n \"def show\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @time_frame }\\n end\\n end\",\n \"def new\\n @my_time_trial = MyTimeTrial.new\\n\\n respond_to do |format|\\n format.html # new.html.erb\\n format.json { render :json => @my_time_trial }\\n end\\n end\",\n \"def index\\n @wait_times = WaitTime.all\\n end\",\n \"def show\\n @time_track = TimeTrack.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @time_track }\\n end\\n end\",\n \"def show\\n @time_point = TimePoint.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @time_point }\\n end\\n end\",\n \"def index\\n respond_to do |format|\\n format.html\\n format.json {\\n\\n render :json => TimeOff.joins('LEFT OUTER JOIN request_types ON time_offs.request_type_id = request_types.id')\\n .joins('INNER JOIN users ON time_offs.user_id = users.id')\\n .select(\\n 'time_offs.id,\\n time_offs.request_start_date,\\n time_offs.request_end_date,\\n time_offs.status,\\n time_offs.comments,\\n users.name as users_name,\\n request_types.name as request_type_name') }\\n end\\n end\",\n \"def index\\n #@shifts = Shift.all\\n @shifts = Shift.where(tenant_id: current_tenant.id)\\n render json: {\\n message: 'Your Shift',\\n shifttransaction: @shift\\n }\\n end\",\n \"def chatting_time(*args)\\n @client.get \\\"#{@path}/chatting_time\\\", Hash[*args]\\n end\",\n \"def show\\n @breadcrumb = 'read'\\n @time_record = TimeRecord.find(params[:id])\\n\\n respond_to do |format|\\n format.html # show.html.erb\\n format.json { render json: @time_record }\\n end\\n end\",\n \"def index\\n trips = Trip.all\\n render json: trips\\n end\",\n \"def index\\n set_user\\n @time_offs = TimeOff.all\\n end\",\n \"def index\\n @scheduled_appointments = ScheduledAppointment.all\\n\\n respond_to do |format|\\n format.html # index.html.erb\\n format.json { render json: @scheduled_appointments }\\n end\\n end\"\n]"},"negative_scores":{"kind":"list like","value":["0.7261846","0.66732365","0.6581946","0.6489677","0.64342993","0.63616824","0.6351887","0.63425845","0.6285759","0.6273774","0.62598795","0.6255119","0.6237478","0.6222978","0.6222819","0.6222181","0.6218224","0.61824906","0.617852","0.61682594","0.6140876","0.613861","0.6134875","0.61264247","0.61250496","0.6123458","0.6123458","0.61207294","0.61207294","0.61146325","0.6087947","0.6071389","0.607096","0.60696346","0.6060806","0.6050552","0.6050552","0.6044928","0.6032198","0.60087717","0.60036755","0.5992558","0.5988538","0.5982633","0.5966836","0.59623057","0.5960554","0.5954478","0.59444714","0.59372807","0.5917964","0.59162","0.5908882","0.59045666","0.59045666","0.589154","0.5891122","0.58701503","0.58604354","0.58587116","0.58564943","0.5854692","0.5851696","0.5851195","0.58459073","0.5844174","0.5834008","0.5827395","0.58242035","0.58200246","0.58158904","0.5812353","0.5812084","0.58070534","0.5806551","0.5796599","0.57933366","0.5793268","0.57913387","0.57791203","0.57759553","0.5775642","0.57737696","0.57536083","0.57488555","0.5743656","0.5743358","0.5742512","0.57380706","0.5731987","0.5730328","0.5725145","0.57240796","0.5723337","0.57160664","0.57144946","0.57076985","0.57060075","0.5699461","0.5695938","0.56943196"],"string":"[\n \"0.7261846\",\n \"0.66732365\",\n \"0.6581946\",\n \"0.6489677\",\n \"0.64342993\",\n \"0.63616824\",\n \"0.6351887\",\n \"0.63425845\",\n \"0.6285759\",\n \"0.6273774\",\n \"0.62598795\",\n \"0.6255119\",\n \"0.6237478\",\n \"0.6222978\",\n \"0.6222819\",\n \"0.6222181\",\n \"0.6218224\",\n \"0.61824906\",\n \"0.617852\",\n \"0.61682594\",\n \"0.6140876\",\n \"0.613861\",\n \"0.6134875\",\n \"0.61264247\",\n \"0.61250496\",\n \"0.6123458\",\n \"0.6123458\",\n \"0.61207294\",\n \"0.61207294\",\n \"0.61146325\",\n \"0.6087947\",\n \"0.6071389\",\n \"0.607096\",\n \"0.60696346\",\n \"0.6060806\",\n \"0.6050552\",\n \"0.6050552\",\n \"0.6044928\",\n \"0.6032198\",\n \"0.60087717\",\n \"0.60036755\",\n \"0.5992558\",\n \"0.5988538\",\n \"0.5982633\",\n \"0.5966836\",\n \"0.59623057\",\n \"0.5960554\",\n \"0.5954478\",\n \"0.59444714\",\n \"0.59372807\",\n \"0.5917964\",\n \"0.59162\",\n \"0.5908882\",\n \"0.59045666\",\n \"0.59045666\",\n \"0.589154\",\n \"0.5891122\",\n \"0.58701503\",\n \"0.58604354\",\n \"0.58587116\",\n \"0.58564943\",\n \"0.5854692\",\n \"0.5851696\",\n \"0.5851195\",\n \"0.58459073\",\n \"0.5844174\",\n \"0.5834008\",\n \"0.5827395\",\n \"0.58242035\",\n \"0.58200246\",\n \"0.58158904\",\n \"0.5812353\",\n \"0.5812084\",\n \"0.58070534\",\n \"0.5806551\",\n \"0.5796599\",\n \"0.57933366\",\n \"0.5793268\",\n \"0.57913387\",\n \"0.57791203\",\n \"0.57759553\",\n \"0.5775642\",\n \"0.57737696\",\n \"0.57536083\",\n \"0.57488555\",\n \"0.5743656\",\n \"0.5743358\",\n \"0.5742512\",\n \"0.57380706\",\n \"0.5731987\",\n \"0.5730328\",\n \"0.5725145\",\n \"0.57240796\",\n \"0.5723337\",\n \"0.57160664\",\n \"0.57144946\",\n \"0.57076985\",\n \"0.57060075\",\n \"0.5699461\",\n \"0.5695938\",\n \"0.56943196\"\n]"},"document_score":{"kind":"string","value":"0.0"},"document_rank":{"kind":"string","value":"-1"}}},{"rowIdx":127,"cells":{"query":{"kind":"string","value":"POST /stay_times POST /stay_times.json"},"document":{"kind":"string","value":"def create\n @stay_time = StayTime.new(stay_time_params)\n\n respond_to do |format|\n if @stay_time.save\n format.html { redirect_to @stay_time, notice: 'Stay time was successfully created.' }\n format.json { render :show, status: :created, location: @stay_time }\n else\n format.html { render :new }\n format.json { render json: @stay_time.errors, status: :unprocessable_entity }\n end\n end\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def stay_time_params\n params.require(:stay_time).permit(:arrive_date, :leave_date, :nationality, :country_stay, :day_stay)\n end","def index\n @stay_times = StayTime.all\n end","def create\n @timing = Timing.new(params[:timing].slice(:start, :stop, :days, :parent_class, :parent_id, :active))\n if @timing.save\n render json: @timing\n else\n render json: { error: 'error: could not save timing' }\n end\n end","def create\n @time_gap = TimeGap.new(params[:time_gap])\n\n respond_to do |format|\n if @time_gap.save\n format.html { redirect_to @time_gap, notice: 'Time gap was successfully created.' }\n format.json { render json: @time_gap, status: :created, location: @time_gap }\n else\n format.html { render action: \"new\" }\n format.json { render json: @time_gap.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n busy_shifts = params[:busy_shift]\n if busy_shifts\n busy_shifts[:day].length.times do |index|\n day = busy_shifts[:day][index]\n start_time = busy_shifts[:start_time][index]\n end_time = busy_shifts[:end_time][index]\n @busy_shifts = current_user.busy_shifts.create(:day => day, :start_time => start_time, :end_time => end_time)\n end\n render json: current_user.busy_shifts\n else\n render json: {errors: \"Could not create busy shifts there was a error\"}\n end\n end","def create\n cnt = params[:tutor_availability][:repeat].to_i - 1\n params[:tutor_availability].delete :repeat\n @tutor_availability = TutorAvailability.new(params[:tutor_availability])\n\n respond_to do |format|\n if @tutor_availability.save\n if cnt > 0\n for i in 1..cnt\n new_ta = TutorAvailability.new(params[:tutor_availability])\n new_ta.start_time = @tutor_availability.start_time + 604800*i\n new_ta.save\n end\n end\n format.html { redirect_to tutor_availabilities_path, notice: 'Tutor availability was successfully created.' }\n format.json { render json: @tutor_availability, status: :created, location: @tutor_availability }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tutor_availability.errors, status: :unprocessable_entity }\n end\n end\n end","def set_stay_time\n @stay_time = StayTime.find(params[:id])\n end","def create\n @working_time = WorkingTime.new(params[:working_time])\n\n respond_to do |format|\n if current_user.time_tables[0].working_times << @working_time\n format.html { redirect_to time_tables_path }\n format.json { render json: @working_time, status: :created, location: @working_time }\n else\n format.html { render action: \"new\" }\n format.json { render json: @working_time.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @patient = Patient.find(params[:patient_id])\n @schedule = @patient.schedules.create(params[:schedule])\n\n # TODO can improve it to use nested attributes\n params[:pill_time].each do |pill_time|\n @schedule.pill_times.build(pill_time)\n end\n\n @pill_times = @schedule.pill_times\n\n respond_to do |format|\n if @schedule.save\n format.html { redirect_to [@patient, @schedule],\n notice: 'Schedule was successfully created.' }\n format.json { render json: @schedule,\n status: :created,\n location: [@patient, @schedule] }\n else\n format.html { render action: \"new\" }\n format.json { render json: @schedule.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @workSegment = @workday.workSegments.last\n puts @workSegment.workday.dayDate\n # if @workSegment.timePunches.count == 0\n # @currentStatus = false\n # else\n # @lastTimePunch = @workSegment.timePunches.last\n # @currentStatus = @lastTimePunch.status\n # end\n\n @time_punch = @workSegment.timePunches.new(punch: Time.current, status: true)\n\n respond_to do |format|\n if @time_punch.save\n format.html { redirect_to dashboard_path, notice: 'Time punch was successfully created.' }\n # format.json { render :show, status: :created, location: @time_punch }\n else\n format.html { redirect_to dashboard_path, notice: 'clock record was not created(from tp controller).' }\n # format.json { render json: @time_punch.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @time_tracker = TimeTracker.new({ started_at: Time.current, status: 'running' }.merge(time_tracker_params))\n\n respond_to do |format|\n if @time_tracker.save\n format.html { redirect_to @time_tracker, notice: 'Time tracker was successfully created.' }\n format.json { render :show, status: :created, location: @time_tracker }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @time_tracker.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @timeslot = Timeslot.new(timeslot_params)\n @timeslot.save!\n render :json => @timeslot.as_json\n end","def create\n @stime = Stime.new(stime_params)\n\n respond_to do |format|\n if @stime.save\n format.html { redirect_to @stime, notice: 'Stime was successfully created.' }\n format.json { render :show, status: :created, location: @stime }\n else\n format.html { render :new }\n format.json { render json: @stime.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @cooking_time = CookingTime.new(cooking_time_params)\n\n respond_to do |format|\n if @cooking_time.save\n format.html { redirect_to cooking_times_path, notice: 'Cooking time was successfully created.' }\n format.json { render action: 'show', status: :created, location: @cooking_time }\n else\n format.html { render action: 'new' }\n format.json { render json: @cooking_time.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @allocated_time = AllocatedTime.new(allocated_time_params)\n\n respond_to do |format|\n if @allocated_time.save\n format.html { redirect_to @allocated_time, notice: 'Allocated time was successfully created.' }\n format.json { render :show, status: :created, location: @allocated_time }\n else\n format.html { render :new }\n format.json { render json: @allocated_time.errors, status: :unprocessable_entity }\n end\n end\n end","def open_appointments\n date = Date.parse(params[:date])\n clinic = Clinic.find(params[:clinic_id])\n doctor = Doctor.find(params[:doctor_id])\n # @times = doctor.open_appointment_times(date)\n @times = clinic.open_appointment_times(date, doctor)\n if @times.is_a?(Hash)\n render json: {status: 1, error: @times[:error]}\n else\n render json: { status: 0, times: @times }\n end\n #@appointment = Appointment.new\n #render json: {open_times: @open_times}\n # render json: {times: [\n # {time: '8:00 AM', enabled: true, selected: false, index: 0},\n # {time: '8:30 AM', enabled: false, selected: false, index: 1},\n # {time: '9:00 AM', enabled: true, selected: false, index: 2},\n # {time: '9:30 AM', enabled: true, selected: false, index: 3},\n # {time: '10:00 AM', enabled: false, selected: false, index: 4},\n # {time: '10:30 AM', enabled: false, selected: false, index: 5},\n # {time: '11:00 AM', enabled: false, selected: false, index: 6},\n # {time: '11:30 AM', enabled: true, selected: false, index: 7},\n # {time: '12:00 PM', enabled: true, selected: false, index: 8},\n # {time: '12:30 PM', enabled: true, selected: false, index: 9},\n # {time: '1:00 PM', enabled: false, selected: false, index: 10},\n # {time: '1:30 PM', enabled: true, selected: false, index: 11},\n # {time: '2:00 PM', enabled: false, selected: false, index: 12},\n # {time: '2:30 PM', enabled: false, selected: false, index: 13},\n # {time: '3:00 PM', enabled: true, selected: false, index: 14},\n # {time: '3:30 PM', enabled: true, selected: false, index: 15},\n # {time: '4:00 PM', enabled: true, selected: false, index: 16},\n # {time: '4:30 PM', enabled: false, selected: false, index: 17},\n # {time: '5:00 PM', enabled: true, selected: false, index: 18},\n # {time: '5:30 PM', enabled: true, selected: false, index: 19}]}\n\n end","def create\n @work_time = WorkTime.new(work_time_params)\n\n respond_to do |format|\n if @work_time.save\n format.html { redirect_to @work_time, notice: 'Work time was successfully created.' }\n format.json { render :show, status: :created, location: @work_time }\n else\n format.html { render :new }\n format.json { render json: @work_time.errors, status: :unprocessable_entity }\n end\n end\n end","def create_time_request\n TimeRequest.create(\n time: [ Time.new(2000, 1, 1, 14, 0, 0, \"+00:00\").utc, Time.new(2000, 1, 1, 13, 0, 0, \"+00:00\").utc, Time.new(2000, 1, 1, 12, 0, 0, \"+00:00\").utc ].sample,\n reservation: Reservation.all.sample,\n check_in: [true, false].sample,\n status: 'pending'\n )\nend","def create\n @wait_time = WaitTime.new(params[:wait_time])\n\n respond_to do |format|\n if @wait_time.save\n format.html { redirect_to @wait_time, notice: 'Wait time was successfully created.' }\n format.json { render json: @wait_time, status: :created, location: @wait_time }\n else\n format.html { render action: \"new\" }\n format.json { render json: @wait_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @stay_time.update(stay_time_params)\n format.html { redirect_to @stay_time, notice: 'Stay time was successfully updated.' }\n format.json { render :show, status: :ok, location: @stay_time }\n else\n format.html { render :edit }\n format.json { render json: @stay_time.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @stop_time = StopTime.new(params[:stop_time])\n\n respond_to do |format|\n if @stop_time.save\n format.html { redirect_to @stop_time, notice: 'Stop time was successfully created.' }\n format.json { render json: @stop_time, status: :created, location: @stop_time }\n else\n format.html { render action: \"new\" }\n format.json { render json: @stop_time.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @wait_time = WaitTime.new(wait_time_params)\n\n respond_to do |format|\n if @wait_time.save\n format.html { redirect_to @wait_time, notice: 'Wait time was successfully created.' }\n format.json { render :show, status: :created, location: @wait_time }\n else\n format.html { render :new }\n format.json { render json: @wait_time.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @meal_time = MealTime.new(params[:meal_time])\n\n respond_to do |format|\n if @meal_time.save\n format.html { redirect_to @meal_time, notice: 'Meal time was successfully created.' }\n format.json { render json: @meal_time, status: :created, location: @meal_time }\n else\n format.html { render action: \"new\" }\n format.json { render json: @meal_time.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @time_registration = TimeRegistration.create(time_registration_params)\n respond_to do |format|\n if @time_registration.save\n format.json { render :show, status: :created, location: @time_registration }\n else\n format.json { render json: @time_registration.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @time_of_day = TimeOfDay.new(time_of_day_params)\n\n respond_to do |format|\n if @time_of_day.save\n format.html { redirect_to @time_of_day, notice: 'Time of day was successfully created.' }\n format.json { render :show, status: :created, location: @time_of_day }\n else\n format.html { render :new }\n format.json { render json: @time_of_day.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @downtime = Downtime.new(downtime_params)\n\n respond_to do |format|\n if @downtime.save\n format.html { redirect_to @downtime, notice: 'Downtime was successfully created.' }\n format.json { render action: 'show', status: :created, location: @downtime }\n else\n format.html { render action: 'new' }\n format.json { render json: @downtime.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @meeting_time = MeetingTime.new(meeting_time_params)\n\n respond_to do |format|\n if @meeting_time.save\n format.html { redirect_to @meeting_time, notice: 'Meeting time was successfully created.' }\n format.json { render action: 'show', status: :created, location: @meeting_time }\n else\n format.html { render action: 'new' }\n format.json { render json: @meeting_time.errors, status: :unprocessable_entity }\n end\n end\n end","def postEntityOpening_times( entity_id, monday, tuesday, wednesday, thursday, friday, saturday, sunday, closed, closed_public_holidays)\n params = Hash.new\n params['entity_id'] = entity_id\n params['monday'] = monday\n params['tuesday'] = tuesday\n params['wednesday'] = wednesday\n params['thursday'] = thursday\n params['friday'] = friday\n params['saturday'] = saturday\n params['sunday'] = sunday\n params['closed'] = closed\n params['closed_public_holidays'] = closed_public_holidays\n return doCurl(\"post\",\"/entity/opening_times\",params)\n end","def stay_night_params\n params.require(:stay_night).permit(:today, :city_id, :hotel_id, :rate, :comment)\n end","def create\n @nursing_time = NursingTime.new(params[:nursing_time])\n\n respond_to do |format|\n if @nursing_time.save\n format.html { redirect_to @nursing_time, notice: 'Nursing time was successfully created.' }\n format.json { render json: @nursing_time, status: :created, location: @nursing_time }\n else\n format.html { render action: \"new\" }\n format.json { render json: @nursing_time.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @time_slot = TimeSlot.new(time_slot_params)\n\n if @time_slot.save\n render :show, status: :created, location: @time_slot\n else\n render json: @time_slot.errors, status: :unprocessable_entity\n end\n end","def create\n @timing = Timing.new(timing_params)\n\n if @timing.save\n render :show, status: :created, location: @timing\n else\n render json: @timing.errors, status: :unprocessable_entity\n end\n end","def create\n @punchtime = current_user.punchtimes.build(punchtime_params)\n respond_to do |format|\n if @punchtime.save\n format.html { redirect_to( current_user, notice: 'Punchtime was successfully created.') }\n format.json { render :show, status: :created, location: @punchtime }\n else\n format.html { render :new }\n format.json { render json: @punchtime.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @time_slot = TimeSlot.new(params[:time_slot])\n @time_slot.user_id = current_identity.user_id\n\t@recurrence_array = []\n respond_to do |format|\n if @time_slot.save\n format.html { redirect_to @time_slot, notice: 'Time slot was successfully created.' }\n format.json { render json: @time_slot, status: :created, location: @time_slot }\n else\n format.html { render action: \"new\" }\n format.json { render json: @time_slot.errors, status: :unprocessable_entity }\n end\n end\n end","def stime_params\n params.require(:stime).permit(:time, :meet_id, :swimmer_id, :stroke_id)\n end","def create\n @work_order_time = WorkOrderTime.new(work_order_time_params)\n\n respond_to do |format|\n if @work_order_time.save\n format.html { redirect_to @work_order_time, notice: 'Work order time was successfully created.' }\n format.json { render :show, status: :created, location: @work_order_time }\n else\n format.html { render :new }\n format.json { render json: @work_order_time.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @service_time = ServiceTime.new(params[:service_time])\n\n respond_to do |format|\n if @service_time.save\n format.html { redirect_to @service_time, notice: 'Service time was successfully created.' }\n format.json { render json: @service_time, status: :created, location: @service_time }\n else\n format.html { render action: \"new\" }\n format.json { render json: @service_time.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @timeslot = Timeslot.new(timeslot_params)\n\n if @timeslot.save\n render :show, status: :created, location: @timeslot\n else\n render json: @timeslot.errors, status: :unprocessable_entity\n end\n end","def create\n @my_time_trial = MyTimeTrial.new(params[:my_time_trial])\n\n respond_to do |format|\n if @my_time_trial.save\n format.html { redirect_to @my_time_trial, :notice => 'My time trial was successfully created.' }\n format.json { render :json => @my_time_trial, :status => :created, :location => @my_time_trial }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @my_time_trial.errors, :status => :unprocessable_entity }\n end\n end\n end","def maketime\n\n openingtime = OpeningTime.new do |u|\n u.day = params[:opening_times][:day]\n u.from = \"9:00\"\n u.to = \"12 Noon\"\n u.on = true\n u.position = params[:opening_times][:position]\n \n \n end\n openingtime.save\n redirect_to \"/\"\n end","def create\n @time_slot = TimeSlot.create(time_slot_params)\n\n respond_to do |format|\n if @time_slot.save\n format.html { redirect_to @time_slot, notice: 'Time slot was successfully created.' }\n format.json { render :show, status: :created, location: @time_slot }\n else\n format.html { render :new }\n format.json { render json: @time_slot.errors, status: :unprocessable_entity }\n end\n end\n end","def new\n @time_gap = TimeGap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @time_gap }\n end\n end","def create\n @tombstone_timehold = TombstoneTimehold.new(tombstone_timehold_params)\n\n respond_to do |format|\n if @tombstone_timehold.save\n format.html { redirect_to @tombstone_timehold, notice: 'Tombstone timehold was successfully created.' }\n format.json { render :show, status: :created, location: @tombstone_timehold }\n else\n format.html { render :new }\n format.json { render json: @tombstone_timehold.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @p_time = PTime.new(p_time_params)\n\n respond_to do |format|\n if @p_time.save\n format.html { redirect_to @p_time, notice: 'P time was successfully created.' }\n format.json { render :show, status: :created, location: @p_time }\n else\n format.html { render :new }\n format.json { render json: @p_time.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @time_clock = TimeClock.new(time_clock_params)\n\n respond_to do |format|\n if @time_clock.save\n format.html { redirect_to time_sheet_index_path(@time_clock), notice: 'Time clock entry was successfully created.' }\n format.json { render action: 'show', status: :created, location: @time_clock }\n else\n format.html { render action: 'new' }\n format.json { render json: @time_clock.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @ride = Ride.new(ride_params)\n @ride.assembly_time = params[:ride][:assembly_time]\n @ride.destination_time = params[:ride][:destination_time]\n @ride.check_points = params[:ride][:check_points]\n if @ride.save\n @ride.delay.call_notification(I18n.t('Notification.ride_created'), I18n.t('Email.ride_created'))\n render json: @ride, status: :created\n else\n render json: @ride.errors, status: :unprocessable_entity\n end\n end","def create\n @schedule = Schedule.new(params[:schedule])\n times =[]\n count_days = 0\n days = params[:day].join(\", \") if params[:day]\n (0..6).each do |i|\n if params[:hour][i].present? && params[:minute][i].present?\n times<< \"#{params[:hour][i]}:#{ params[:minute][i]}\"\n end\n end\n\n count_days = params[:day].count if params[:day]\n count_times = times.count\n\n if count_days == count_times\n\n if count_days && count_times != 0\n times = times.join(\", \")\n @schedule.day = days\n @schedule.time = times\n end\n respond_to do |format|\n if @schedule.save\n format.html { redirect_to @schedule, notice: 'Schedule was successfully created.' }\n format.json { render json: @schedule, status: :created, location: @schedule }\n else\n format.html { render action: \"new\" }\n format.json { render json: @schedule.errors, status: :unprocessable_entity }\n end\n end\n\n else\n #redirect_to new_schedule_path, notice: \"даныне введены некорректно (день-время)\"\n render action: \"new\"\n end\n end","def create\n @day_timeslot = DayTimeslot.new(day_timeslot_params)\n\n respond_to do |format|\n if @day_timeslot.save\n format.html { redirect_to @day_timeslot, notice: 'Day timeslot was successfully created.' }\n format.json { render action: 'show', status: :created, location: @day_timeslot }\n else\n format.html { render action: 'new' }\n format.json { render json: @day_timeslot.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @planned_time = PlannedTime.new(params[:planned_time])\n\n respond_to do |format|\n if @planned_time.save\n format.html { redirect_to @planned_time, notice: 'Planned time was successfully created.' }\n format.json { render json: @planned_time, status: :created, location: @planned_time }\n else\n format.html { render action: \"new\" }\n format.json { render json: @planned_time.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @timeslot = Timeslot.new(timeslot_params)\n @current_faculty = Faculty.where(email: current_user.email).first\n @timeslot.faculty_id = @current_faculty.id\n @timeslot.title = \"Timeslot Available for #{@current_faculty.full_name}\"\n @timeslot.end = (@timeslot.start.to_time + 1.hours).to_datetime\n @timeslot.save\n\n respond_to do |format|\n if @timeslot.save\n format.json {render :json => @timeslot}\n else\n format.json {render :status => 400}\n end\n end\n end","def create\n @time_entry = TimeEntry.new(time_entry_params)\n\n respond_to do |format|\n if @time_entry.save\n format.html { redirect_to @time_entry, notice: 'Time entry was successfully created.' }\n format.json { render :show, status: :created, location: @time_entry }\n else\n format.html { render :new }\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\n end\n end\n end","def index\n @time_entry ||= current_user.time_entries.build(\n :tdate => Date.today\n )\n \n @time_entries = current_firm.all_time_entries\n\n respond_to do |format|\n format.html { render :index }# index.html.erb\n format.json { render json: @time_entries }\n end\n end","def create\n @timetable = Timetable.new(params[:timetable])\n\n respond_to do |format|\n if @timetable.save\n format.html { redirect_to @timetable, notice: 'Timetable was successfully created.' }\n format.json { render json: @timetable, status: :created, location: @timetable }\n else\n format.html { render action: \"new\" }\n format.json { render json: @timetable.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @time_entry = TimeEntry.new(params[:time_entry])\n\n respond_to do |format|\n if @time_entry.save\n format.html { redirect_to @time_entry, notice: 'Time entry was successfully created.' }\n format.json { render json: @time_entry, status: :created, location: @time_entry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @time_entry = TimeEntry.new(params[:time_entry])\n\n respond_to do |format|\n if @time_entry.save\n format.html { redirect_to @time_entry, notice: 'Time entry was successfully created.' }\n format.json { render json: @time_entry, status: :created, location: @time_entry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @time_entry = TimeEntry.new(params[:time_entry])\n\n respond_to do |format|\n if @time_entry.save\n format.html { redirect_to @time_entry, notice: 'Time entry was successfully created.' }\n format.json { render json: @time_entry, status: :created, location: @time_entry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @timer = Timer.new(timer_params)\n\n if @timer.save\n render json: @timer, status: :created, location: @timer\n else\n render json: @timer.errors, status: :unprocessable_entity\n end\n end","def new\n @patient = Patient.find(params[:patient_id])\n current_schedule = @patient.current_schedule\n if current_schedule\n current_schedule.terminated_at = Date.today\n current_schedule.save\n end\n @schedule = @patient.schedules.build\n @pill_times = [@schedule.pill_times.build]\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @schedule }\n end\n end","def destroy\n @stay_time.destroy\n respond_to do |format|\n format.html { redirect_to stay_times_url, notice: 'Stay time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def create\n @session_time = SessionTime.new(session_time_params)\n\n respond_to do |format|\n if @session_time.save\n format.html { redirect_to @session_time, notice: 'Session time was successfully created.' }\n format.json { render :show, status: :created, location: @session_time }\n else\n format.html { render :new }\n format.json { render json: @session_time.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n\n \t\t\t@teetime = Teetime.new teetime_params\n\n \t\t\tif @teetime.save\n\n \t\t\t\trender json: @teetime,status: :created\n\n \t\t\telse\n\n \t\t\t\trender json: {error: true,errors: @teetime.errors},status: :unprocessable_entity\n\n \t\t\tend\n\n \t\tend","def create\n @location_time = LocationTime.new(location_time_params)\n\n respond_to do |format|\n if @location_time.save\n format.html { redirect_to @location_time, notice: 'Location time was successfully created.' }\n format.json { render action: 'show', status: :created, location: @location_time }\n else\n format.html { render action: 'new' }\n format.json { render json: @location_time.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @poi_time = PoiTime.new(poi_time_params)\n\n respond_to do |format|\n if @poi_time.save\n format.html { redirect_to @poi_time, notice: 'Poi time was successfully created.' }\n format.json { render :show, status: :created, location: @poi_time }\n else\n format.html { render :new }\n format.json { render json: @poi_time.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @time_record = WorkTimeRecord.new(time_record_params)\n\n respond_to do |format|\n if @time_record.save\n format.html { redirect_to @time_record, notice: 'Time record was successfully created.' }\n format.json { render :show, status: :created, location: @time_record }\n else\n format.html { render :new }\n format.json { render json: @time_record.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @timed_task = TimedTask.new(timed_task_params)\n\n respond_to do |format|\n if @timed_task.save\n format.html { redirect_to @timed_task, notice: 'Timed task was successfully created.' }\n format.json { render :show, status: :created, location: @timed_task }\n else\n format.html { render :new }\n format.json { render json: @timed_task.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @timeslot = current_event.timeslots.new(params[:timeslot])\n \n respond_to do |format|\n if @timeslot.save\n flash[:notice] = 'Timeslot was successfully created.'\n format.html { redirect_to(timeslots_url) }\n format.xml { render :xml => @timeslot, :status => :created, :location => @timeslot }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @timeslot.errors, :status => :unprocessable_entity }\n end\n end\n end","def create\n \n #timestamp={{FellAsleepAt}}&total_sleep={{TotalTimeSleptInSeconds}}&deep={{TimeInDeepSleepSeconds}}&light={{TimeInLightSleepSeconds}}&awake={{TimeAwakeSeconds}}\n \n json_hash = Hash.new\n \n description = params[:description]\n \n timestamp = params[:timestamp]\n total_sleep_seconds = params[:total_sleep]\n deep_sleep_seconds = params[:deep]\n light_sleep_seconds = params[:light]\n awake_seconds = params[:awake]\n \n if timestamp.nil? || total_sleep_seconds.nil?\n \n puts 'timestamp is nil or total_sleep_seconds is nil :('\n \n else\n \n total_sleep = total_sleep_seconds / 60.0\n deep = deep_sleep_seconds / 60.0\n light = light_sleep_seconds / 60.0\n awake = awake_seconds / 60.0\n \n post_to_twitter = false\n post_to_facebook = false\n \n # FellAsleepAt is formatted: August 23, 2013 at 11:01PM\n # Convert to Runkeeper's preferred format: Sat, 1 Jan 2011 00:00:00\n timestamp_datetime = DateTime.parse(timestamp)\n formatted_timestamp = timestamp_datetime.strftime(\"%a, %d %b %Y %H:%M:%S\")\n \n json_hash['timestamp'] = formatted_timestamp\n json_hash['total_sleep'] = deep\n json_hash['deep'] = deep\n json_hash['light'] = light\n json_hash['awake'] = awake\n json_hash['post_to_twitter'] = post_to_twitter\n json_hash['post_to_facebook'] = post_to_facebook\n \n url = 'https://api.runkeeper.com/sleep'\n \n uri = URI.parse(url)\n \n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n request = Net::HTTP::Post.new(uri.request_uri)\n request[\"Authorization\"] = \"Bearer \" + RUNKEEPER_ACCESS_TOKEN\n request[\"Content-Type\"] = \"application/vnd.com.runkeeper.NewSleep+json\"\n request.body = json_hash.to_json\n \n response = http.request(request)\n \n puts response.body\n \n end\n \n @sleep = json_hash\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sleep }\n end\n \n end","def wait_time_params\n params.require(:wait_time).permit(:restaurant_id, :party_size, :minutes, :checked_at)\n end","def trip_params\n params.require(:trip).permit(:starts_on, :ends_on, :name, :location, {:item_ids => []})\n end","def create\n @time_record = TimeRecord.new(params[:time_record])\n @time_record.value = (@time_record.ended_at - @time_record.started_at) / 1.hour\n @time_record.recorded_on = @time_record.started_at.to_date\n\n respond_to do |format|\n if @time_record.save\n format.html { redirect_to time_records_path, notice: 'Time record was successfully created.' }\n format.json { render json: @time_record.to_json, status: :created, location: @time_record }\n else\n format.html { render action: \"new\" }\n format.json { render json: @time_record.errors.full_messages, status: :unprocessable_entity }\n end\n end\n end","def times_game_params\n params.require(:times_game).permit(:point, :sta)\n end","def tombstone_timehold_params\n params.require(:tombstone_timehold).permit(:tombstoneJSON, :permanent, :rating)\n end","def create\n @planning_time = PlanningTime.new(params[:planning_time])\n\n respond_to do |format|\n if @planning_time.save\n format.html { redirect_to @planning_time, notice: 'Planning time was successfully created.' }\n format.json { render json: @planning_time, status: :created, location: @planning_time }\n else\n format.html { render action: \"new\" }\n format.json { render json: @planning_time.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n attendance_params[:checkin] = attendance_params[:checkin].to_time\n attendance_params[:checkout] = attendance_params[:checkout].to_time\n attendance_params[:attendance_date] = attendance_params[:attendance_date].to_date\n\n r = @api.create_attendance(attendance_params)\n respond_to do |format|\n if r.code == 201\n format.html { redirect_to attendances_url, notice: 'Attendance was successfully created.' }\n else\n response = JSON.parse(r.body)\n format.html { redirect_to attendances_url, alert: response['message']}\n end\n end\n end","def create\n @timetable = Timetable.new(timetable_params)\n\n respond_to do |format|\n if @timetable.save\n format.html { redirect_to request.referer, notice: 'Timetable was successfully created.' }\n format.json { render :show, status: :created, location: @timetable }\n else\n format.html { render :new }\n format.json { render json: @timetable.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @working_start_time = WorkingStartTime.new(working_start_time_params)\n\n respond_to do |format|\n if @working_start_time.save\n format.html { redirect_to @working_start_time, notice: 'Working start time was successfully created.' }\n format.json { render action: 'show', status: :created, location: @working_start_time }\n else\n format.html { render action: 'new' }\n format.json { render json: @working_start_time.errors, status: :unprocessable_entity }\n end\n end\n end","def create_day\n trip = Trip.find(params[:id])\n offset = 0\n trip.days.all.each do |day|\n offset += 1\n end\n @day = Day.new({\"date\" => trip.beginning + offset , \"trip\" => trip})\n trip.update_attribute(:duration, trip.attributes['duration'] + 1)\n trip.save\n respond_to do |format|\n if @day.save\n format.html { redirect_to trip, notice: 'Day was successfully created.' }\n format.json { render :show, status: :created, location: @day }\n else\n format.html { render home_path }\n format.json { render json: @day.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @appointment = Appointment.new(appointment_params)\n if @appointment.starts_at != nil\n @appointment.ends_at = @appointment.starts_at + 30.minutes\n end\n respond_to do |format|\n if @appointment.save\n format.html { redirect_to new_appointment_path, notice: 'Agendamento realizado.' }\n format.json { render :show, status: :created, location: @appointment }\n else\n format.html { render :schedule }\n format.json { render json: @appointment.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @order_break_time = OrderBreakTime.new(order_break_time_params)\n\n respond_to do |format|\n if @order_break_time.save\n format.html { redirect_to @order_break_time, notice: 'Order break time was successfully created.' }\n format.json { render 'show', status: :created, location: @order_break_time }\n else\n format.html { render 'new' }\n format.json { render json: @order_break_time.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @hotel_stay = HotelStay.new(params[:hotel_stay])\n\n respond_to do |format|\n if @hotel_stay.save\n format.html { redirect_to @hotel_stay, notice: 'Hotel stay was successfully created.' }\n format.json { render json: @hotel_stay, status: :created, location: @hotel_stay }\n else\n format.html { render action: \"new\" }\n format.json { render json: @hotel_stay.errors, status: :unprocessable_entity }\n end\n end\n end","def timecontroll_params\n params.require(:timecontroll).permit(:start, :end, :gap)\n end","def create\n @daytime = Daytime.new(params[:daytime])\n\n respond_to do |format|\n if @daytime.save\n format.html { redirect_to @daytime, notice: 'Daytime was successfully created.' }\n format.json { render json: @daytime, status: :created, location: @daytime }\n else\n format.html { render action: \"new\" }\n format.json { render json: @daytime.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @transaction = Transaction.new(transaction_params)\n @transaction.update(user_id: session[:user_id])\n @transaction.update(status: 'Scheduled')\n\n @timingsList = []\n @datesList = []\n @timings = Timing.find_by_sql(\"SELECT day, hours, minutes, ampm FROM timings\")\n @timings.each do |timing|\n timing.day = date_of_next(timing.day).strftime(\"%d %b %Y\") + \" - \" + timing.hours + \":\" + timing.minutes + \" \" + timing.ampm\n @timingsList.push([timing.day, timing.day])\n end\n for i in 0..9\n @datesList.push([(Date.today+i).strftime(\"%d %b %Y\"), (Date.today+i).strftime(\"%d %b %Y\")])\n end\n\n respond_to do |format|\n if @transaction.save\n format.html { redirect_to transactions_path, notice: 'Transaction was successfully created.' }\n format.json { render :show, status: :created, location: @transaction }\n else\n format.html { render :new }\n format.json { render json: @transaction.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @drop_route_start_time = DropRouteStartTime.new(drop_route_start_time_params)\n\n respond_to do |format|\n if @drop_route_start_time.save\n format.html { redirect_to drop_route_start_times_path, notice: 'Drop route start time was successfully created.' }\n format.json { render :show, status: :created, location: @drop_route_start_time }\n else\n format.html { render :new }\n format.json { render json: @drop_route_start_time.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @trip_schedule = TripSchedule.new(trip_schedule_params)\n\n respond_to do |format|\n if @trip_schedule.save\n format.html { redirect_to @trip_schedule, notice: 'Trip schedule was successfully created.' }\n format.json { render :show, status: :created, location: @trip_schedule }\n else\n format.html { render :new }\n format.json { render json: @trip_schedule.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n if params[:pay_day] && params[:start_day] && params[:end_day]\n ::TimeEntry.where(pay_day: params[:pay_day]).update_all(pay_day: nil)\n ::TimeEntry.where(\"day>=? AND day<=?\",params[:start_day],params[:end_day]).update_all(pay_day: params[:pay_day])\n end\n redirect_to \"/time/#{params[:start_day]}\"\n end","def create\n @user = User.find(params[:user_id])\n @clock_time = @user.clock_times.new(params[:clock_time])\n\n time_in_to_update = get_time_to_update(params[\"use_current\"], params[:clock_time], \"in\")\n\n\n @clock_time.in = time_in_to_update\n\n respond_to do |format|\n if @clock_time.save\n format.html { redirect_to @user, notice: 'You have successfully clocked in' }\n format.json { render json: @clock_time, status: :created, location: @clock_time }\n format.js\n else\n format.html { render action: \"new\" }\n format.json { render json: @clock_time.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end","def transit_times(shipment, options:, debug: false)\n request = FriendlyShipping::Request.new(\n url: API_BASE + API_PATHS[:transit_times],\n http_method: \"POST\",\n body: SerializeTransitTimesRequest.call(shipment: shipment, options: options).to_json,\n headers: request_headers,\n debug: debug\n )\n client.post(request).bind do |response|\n ParseTransitTimesResponse.call(request: request, response: response)\n end\n end","def create\n @disatance_and_time = DisatanceAndTime.new(disatance_and_time_params)\n\n respond_to do |format|\n if @disatance_and_time.save\n format.html { redirect_to @disatance_and_time, notice: 'Disatance and time was successfully created.' }\n format.json { render :show, status: :created, location: @disatance_and_time }\n else\n format.html { render :new }\n format.json { render json: @disatance_and_time.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @selected_time = SelectedTime.new(selected_time_params)\n\n respond_to do |format|\n if @selected_time.save\n format.html { redirect_to @selected_time, notice: 'Selected time was successfully created.' }\n format.json { render :show, status: :created, location: @selected_time }\n else\n format.html { render :new }\n format.json { render json: @selected_time.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @start_time = params[:start_time].to_datetime.strftime(\"%Y-%m-%d %H:%M:%S\")\n @end_time = params[:end_time].to_datetime.strftime(\"%Y-%m-%d %H:%M:%S\")\n @service = params[:service_item_id]\n\n @hours = params[:hours]\n @minutes = params[:minutes]\n @seconds = params[:seconds]\n\n @quantity = @hours.to_s+':'+@minutes.to_s+':'+@seconds.to_s\n \n @jobtime = Jobtime.new(:start_time => @start_time, :end_time => @end_time,:qty => @quantity,:company_id => current_login.id,:job_id => params[:job_id],:jobsite_id => params[:jobsite_id],:customer_id => params[:customer_id],:user => current_login.name, :timetype => \"Actual Time\", :service => @service)\n \n if @jobtime.save(:validate => false)\n response_message = {:message => \"Jobtime successfully created.\", :jobtime => @jobtime}\n else\n response_message = {:message => \"Jobtime creation failed. Please try again.\"} \n end\n \n respond_to do |format|\n format.xml { render :xml => response_message }\n format.json { render :json => response_message }\n end\n end","def jobtime_shedule\n @jobtime = Jobtime.new(params[:jobtime])\n\n @qty = @jobtime.qty.to_i.hours\n @item = Item.find(@jobtime.service)\n\n #calculate end_time\n @jobtime.end_time = @jobtime.start_time+@qty\n\n #calculate cost\n @jobtime.cost = @item.unit_cost * @qty\n\n #calculate price\n if(@jobtime.billable.present?)\n @jobtime.price = @item.unit_price * @qty\n else\n @jobtime.price = 0\n end\n puts @jobtime.errors.inspect\n if @jobtime.save\n response_message = {:message => \"Time was scheduled successfully.\",:jobtime => @jobtime }\n else\n response_message = {:message => \"Please try again.\"}\n end\n respond_to do |format|\n format.xml{render :xml => response_message }\n format.json{render :json => response_message }\n end\n end","def new\n @travel_datum = TravelDatum.new\n @travel_datum.start_time = Time.now.beginning_of_day + 9.hours\n @travel_datum.end_of_business_time = Time.now.beginning_of_day+17.hours\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @travel_datum }\n format.xml { render :xml => @travel_data }\n end\n end","def create\n @trip = Trip.new(trip_params)\n @trip.session_id = session.id\n @trip.user_id = current_user.id\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to @trip.parent || @trip, notice: 'Trip was successfully created.', change: 'list' }\n format.json { render action: 'show', status: :created, location: @trip, day: 1 }\n else\n format.html { render action: 'new' }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @receiver_time = ReceiverTime.new(params[:receiver_time])\n\n respond_to do |format|\n if @receiver_time.save\n format.html { redirect_to @receiver_time, notice: 'Receiver time was successfully created.' }\n format.json { render json: @receiver_time, status: :created, location: @receiver_time }\n else\n format.html { render action: \"new\" }\n format.json { render json: @receiver_time.errors, status: :unprocessable_entity }\n end\n end\n end","def lession_time_params\n params.require(:lession_time).permit(:day, :start_at, :end_at)\n end","def outing_params\n params.require(:outing).permit(:day, :location_id, :time)\n end","def create\n @time_table = TimeTable.new(time_table_params)\n \n session.delete(:return_to)\n session[:return_to] ||= request.referer\n\n respond_to do |format|\n if @time_table.save\n format.html { redirect_to session.delete(:return_to), notice: 'Time table was successfully created.' }\n format.json { render :show, status: :created, location: @time_table }\n else\n format.html { render :new }\n format.json { render json: @time_table.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n @time_treinador = TimeTreinador.new(time_treinador_params)\n @time_treinador.treinador = @treinador\n\n respond_to do |format|\n if @time_treinador.save\n format.html { redirect_to @time_treinador, notice: 'Time criado com sucesso' }\n format.json { render :show, status: :created, location: @time_treinador }\n else\n format.html { render :new }\n format.json { render json: @time_treinador.errors, status: :unprocessable_entity }\n end\n end\n end","def create\n set_user\n @time_off = TimeOff.new(time_off_params)\n\n respond_to do |format|\n if @time_off.save\n format.html { redirect_to user_time_off_path(@user, @time_off), notice: 'Time off was successfully created.' }\n format.json { render action: 'show', status: :created, location: @time_off }\n else\n format.html { render action: 'new' }\n format.json { render json: @time_off.errors, status: :unprocessable_entity }\n end\n end\n end"],"string":"[\n \"def stay_time_params\\n params.require(:stay_time).permit(:arrive_date, :leave_date, :nationality, :country_stay, :day_stay)\\n end\",\n \"def index\\n @stay_times = StayTime.all\\n end\",\n \"def create\\n @timing = Timing.new(params[:timing].slice(:start, :stop, :days, :parent_class, :parent_id, :active))\\n if @timing.save\\n render json: @timing\\n else\\n render json: { error: 'error: could not save timing' }\\n end\\n end\",\n \"def create\\n @time_gap = TimeGap.new(params[:time_gap])\\n\\n respond_to do |format|\\n if @time_gap.save\\n format.html { redirect_to @time_gap, notice: 'Time gap was successfully created.' }\\n format.json { render json: @time_gap, status: :created, location: @time_gap }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @time_gap.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n busy_shifts = params[:busy_shift]\\n if busy_shifts\\n busy_shifts[:day].length.times do |index|\\n day = busy_shifts[:day][index]\\n start_time = busy_shifts[:start_time][index]\\n end_time = busy_shifts[:end_time][index]\\n @busy_shifts = current_user.busy_shifts.create(:day => day, :start_time => start_time, :end_time => end_time)\\n end\\n render json: current_user.busy_shifts\\n else\\n render json: {errors: \\\"Could not create busy shifts there was a error\\\"}\\n end\\n end\",\n \"def create\\n cnt = params[:tutor_availability][:repeat].to_i - 1\\n params[:tutor_availability].delete :repeat\\n @tutor_availability = TutorAvailability.new(params[:tutor_availability])\\n\\n respond_to do |format|\\n if @tutor_availability.save\\n if cnt > 0\\n for i in 1..cnt\\n new_ta = TutorAvailability.new(params[:tutor_availability])\\n new_ta.start_time = @tutor_availability.start_time + 604800*i\\n new_ta.save\\n end\\n end\\n format.html { redirect_to tutor_availabilities_path, notice: 'Tutor availability was successfully created.' }\\n format.json { render json: @tutor_availability, status: :created, location: @tutor_availability }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @tutor_availability.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def set_stay_time\\n @stay_time = StayTime.find(params[:id])\\n end\",\n \"def create\\n @working_time = WorkingTime.new(params[:working_time])\\n\\n respond_to do |format|\\n if current_user.time_tables[0].working_times << @working_time\\n format.html { redirect_to time_tables_path }\\n format.json { render json: @working_time, status: :created, location: @working_time }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @working_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @patient = Patient.find(params[:patient_id])\\n @schedule = @patient.schedules.create(params[:schedule])\\n\\n # TODO can improve it to use nested attributes\\n params[:pill_time].each do |pill_time|\\n @schedule.pill_times.build(pill_time)\\n end\\n\\n @pill_times = @schedule.pill_times\\n\\n respond_to do |format|\\n if @schedule.save\\n format.html { redirect_to [@patient, @schedule],\\n notice: 'Schedule was successfully created.' }\\n format.json { render json: @schedule,\\n status: :created,\\n location: [@patient, @schedule] }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @schedule.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @workSegment = @workday.workSegments.last\\n puts @workSegment.workday.dayDate\\n # if @workSegment.timePunches.count == 0\\n # @currentStatus = false\\n # else\\n # @lastTimePunch = @workSegment.timePunches.last\\n # @currentStatus = @lastTimePunch.status\\n # end\\n\\n @time_punch = @workSegment.timePunches.new(punch: Time.current, status: true)\\n\\n respond_to do |format|\\n if @time_punch.save\\n format.html { redirect_to dashboard_path, notice: 'Time punch was successfully created.' }\\n # format.json { render :show, status: :created, location: @time_punch }\\n else\\n format.html { redirect_to dashboard_path, notice: 'clock record was not created(from tp controller).' }\\n # format.json { render json: @time_punch.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @time_tracker = TimeTracker.new({ started_at: Time.current, status: 'running' }.merge(time_tracker_params))\\n\\n respond_to do |format|\\n if @time_tracker.save\\n format.html { redirect_to @time_tracker, notice: 'Time tracker was successfully created.' }\\n format.json { render :show, status: :created, location: @time_tracker }\\n else\\n format.html { render :new, status: :unprocessable_entity }\\n format.json { render json: @time_tracker.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @timeslot = Timeslot.new(timeslot_params)\\n @timeslot.save!\\n render :json => @timeslot.as_json\\n end\",\n \"def create\\n @stime = Stime.new(stime_params)\\n\\n respond_to do |format|\\n if @stime.save\\n format.html { redirect_to @stime, notice: 'Stime was successfully created.' }\\n format.json { render :show, status: :created, location: @stime }\\n else\\n format.html { render :new }\\n format.json { render json: @stime.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @cooking_time = CookingTime.new(cooking_time_params)\\n\\n respond_to do |format|\\n if @cooking_time.save\\n format.html { redirect_to cooking_times_path, notice: 'Cooking time was successfully created.' }\\n format.json { render action: 'show', status: :created, location: @cooking_time }\\n else\\n format.html { render action: 'new' }\\n format.json { render json: @cooking_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @allocated_time = AllocatedTime.new(allocated_time_params)\\n\\n respond_to do |format|\\n if @allocated_time.save\\n format.html { redirect_to @allocated_time, notice: 'Allocated time was successfully created.' }\\n format.json { render :show, status: :created, location: @allocated_time }\\n else\\n format.html { render :new }\\n format.json { render json: @allocated_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def open_appointments\\n date = Date.parse(params[:date])\\n clinic = Clinic.find(params[:clinic_id])\\n doctor = Doctor.find(params[:doctor_id])\\n # @times = doctor.open_appointment_times(date)\\n @times = clinic.open_appointment_times(date, doctor)\\n if @times.is_a?(Hash)\\n render json: {status: 1, error: @times[:error]}\\n else\\n render json: { status: 0, times: @times }\\n end\\n #@appointment = Appointment.new\\n #render json: {open_times: @open_times}\\n # render json: {times: [\\n # {time: '8:00 AM', enabled: true, selected: false, index: 0},\\n # {time: '8:30 AM', enabled: false, selected: false, index: 1},\\n # {time: '9:00 AM', enabled: true, selected: false, index: 2},\\n # {time: '9:30 AM', enabled: true, selected: false, index: 3},\\n # {time: '10:00 AM', enabled: false, selected: false, index: 4},\\n # {time: '10:30 AM', enabled: false, selected: false, index: 5},\\n # {time: '11:00 AM', enabled: false, selected: false, index: 6},\\n # {time: '11:30 AM', enabled: true, selected: false, index: 7},\\n # {time: '12:00 PM', enabled: true, selected: false, index: 8},\\n # {time: '12:30 PM', enabled: true, selected: false, index: 9},\\n # {time: '1:00 PM', enabled: false, selected: false, index: 10},\\n # {time: '1:30 PM', enabled: true, selected: false, index: 11},\\n # {time: '2:00 PM', enabled: false, selected: false, index: 12},\\n # {time: '2:30 PM', enabled: false, selected: false, index: 13},\\n # {time: '3:00 PM', enabled: true, selected: false, index: 14},\\n # {time: '3:30 PM', enabled: true, selected: false, index: 15},\\n # {time: '4:00 PM', enabled: true, selected: false, index: 16},\\n # {time: '4:30 PM', enabled: false, selected: false, index: 17},\\n # {time: '5:00 PM', enabled: true, selected: false, index: 18},\\n # {time: '5:30 PM', enabled: true, selected: false, index: 19}]}\\n\\n end\",\n \"def create\\n @work_time = WorkTime.new(work_time_params)\\n\\n respond_to do |format|\\n if @work_time.save\\n format.html { redirect_to @work_time, notice: 'Work time was successfully created.' }\\n format.json { render :show, status: :created, location: @work_time }\\n else\\n format.html { render :new }\\n format.json { render json: @work_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create_time_request\\n TimeRequest.create(\\n time: [ Time.new(2000, 1, 1, 14, 0, 0, \\\"+00:00\\\").utc, Time.new(2000, 1, 1, 13, 0, 0, \\\"+00:00\\\").utc, Time.new(2000, 1, 1, 12, 0, 0, \\\"+00:00\\\").utc ].sample,\\n reservation: Reservation.all.sample,\\n check_in: [true, false].sample,\\n status: 'pending'\\n )\\nend\",\n \"def create\\n @wait_time = WaitTime.new(params[:wait_time])\\n\\n respond_to do |format|\\n if @wait_time.save\\n format.html { redirect_to @wait_time, notice: 'Wait time was successfully created.' }\\n format.json { render json: @wait_time, status: :created, location: @wait_time }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @wait_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @stay_time.update(stay_time_params)\\n format.html { redirect_to @stay_time, notice: 'Stay time was successfully updated.' }\\n format.json { render :show, status: :ok, location: @stay_time }\\n else\\n format.html { render :edit }\\n format.json { render json: @stay_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @stop_time = StopTime.new(params[:stop_time])\\n\\n respond_to do |format|\\n if @stop_time.save\\n format.html { redirect_to @stop_time, notice: 'Stop time was successfully created.' }\\n format.json { render json: @stop_time, status: :created, location: @stop_time }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @stop_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @wait_time = WaitTime.new(wait_time_params)\\n\\n respond_to do |format|\\n if @wait_time.save\\n format.html { redirect_to @wait_time, notice: 'Wait time was successfully created.' }\\n format.json { render :show, status: :created, location: @wait_time }\\n else\\n format.html { render :new }\\n format.json { render json: @wait_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @meal_time = MealTime.new(params[:meal_time])\\n\\n respond_to do |format|\\n if @meal_time.save\\n format.html { redirect_to @meal_time, notice: 'Meal time was successfully created.' }\\n format.json { render json: @meal_time, status: :created, location: @meal_time }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @meal_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @time_registration = TimeRegistration.create(time_registration_params)\\n respond_to do |format|\\n if @time_registration.save\\n format.json { render :show, status: :created, location: @time_registration }\\n else\\n format.json { render json: @time_registration.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @time_of_day = TimeOfDay.new(time_of_day_params)\\n\\n respond_to do |format|\\n if @time_of_day.save\\n format.html { redirect_to @time_of_day, notice: 'Time of day was successfully created.' }\\n format.json { render :show, status: :created, location: @time_of_day }\\n else\\n format.html { render :new }\\n format.json { render json: @time_of_day.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @downtime = Downtime.new(downtime_params)\\n\\n respond_to do |format|\\n if @downtime.save\\n format.html { redirect_to @downtime, notice: 'Downtime was successfully created.' }\\n format.json { render action: 'show', status: :created, location: @downtime }\\n else\\n format.html { render action: 'new' }\\n format.json { render json: @downtime.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @meeting_time = MeetingTime.new(meeting_time_params)\\n\\n respond_to do |format|\\n if @meeting_time.save\\n format.html { redirect_to @meeting_time, notice: 'Meeting time was successfully created.' }\\n format.json { render action: 'show', status: :created, location: @meeting_time }\\n else\\n format.html { render action: 'new' }\\n format.json { render json: @meeting_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def postEntityOpening_times( entity_id, monday, tuesday, wednesday, thursday, friday, saturday, sunday, closed, closed_public_holidays)\\n params = Hash.new\\n params['entity_id'] = entity_id\\n params['monday'] = monday\\n params['tuesday'] = tuesday\\n params['wednesday'] = wednesday\\n params['thursday'] = thursday\\n params['friday'] = friday\\n params['saturday'] = saturday\\n params['sunday'] = sunday\\n params['closed'] = closed\\n params['closed_public_holidays'] = closed_public_holidays\\n return doCurl(\\\"post\\\",\\\"/entity/opening_times\\\",params)\\n end\",\n \"def stay_night_params\\n params.require(:stay_night).permit(:today, :city_id, :hotel_id, :rate, :comment)\\n end\",\n \"def create\\n @nursing_time = NursingTime.new(params[:nursing_time])\\n\\n respond_to do |format|\\n if @nursing_time.save\\n format.html { redirect_to @nursing_time, notice: 'Nursing time was successfully created.' }\\n format.json { render json: @nursing_time, status: :created, location: @nursing_time }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @nursing_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @time_slot = TimeSlot.new(time_slot_params)\\n\\n if @time_slot.save\\n render :show, status: :created, location: @time_slot\\n else\\n render json: @time_slot.errors, status: :unprocessable_entity\\n end\\n end\",\n \"def create\\n @timing = Timing.new(timing_params)\\n\\n if @timing.save\\n render :show, status: :created, location: @timing\\n else\\n render json: @timing.errors, status: :unprocessable_entity\\n end\\n end\",\n \"def create\\n @punchtime = current_user.punchtimes.build(punchtime_params)\\n respond_to do |format|\\n if @punchtime.save\\n format.html { redirect_to( current_user, notice: 'Punchtime was successfully created.') }\\n format.json { render :show, status: :created, location: @punchtime }\\n else\\n format.html { render :new }\\n format.json { render json: @punchtime.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @time_slot = TimeSlot.new(params[:time_slot])\\n @time_slot.user_id = current_identity.user_id\\n\\t@recurrence_array = []\\n respond_to do |format|\\n if @time_slot.save\\n format.html { redirect_to @time_slot, notice: 'Time slot was successfully created.' }\\n format.json { render json: @time_slot, status: :created, location: @time_slot }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @time_slot.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def stime_params\\n params.require(:stime).permit(:time, :meet_id, :swimmer_id, :stroke_id)\\n end\",\n \"def create\\n @work_order_time = WorkOrderTime.new(work_order_time_params)\\n\\n respond_to do |format|\\n if @work_order_time.save\\n format.html { redirect_to @work_order_time, notice: 'Work order time was successfully created.' }\\n format.json { render :show, status: :created, location: @work_order_time }\\n else\\n format.html { render :new }\\n format.json { render json: @work_order_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @service_time = ServiceTime.new(params[:service_time])\\n\\n respond_to do |format|\\n if @service_time.save\\n format.html { redirect_to @service_time, notice: 'Service time was successfully created.' }\\n format.json { render json: @service_time, status: :created, location: @service_time }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @service_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @timeslot = Timeslot.new(timeslot_params)\\n\\n if @timeslot.save\\n render :show, status: :created, location: @timeslot\\n else\\n render json: @timeslot.errors, status: :unprocessable_entity\\n end\\n end\",\n \"def create\\n @my_time_trial = MyTimeTrial.new(params[:my_time_trial])\\n\\n respond_to do |format|\\n if @my_time_trial.save\\n format.html { redirect_to @my_time_trial, :notice => 'My time trial was successfully created.' }\\n format.json { render :json => @my_time_trial, :status => :created, :location => @my_time_trial }\\n else\\n format.html { render :action => \\\"new\\\" }\\n format.json { render :json => @my_time_trial.errors, :status => :unprocessable_entity }\\n end\\n end\\n end\",\n \"def maketime\\n\\n openingtime = OpeningTime.new do |u|\\n u.day = params[:opening_times][:day]\\n u.from = \\\"9:00\\\"\\n u.to = \\\"12 Noon\\\"\\n u.on = true\\n u.position = params[:opening_times][:position]\\n \\n \\n end\\n openingtime.save\\n redirect_to \\\"/\\\"\\n end\",\n \"def create\\n @time_slot = TimeSlot.create(time_slot_params)\\n\\n respond_to do |format|\\n if @time_slot.save\\n format.html { redirect_to @time_slot, notice: 'Time slot was successfully created.' }\\n format.json { render :show, status: :created, location: @time_slot }\\n else\\n format.html { render :new }\\n format.json { render json: @time_slot.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def new\\n @time_gap = TimeGap.new\\n\\n respond_to do |format|\\n format.html # new.html.erb\\n format.json { render json: @time_gap }\\n end\\n end\",\n \"def create\\n @tombstone_timehold = TombstoneTimehold.new(tombstone_timehold_params)\\n\\n respond_to do |format|\\n if @tombstone_timehold.save\\n format.html { redirect_to @tombstone_timehold, notice: 'Tombstone timehold was successfully created.' }\\n format.json { render :show, status: :created, location: @tombstone_timehold }\\n else\\n format.html { render :new }\\n format.json { render json: @tombstone_timehold.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @p_time = PTime.new(p_time_params)\\n\\n respond_to do |format|\\n if @p_time.save\\n format.html { redirect_to @p_time, notice: 'P time was successfully created.' }\\n format.json { render :show, status: :created, location: @p_time }\\n else\\n format.html { render :new }\\n format.json { render json: @p_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @time_clock = TimeClock.new(time_clock_params)\\n\\n respond_to do |format|\\n if @time_clock.save\\n format.html { redirect_to time_sheet_index_path(@time_clock), notice: 'Time clock entry was successfully created.' }\\n format.json { render action: 'show', status: :created, location: @time_clock }\\n else\\n format.html { render action: 'new' }\\n format.json { render json: @time_clock.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @ride = Ride.new(ride_params)\\n @ride.assembly_time = params[:ride][:assembly_time]\\n @ride.destination_time = params[:ride][:destination_time]\\n @ride.check_points = params[:ride][:check_points]\\n if @ride.save\\n @ride.delay.call_notification(I18n.t('Notification.ride_created'), I18n.t('Email.ride_created'))\\n render json: @ride, status: :created\\n else\\n render json: @ride.errors, status: :unprocessable_entity\\n end\\n end\",\n \"def create\\n @schedule = Schedule.new(params[:schedule])\\n times =[]\\n count_days = 0\\n days = params[:day].join(\\\", \\\") if params[:day]\\n (0..6).each do |i|\\n if params[:hour][i].present? && params[:minute][i].present?\\n times<< \\\"#{params[:hour][i]}:#{ params[:minute][i]}\\\"\\n end\\n end\\n\\n count_days = params[:day].count if params[:day]\\n count_times = times.count\\n\\n if count_days == count_times\\n\\n if count_days && count_times != 0\\n times = times.join(\\\", \\\")\\n @schedule.day = days\\n @schedule.time = times\\n end\\n respond_to do |format|\\n if @schedule.save\\n format.html { redirect_to @schedule, notice: 'Schedule was successfully created.' }\\n format.json { render json: @schedule, status: :created, location: @schedule }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @schedule.errors, status: :unprocessable_entity }\\n end\\n end\\n\\n else\\n #redirect_to new_schedule_path, notice: \\\"даныне введены некорректно (день-время)\\\"\\n render action: \\\"new\\\"\\n end\\n end\",\n \"def create\\n @day_timeslot = DayTimeslot.new(day_timeslot_params)\\n\\n respond_to do |format|\\n if @day_timeslot.save\\n format.html { redirect_to @day_timeslot, notice: 'Day timeslot was successfully created.' }\\n format.json { render action: 'show', status: :created, location: @day_timeslot }\\n else\\n format.html { render action: 'new' }\\n format.json { render json: @day_timeslot.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @planned_time = PlannedTime.new(params[:planned_time])\\n\\n respond_to do |format|\\n if @planned_time.save\\n format.html { redirect_to @planned_time, notice: 'Planned time was successfully created.' }\\n format.json { render json: @planned_time, status: :created, location: @planned_time }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @planned_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @timeslot = Timeslot.new(timeslot_params)\\n @current_faculty = Faculty.where(email: current_user.email).first\\n @timeslot.faculty_id = @current_faculty.id\\n @timeslot.title = \\\"Timeslot Available for #{@current_faculty.full_name}\\\"\\n @timeslot.end = (@timeslot.start.to_time + 1.hours).to_datetime\\n @timeslot.save\\n\\n respond_to do |format|\\n if @timeslot.save\\n format.json {render :json => @timeslot}\\n else\\n format.json {render :status => 400}\\n end\\n end\\n end\",\n \"def create\\n @time_entry = TimeEntry.new(time_entry_params)\\n\\n respond_to do |format|\\n if @time_entry.save\\n format.html { redirect_to @time_entry, notice: 'Time entry was successfully created.' }\\n format.json { render :show, status: :created, location: @time_entry }\\n else\\n format.html { render :new }\\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def index\\n @time_entry ||= current_user.time_entries.build(\\n :tdate => Date.today\\n )\\n \\n @time_entries = current_firm.all_time_entries\\n\\n respond_to do |format|\\n format.html { render :index }# index.html.erb\\n format.json { render json: @time_entries }\\n end\\n end\",\n \"def create\\n @timetable = Timetable.new(params[:timetable])\\n\\n respond_to do |format|\\n if @timetable.save\\n format.html { redirect_to @timetable, notice: 'Timetable was successfully created.' }\\n format.json { render json: @timetable, status: :created, location: @timetable }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @timetable.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @time_entry = TimeEntry.new(params[:time_entry])\\n\\n respond_to do |format|\\n if @time_entry.save\\n format.html { redirect_to @time_entry, notice: 'Time entry was successfully created.' }\\n format.json { render json: @time_entry, status: :created, location: @time_entry }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @time_entry = TimeEntry.new(params[:time_entry])\\n\\n respond_to do |format|\\n if @time_entry.save\\n format.html { redirect_to @time_entry, notice: 'Time entry was successfully created.' }\\n format.json { render json: @time_entry, status: :created, location: @time_entry }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @time_entry = TimeEntry.new(params[:time_entry])\\n\\n respond_to do |format|\\n if @time_entry.save\\n format.html { redirect_to @time_entry, notice: 'Time entry was successfully created.' }\\n format.json { render json: @time_entry, status: :created, location: @time_entry }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @timer = Timer.new(timer_params)\\n\\n if @timer.save\\n render json: @timer, status: :created, location: @timer\\n else\\n render json: @timer.errors, status: :unprocessable_entity\\n end\\n end\",\n \"def new\\n @patient = Patient.find(params[:patient_id])\\n current_schedule = @patient.current_schedule\\n if current_schedule\\n current_schedule.terminated_at = Date.today\\n current_schedule.save\\n end\\n @schedule = @patient.schedules.build\\n @pill_times = [@schedule.pill_times.build]\\n respond_to do |format|\\n format.html # new.html.erb\\n format.json { render json: @schedule }\\n end\\n end\",\n \"def destroy\\n @stay_time.destroy\\n respond_to do |format|\\n format.html { redirect_to stay_times_url, notice: 'Stay time was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def create\\n @session_time = SessionTime.new(session_time_params)\\n\\n respond_to do |format|\\n if @session_time.save\\n format.html { redirect_to @session_time, notice: 'Session time was successfully created.' }\\n format.json { render :show, status: :created, location: @session_time }\\n else\\n format.html { render :new }\\n format.json { render json: @session_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n\\n \\t\\t\\t@teetime = Teetime.new teetime_params\\n\\n \\t\\t\\tif @teetime.save\\n\\n \\t\\t\\t\\trender json: @teetime,status: :created\\n\\n \\t\\t\\telse\\n\\n \\t\\t\\t\\trender json: {error: true,errors: @teetime.errors},status: :unprocessable_entity\\n\\n \\t\\t\\tend\\n\\n \\t\\tend\",\n \"def create\\n @location_time = LocationTime.new(location_time_params)\\n\\n respond_to do |format|\\n if @location_time.save\\n format.html { redirect_to @location_time, notice: 'Location time was successfully created.' }\\n format.json { render action: 'show', status: :created, location: @location_time }\\n else\\n format.html { render action: 'new' }\\n format.json { render json: @location_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @poi_time = PoiTime.new(poi_time_params)\\n\\n respond_to do |format|\\n if @poi_time.save\\n format.html { redirect_to @poi_time, notice: 'Poi time was successfully created.' }\\n format.json { render :show, status: :created, location: @poi_time }\\n else\\n format.html { render :new }\\n format.json { render json: @poi_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @time_record = WorkTimeRecord.new(time_record_params)\\n\\n respond_to do |format|\\n if @time_record.save\\n format.html { redirect_to @time_record, notice: 'Time record was successfully created.' }\\n format.json { render :show, status: :created, location: @time_record }\\n else\\n format.html { render :new }\\n format.json { render json: @time_record.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @timed_task = TimedTask.new(timed_task_params)\\n\\n respond_to do |format|\\n if @timed_task.save\\n format.html { redirect_to @timed_task, notice: 'Timed task was successfully created.' }\\n format.json { render :show, status: :created, location: @timed_task }\\n else\\n format.html { render :new }\\n format.json { render json: @timed_task.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @timeslot = current_event.timeslots.new(params[:timeslot])\\n \\n respond_to do |format|\\n if @timeslot.save\\n flash[:notice] = 'Timeslot was successfully created.'\\n format.html { redirect_to(timeslots_url) }\\n format.xml { render :xml => @timeslot, :status => :created, :location => @timeslot }\\n else\\n format.html { render :action => \\\"new\\\" }\\n format.xml { render :xml => @timeslot.errors, :status => :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n \\n #timestamp={{FellAsleepAt}}&total_sleep={{TotalTimeSleptInSeconds}}&deep={{TimeInDeepSleepSeconds}}&light={{TimeInLightSleepSeconds}}&awake={{TimeAwakeSeconds}}\\n \\n json_hash = Hash.new\\n \\n description = params[:description]\\n \\n timestamp = params[:timestamp]\\n total_sleep_seconds = params[:total_sleep]\\n deep_sleep_seconds = params[:deep]\\n light_sleep_seconds = params[:light]\\n awake_seconds = params[:awake]\\n \\n if timestamp.nil? || total_sleep_seconds.nil?\\n \\n puts 'timestamp is nil or total_sleep_seconds is nil :('\\n \\n else\\n \\n total_sleep = total_sleep_seconds / 60.0\\n deep = deep_sleep_seconds / 60.0\\n light = light_sleep_seconds / 60.0\\n awake = awake_seconds / 60.0\\n \\n post_to_twitter = false\\n post_to_facebook = false\\n \\n # FellAsleepAt is formatted: August 23, 2013 at 11:01PM\\n # Convert to Runkeeper's preferred format: Sat, 1 Jan 2011 00:00:00\\n timestamp_datetime = DateTime.parse(timestamp)\\n formatted_timestamp = timestamp_datetime.strftime(\\\"%a, %d %b %Y %H:%M:%S\\\")\\n \\n json_hash['timestamp'] = formatted_timestamp\\n json_hash['total_sleep'] = deep\\n json_hash['deep'] = deep\\n json_hash['light'] = light\\n json_hash['awake'] = awake\\n json_hash['post_to_twitter'] = post_to_twitter\\n json_hash['post_to_facebook'] = post_to_facebook\\n \\n url = 'https://api.runkeeper.com/sleep'\\n \\n uri = URI.parse(url)\\n \\n http = Net::HTTP.new(uri.host, uri.port)\\n http.use_ssl = true\\n request = Net::HTTP::Post.new(uri.request_uri)\\n request[\\\"Authorization\\\"] = \\\"Bearer \\\" + RUNKEEPER_ACCESS_TOKEN\\n request[\\\"Content-Type\\\"] = \\\"application/vnd.com.runkeeper.NewSleep+json\\\"\\n request.body = json_hash.to_json\\n \\n response = http.request(request)\\n \\n puts response.body\\n \\n end\\n \\n @sleep = json_hash\\n \\n respond_to do |format|\\n format.html # new.html.erb\\n format.json { render json: @sleep }\\n end\\n \\n end\",\n \"def wait_time_params\\n params.require(:wait_time).permit(:restaurant_id, :party_size, :minutes, :checked_at)\\n end\",\n \"def trip_params\\n params.require(:trip).permit(:starts_on, :ends_on, :name, :location, {:item_ids => []})\\n end\",\n \"def create\\n @time_record = TimeRecord.new(params[:time_record])\\n @time_record.value = (@time_record.ended_at - @time_record.started_at) / 1.hour\\n @time_record.recorded_on = @time_record.started_at.to_date\\n\\n respond_to do |format|\\n if @time_record.save\\n format.html { redirect_to time_records_path, notice: 'Time record was successfully created.' }\\n format.json { render json: @time_record.to_json, status: :created, location: @time_record }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @time_record.errors.full_messages, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def times_game_params\\n params.require(:times_game).permit(:point, :sta)\\n end\",\n \"def tombstone_timehold_params\\n params.require(:tombstone_timehold).permit(:tombstoneJSON, :permanent, :rating)\\n end\",\n \"def create\\n @planning_time = PlanningTime.new(params[:planning_time])\\n\\n respond_to do |format|\\n if @planning_time.save\\n format.html { redirect_to @planning_time, notice: 'Planning time was successfully created.' }\\n format.json { render json: @planning_time, status: :created, location: @planning_time }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @planning_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n attendance_params[:checkin] = attendance_params[:checkin].to_time\\n attendance_params[:checkout] = attendance_params[:checkout].to_time\\n attendance_params[:attendance_date] = attendance_params[:attendance_date].to_date\\n\\n r = @api.create_attendance(attendance_params)\\n respond_to do |format|\\n if r.code == 201\\n format.html { redirect_to attendances_url, notice: 'Attendance was successfully created.' }\\n else\\n response = JSON.parse(r.body)\\n format.html { redirect_to attendances_url, alert: response['message']}\\n end\\n end\\n end\",\n \"def create\\n @timetable = Timetable.new(timetable_params)\\n\\n respond_to do |format|\\n if @timetable.save\\n format.html { redirect_to request.referer, notice: 'Timetable was successfully created.' }\\n format.json { render :show, status: :created, location: @timetable }\\n else\\n format.html { render :new }\\n format.json { render json: @timetable.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @working_start_time = WorkingStartTime.new(working_start_time_params)\\n\\n respond_to do |format|\\n if @working_start_time.save\\n format.html { redirect_to @working_start_time, notice: 'Working start time was successfully created.' }\\n format.json { render action: 'show', status: :created, location: @working_start_time }\\n else\\n format.html { render action: 'new' }\\n format.json { render json: @working_start_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create_day\\n trip = Trip.find(params[:id])\\n offset = 0\\n trip.days.all.each do |day|\\n offset += 1\\n end\\n @day = Day.new({\\\"date\\\" => trip.beginning + offset , \\\"trip\\\" => trip})\\n trip.update_attribute(:duration, trip.attributes['duration'] + 1)\\n trip.save\\n respond_to do |format|\\n if @day.save\\n format.html { redirect_to trip, notice: 'Day was successfully created.' }\\n format.json { render :show, status: :created, location: @day }\\n else\\n format.html { render home_path }\\n format.json { render json: @day.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @appointment = Appointment.new(appointment_params)\\n if @appointment.starts_at != nil\\n @appointment.ends_at = @appointment.starts_at + 30.minutes\\n end\\n respond_to do |format|\\n if @appointment.save\\n format.html { redirect_to new_appointment_path, notice: 'Agendamento realizado.' }\\n format.json { render :show, status: :created, location: @appointment }\\n else\\n format.html { render :schedule }\\n format.json { render json: @appointment.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @order_break_time = OrderBreakTime.new(order_break_time_params)\\n\\n respond_to do |format|\\n if @order_break_time.save\\n format.html { redirect_to @order_break_time, notice: 'Order break time was successfully created.' }\\n format.json { render 'show', status: :created, location: @order_break_time }\\n else\\n format.html { render 'new' }\\n format.json { render json: @order_break_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @hotel_stay = HotelStay.new(params[:hotel_stay])\\n\\n respond_to do |format|\\n if @hotel_stay.save\\n format.html { redirect_to @hotel_stay, notice: 'Hotel stay was successfully created.' }\\n format.json { render json: @hotel_stay, status: :created, location: @hotel_stay }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @hotel_stay.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def timecontroll_params\\n params.require(:timecontroll).permit(:start, :end, :gap)\\n end\",\n \"def create\\n @daytime = Daytime.new(params[:daytime])\\n\\n respond_to do |format|\\n if @daytime.save\\n format.html { redirect_to @daytime, notice: 'Daytime was successfully created.' }\\n format.json { render json: @daytime, status: :created, location: @daytime }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @daytime.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @transaction = Transaction.new(transaction_params)\\n @transaction.update(user_id: session[:user_id])\\n @transaction.update(status: 'Scheduled')\\n\\n @timingsList = []\\n @datesList = []\\n @timings = Timing.find_by_sql(\\\"SELECT day, hours, minutes, ampm FROM timings\\\")\\n @timings.each do |timing|\\n timing.day = date_of_next(timing.day).strftime(\\\"%d %b %Y\\\") + \\\" - \\\" + timing.hours + \\\":\\\" + timing.minutes + \\\" \\\" + timing.ampm\\n @timingsList.push([timing.day, timing.day])\\n end\\n for i in 0..9\\n @datesList.push([(Date.today+i).strftime(\\\"%d %b %Y\\\"), (Date.today+i).strftime(\\\"%d %b %Y\\\")])\\n end\\n\\n respond_to do |format|\\n if @transaction.save\\n format.html { redirect_to transactions_path, notice: 'Transaction was successfully created.' }\\n format.json { render :show, status: :created, location: @transaction }\\n else\\n format.html { render :new }\\n format.json { render json: @transaction.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @drop_route_start_time = DropRouteStartTime.new(drop_route_start_time_params)\\n\\n respond_to do |format|\\n if @drop_route_start_time.save\\n format.html { redirect_to drop_route_start_times_path, notice: 'Drop route start time was successfully created.' }\\n format.json { render :show, status: :created, location: @drop_route_start_time }\\n else\\n format.html { render :new }\\n format.json { render json: @drop_route_start_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @trip_schedule = TripSchedule.new(trip_schedule_params)\\n\\n respond_to do |format|\\n if @trip_schedule.save\\n format.html { redirect_to @trip_schedule, notice: 'Trip schedule was successfully created.' }\\n format.json { render :show, status: :created, location: @trip_schedule }\\n else\\n format.html { render :new }\\n format.json { render json: @trip_schedule.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n if params[:pay_day] && params[:start_day] && params[:end_day]\\n ::TimeEntry.where(pay_day: params[:pay_day]).update_all(pay_day: nil)\\n ::TimeEntry.where(\\\"day>=? AND day<=?\\\",params[:start_day],params[:end_day]).update_all(pay_day: params[:pay_day])\\n end\\n redirect_to \\\"/time/#{params[:start_day]}\\\"\\n end\",\n \"def create\\n @user = User.find(params[:user_id])\\n @clock_time = @user.clock_times.new(params[:clock_time])\\n\\n time_in_to_update = get_time_to_update(params[\\\"use_current\\\"], params[:clock_time], \\\"in\\\")\\n\\n\\n @clock_time.in = time_in_to_update\\n\\n respond_to do |format|\\n if @clock_time.save\\n format.html { redirect_to @user, notice: 'You have successfully clocked in' }\\n format.json { render json: @clock_time, status: :created, location: @clock_time }\\n format.js\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @clock_time.errors, status: :unprocessable_entity }\\n format.js\\n end\\n end\\n end\",\n \"def transit_times(shipment, options:, debug: false)\\n request = FriendlyShipping::Request.new(\\n url: API_BASE + API_PATHS[:transit_times],\\n http_method: \\\"POST\\\",\\n body: SerializeTransitTimesRequest.call(shipment: shipment, options: options).to_json,\\n headers: request_headers,\\n debug: debug\\n )\\n client.post(request).bind do |response|\\n ParseTransitTimesResponse.call(request: request, response: response)\\n end\\n end\",\n \"def create\\n @disatance_and_time = DisatanceAndTime.new(disatance_and_time_params)\\n\\n respond_to do |format|\\n if @disatance_and_time.save\\n format.html { redirect_to @disatance_and_time, notice: 'Disatance and time was successfully created.' }\\n format.json { render :show, status: :created, location: @disatance_and_time }\\n else\\n format.html { render :new }\\n format.json { render json: @disatance_and_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @selected_time = SelectedTime.new(selected_time_params)\\n\\n respond_to do |format|\\n if @selected_time.save\\n format.html { redirect_to @selected_time, notice: 'Selected time was successfully created.' }\\n format.json { render :show, status: :created, location: @selected_time }\\n else\\n format.html { render :new }\\n format.json { render json: @selected_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @start_time = params[:start_time].to_datetime.strftime(\\\"%Y-%m-%d %H:%M:%S\\\")\\n @end_time = params[:end_time].to_datetime.strftime(\\\"%Y-%m-%d %H:%M:%S\\\")\\n @service = params[:service_item_id]\\n\\n @hours = params[:hours]\\n @minutes = params[:minutes]\\n @seconds = params[:seconds]\\n\\n @quantity = @hours.to_s+':'+@minutes.to_s+':'+@seconds.to_s\\n \\n @jobtime = Jobtime.new(:start_time => @start_time, :end_time => @end_time,:qty => @quantity,:company_id => current_login.id,:job_id => params[:job_id],:jobsite_id => params[:jobsite_id],:customer_id => params[:customer_id],:user => current_login.name, :timetype => \\\"Actual Time\\\", :service => @service)\\n \\n if @jobtime.save(:validate => false)\\n response_message = {:message => \\\"Jobtime successfully created.\\\", :jobtime => @jobtime}\\n else\\n response_message = {:message => \\\"Jobtime creation failed. Please try again.\\\"} \\n end\\n \\n respond_to do |format|\\n format.xml { render :xml => response_message }\\n format.json { render :json => response_message }\\n end\\n end\",\n \"def jobtime_shedule\\n @jobtime = Jobtime.new(params[:jobtime])\\n\\n @qty = @jobtime.qty.to_i.hours\\n @item = Item.find(@jobtime.service)\\n\\n #calculate end_time\\n @jobtime.end_time = @jobtime.start_time+@qty\\n\\n #calculate cost\\n @jobtime.cost = @item.unit_cost * @qty\\n\\n #calculate price\\n if(@jobtime.billable.present?)\\n @jobtime.price = @item.unit_price * @qty\\n else\\n @jobtime.price = 0\\n end\\n puts @jobtime.errors.inspect\\n if @jobtime.save\\n response_message = {:message => \\\"Time was scheduled successfully.\\\",:jobtime => @jobtime }\\n else\\n response_message = {:message => \\\"Please try again.\\\"}\\n end\\n respond_to do |format|\\n format.xml{render :xml => response_message }\\n format.json{render :json => response_message }\\n end\\n end\",\n \"def new\\n @travel_datum = TravelDatum.new\\n @travel_datum.start_time = Time.now.beginning_of_day + 9.hours\\n @travel_datum.end_of_business_time = Time.now.beginning_of_day+17.hours\\n\\n respond_to do |format|\\n format.html # new.html.erb\\n format.json { render :json => @travel_datum }\\n format.xml { render :xml => @travel_data }\\n end\\n end\",\n \"def create\\n @trip = Trip.new(trip_params)\\n @trip.session_id = session.id\\n @trip.user_id = current_user.id\\n\\n respond_to do |format|\\n if @trip.save\\n format.html { redirect_to @trip.parent || @trip, notice: 'Trip was successfully created.', change: 'list' }\\n format.json { render action: 'show', status: :created, location: @trip, day: 1 }\\n else\\n format.html { render action: 'new' }\\n format.json { render json: @trip.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @receiver_time = ReceiverTime.new(params[:receiver_time])\\n\\n respond_to do |format|\\n if @receiver_time.save\\n format.html { redirect_to @receiver_time, notice: 'Receiver time was successfully created.' }\\n format.json { render json: @receiver_time, status: :created, location: @receiver_time }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @receiver_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def lession_time_params\\n params.require(:lession_time).permit(:day, :start_at, :end_at)\\n end\",\n \"def outing_params\\n params.require(:outing).permit(:day, :location_id, :time)\\n end\",\n \"def create\\n @time_table = TimeTable.new(time_table_params)\\n \\n session.delete(:return_to)\\n session[:return_to] ||= request.referer\\n\\n respond_to do |format|\\n if @time_table.save\\n format.html { redirect_to session.delete(:return_to), notice: 'Time table was successfully created.' }\\n format.json { render :show, status: :created, location: @time_table }\\n else\\n format.html { render :new }\\n format.json { render json: @time_table.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n @time_treinador = TimeTreinador.new(time_treinador_params)\\n @time_treinador.treinador = @treinador\\n\\n respond_to do |format|\\n if @time_treinador.save\\n format.html { redirect_to @time_treinador, notice: 'Time criado com sucesso' }\\n format.json { render :show, status: :created, location: @time_treinador }\\n else\\n format.html { render :new }\\n format.json { render json: @time_treinador.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create\\n set_user\\n @time_off = TimeOff.new(time_off_params)\\n\\n respond_to do |format|\\n if @time_off.save\\n format.html { redirect_to user_time_off_path(@user, @time_off), notice: 'Time off was successfully created.' }\\n format.json { render action: 'show', status: :created, location: @time_off }\\n else\\n format.html { render action: 'new' }\\n format.json { render json: @time_off.errors, status: :unprocessable_entity }\\n end\\n end\\n end\"\n]"},"negative_scores":{"kind":"list like","value":["0.6601063","0.6519595","0.62858284","0.6268728","0.6266317","0.62011385","0.617307","0.6168958","0.6111555","0.60858476","0.60694796","0.6050281","0.6019576","0.60107577","0.5925939","0.5908032","0.5900547","0.58972186","0.5892104","0.5891286","0.5875553","0.58427113","0.5817103","0.58074206","0.58049953","0.5779078","0.57777137","0.57768315","0.5767359","0.57642305","0.5756684","0.57406586","0.57384115","0.5732428","0.5726115","0.5713898","0.5711512","0.57095164","0.5705558","0.57006735","0.56968296","0.56876373","0.5687127","0.566431","0.565074","0.5646809","0.56417114","0.56376374","0.56353974","0.56348974","0.5634356","0.5629803","0.5618873","0.5614667","0.5614667","0.5614667","0.56078017","0.56063914","0.5604064","0.56030947","0.5594199","0.558876","0.5588386","0.5579173","0.55713063","0.5569495","0.5562344","0.5560884","0.55590624","0.5551713","0.55497605","0.5541079","0.55365926","0.5536257","0.5529784","0.5516563","0.5511722","0.5510665","0.5502391","0.5500826","0.54958165","0.5480089","0.54735965","0.5468077","0.5463031","0.5461822","0.5457979","0.5455413","0.54534596","0.54481894","0.5439358","0.5428978","0.5424497","0.541937","0.5417964","0.541616","0.5415978","0.5411887","0.54117924","0.5410409"],"string":"[\n \"0.6601063\",\n \"0.6519595\",\n \"0.62858284\",\n \"0.6268728\",\n \"0.6266317\",\n \"0.62011385\",\n \"0.617307\",\n \"0.6168958\",\n \"0.6111555\",\n \"0.60858476\",\n \"0.60694796\",\n \"0.6050281\",\n \"0.6019576\",\n \"0.60107577\",\n \"0.5925939\",\n \"0.5908032\",\n \"0.5900547\",\n \"0.58972186\",\n \"0.5892104\",\n \"0.5891286\",\n \"0.5875553\",\n \"0.58427113\",\n \"0.5817103\",\n \"0.58074206\",\n \"0.58049953\",\n \"0.5779078\",\n \"0.57777137\",\n \"0.57768315\",\n \"0.5767359\",\n \"0.57642305\",\n \"0.5756684\",\n \"0.57406586\",\n \"0.57384115\",\n \"0.5732428\",\n \"0.5726115\",\n \"0.5713898\",\n \"0.5711512\",\n \"0.57095164\",\n \"0.5705558\",\n \"0.57006735\",\n \"0.56968296\",\n \"0.56876373\",\n \"0.5687127\",\n \"0.566431\",\n \"0.565074\",\n \"0.5646809\",\n \"0.56417114\",\n \"0.56376374\",\n \"0.56353974\",\n \"0.56348974\",\n \"0.5634356\",\n \"0.5629803\",\n \"0.5618873\",\n \"0.5614667\",\n \"0.5614667\",\n \"0.5614667\",\n \"0.56078017\",\n \"0.56063914\",\n \"0.5604064\",\n \"0.56030947\",\n \"0.5594199\",\n \"0.558876\",\n \"0.5588386\",\n \"0.5579173\",\n \"0.55713063\",\n \"0.5569495\",\n \"0.5562344\",\n \"0.5560884\",\n \"0.55590624\",\n \"0.5551713\",\n \"0.55497605\",\n \"0.5541079\",\n \"0.55365926\",\n \"0.5536257\",\n \"0.5529784\",\n \"0.5516563\",\n \"0.5511722\",\n \"0.5510665\",\n \"0.5502391\",\n \"0.5500826\",\n \"0.54958165\",\n \"0.5480089\",\n \"0.54735965\",\n \"0.5468077\",\n \"0.5463031\",\n \"0.5461822\",\n \"0.5457979\",\n \"0.5455413\",\n \"0.54534596\",\n \"0.54481894\",\n \"0.5439358\",\n \"0.5428978\",\n \"0.5424497\",\n \"0.541937\",\n \"0.5417964\",\n \"0.541616\",\n \"0.5415978\",\n \"0.5411887\",\n \"0.54117924\",\n \"0.5410409\"\n]"},"document_score":{"kind":"string","value":"0.7005587"},"document_rank":{"kind":"string","value":"0"}}},{"rowIdx":128,"cells":{"query":{"kind":"string","value":"PATCH/PUT /stay_times/1 PATCH/PUT /stay_times/1.json"},"document":{"kind":"string","value":"def update\n respond_to do |format|\n if @stay_time.update(stay_time_params)\n format.html { redirect_to @stay_time, notice: 'Stay time was successfully updated.' }\n format.json { render :show, status: :ok, location: @stay_time }\n else\n format.html { render :edit }\n format.json { render json: @stay_time.errors, status: :unprocessable_entity }\n end\n end\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def update\n @patient = Patient.find(params[:patient_id])\n @schedule = @patient.schedules.find(params[:id])\n @pill_times = @schedule.pill_times\n\n # TODO can improve it to use nested attributes\n if params[:pill_time]\n params[:pill_time].each_with_index do |pill_time, idx|\n if @pill_times[idx]\n @pill_times[idx].update_attributes(pill_time)\n else\n @pill_times.create(pill_time)\n end\n end\n end\n\n # remove unused pill times\n if params[:pill_time]\n diff = @pill_times.size - params[:pill_time].size\n @pill_times.destroy(@pill_times.last(diff)) if diff > 0\n end\n\n respond_to do |format|\n if @schedule.update_attributes(params[:schedule])\n format.html { redirect_to [@patient, @schedule],\n notice: 'Schedule was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @schedule.errors,\n status: :unprocessable_entity }\n end\n end\n end","def update\n @time_gap = TimeGap.find(params[:id])\n\n respond_to do |format|\n if @time_gap.update_attributes(params[:time_gap])\n format.html { redirect_to @time_gap, notice: 'Time gap was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @time_gap.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @timing = Timing.find(params[:id])\n if @timing.update_attributes(params[:timing].slice(:start, :stop, :days, :active))\n render json: @timing\n else\n render json: { error: 'error: could not update timing' }\n end\n end","def update\n @meal_time = MealTime.find(params[:id])\n\n respond_to do |format|\n if @meal_time.update_attributes(params[:meal_time])\n format.html { redirect_to @meal_time, notice: 'Meal time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meal_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @cooking_time.update(cooking_time_params)\n format.html { redirect_to cooking_times_path, notice: 'Cooking time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cooking_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @working_time = WorkingTime.find(params[:id])\n\n respond_to do |format|\n if @working_time.update_attributes(params[:working_time])\n format.html { redirect_to time_tables_path }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @working_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @task.update(task_params)\n @task.whenever_reset unless task_params[:every].blank? && task_params[:at].blank?\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @meeting_time.update(meeting_time_params)\n format.html { redirect_to @meeting_time, notice: 'Meeting time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @meeting_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @stime.update(stime_params)\n format.html { redirect_to @stime, notice: 'Stime was successfully updated.' }\n format.json { render :show, status: :ok, location: @stime }\n else\n format.html { render :edit }\n format.json { render json: @stime.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n params[:task][:time] = parse_task_time(params[:task][:time], params[:anytime][:anytime])\n \n respond_to do |format|\n if @task.update_attributes(params[:task])\n format.html { redirect_to(tasks_url, :notice => 'Task was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n end\n end\n end","def update\n @my_time_trial = MyTimeTrial.find(params[:id])\n\n respond_to do |format|\n if @my_time_trial.update_attributes(params[:my_time_trial])\n format.html { redirect_to @my_time_trial, :notice => 'My time trial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @my_time_trial.errors, :status => :unprocessable_entity }\n end\n end\n end","def update\n @wait_time = WaitTime.find(params[:id])\n\n respond_to do |format|\n if @wait_time.update_attributes(params[:wait_time])\n format.html { redirect_to @wait_time, notice: 'Wait time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @wait_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @time_off_request = TimeOffRequest.find(params[:id])\n respond_to do |format|\n if @time_off_request.update_attributes(params[:time_off_request])\n format.html { redirect_to admin_time_off_requests_url, notice: 'Time off request was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @time_off_request.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @time_clock.update(time_clock_params)\n format.html { redirect_to time_sheet_index_path(@time_clock), notice: 'Time clock entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @time_clock.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @service_time = ServiceTime.find(params[:id])\n\n respond_to do |format|\n if @service_time.update_attributes(params[:service_time])\n format.html { redirect_to @service_time, notice: 'Service time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @service_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n\n if @teetime.update(teetime_params)\n\n render json: @teetime,status: :ok\n\n else\n\n render json: {error: true,errors: @teetime.errors},status: :unprocessable_entity\n\n end\n\n \t\tend","def update\n @time_entry = current_firm.all_time_entries.find(params[:id])\n\n respond_to do |format|\n if @time_entry.update_attributes(params[:time_entry])\n format.html { redirect_to firm_time_entry_path(current_firm, @time_entry), notice: 'Time entry was successfully updated.' }\n format.json { head :ok }\n else\n format.html { index }\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n if @timeslot.update(timeslot_params)\n render :show, status: :ok, location: @timeslot\n else\n render json: @timeslot.errors, status: :unprocessable_entity\n end\n end","def update\n if @can_edit\n\n # Clear out all other blocks\n @timetable.free_times.destroy_all\n times = JSON::Parser.new(params[:times]).parse\n\n # There's an array for each day of the week\n times.each_with_index do |day, i|\n # Each day of the week then has a list of blocks\n day.each_with_index do |block, j|\n unless block.empty?\n # Each block has a start time and an end time for a free block\n @timetable.free_times.create(:start_time => block[0], :end_time => block[1], :day_of_week => i, :weight => block[2], :css_class => block[3])\n end\n end\n end\n\n @person ||= get_person\n @timetable.update_attributes(:updated_by_person_id => @my.id)\n @timetable.touch\n return if @signup\n\n flash[:notice] = I18n.t('timetable.save_confirm')\n\n elsif !@can_edit\n flash[:notice] = I18n.t('timetable.not_allowed_update')\n end\n\n respond_to do |format|\n format.html { redirect_to(person_timetable_path(@timetable.person, @timetable)) }\n format.js\n format.xml { head :ok }\n end\n end","def update\n respond_to do |format|\n if @time_slot.update(time_slot_params)\n format.html { redirect_to @time_slot, notice: 'Time slot was successfully updated.' }\n format.json { render :show, status: :ok, location: @time_slot }\n else\n format.html { render :edit }\n format.json { render json: @time_slot.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @one_time_stop = OneTimeStop.find(params[:id])\n\n respond_to do |format|\n if @one_time_stop.update_attributes(params[:one_time_stop])\n format.html { redirect_to @one_time_stop, notice: 'One time stop was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @one_time_stop.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @where_to_stay = WhereToStay.find(params[:id])\n\n respond_to do |format|\n if @where_to_stay.update_attributes(params[:where_to_stay])\n format.html { redirect_to @where_to_stay, notice: 'Where to stay was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @where_to_stay.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @timeslot = current_event.timeslots.find(params[:id])\n respond_to do |format|\n @timeslot.start_time_will_change!\n @timeslot.slot_date_will_change!\n if @timeslot.update_attributes(params[:timeslot])\n flash[:notice] = \"Timeslot was successfully updated.\"\n format.html { redirect_to(timeslots_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @timeslot.errors, :status => :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @downtime.update(downtime_params)\n format.html { redirect_to @downtime, notice: 'Downtime was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @downtime.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @poi_time.update(poi_time_params)\n format.html { redirect_to @poi_time, notice: 'Poi time was successfully updated.' }\n format.json { render :show, status: :ok, location: @poi_time }\n else\n format.html { render :edit }\n format.json { render json: @poi_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @timeslot.update(timeslot_params)\n format.html { redirect_to @timeslot, notice: 'Timeslot was successfully updated.' }\n format.json { render :show, status: :ok, location: @timeslot }\n else\n format.html { render :edit }\n format.json { render json: @timeslot.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @location_time.update(location_time_params)\n format.html { redirect_to @location_time, notice: 'Location time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @location_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n if @time_slot.update(time_slot_params)\n render :show, status: :ok, location: @time_slot\n else\n render json: @time_slot.errors, status: :unprocessable_entity\n end\n end","def update\n respond_to do |format|\n if @wait_time.update(wait_time_params)\n format.html { redirect_to @wait_time, notice: 'Wait time was successfully updated.' }\n format.json { render :show, status: :ok, location: @wait_time }\n else\n format.html { render :edit }\n format.json { render json: @wait_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @working_start_time.update(working_start_time_params)\n format.html { redirect_to @working_start_time, notice: 'Working start time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @working_start_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n # @job = @shift.job\n # @employee = @shift.employee\n # time = @shift.time_out || @shift.time_in\n # @shift.week = time.to_datetime\n\n respond_to do |format|\n if @shift.update(shift_params)\n format.html { redirect_to company_shift_path(@shift), notice: 'Shift was successfully updated.' }\n format.json { render :show, status: :ok, location: @shift }\n else\n format.html { render :edit }\n format.json { render json: @shift.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @stop_time = StopTime.find(params[:id])\n\n respond_to do |format|\n if @stop_time.update_attributes(params[:stop_time])\n format.html { redirect_to @stop_time, notice: 'Stop time was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stop_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @work_time.update(work_time_params)\n format.html { redirect_to @work_time, notice: 'Work time was successfully updated.' }\n format.json { render :show, status: :ok, location: @work_time }\n else\n format.html { render :edit }\n format.json { render json: @work_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @cal_time.update(cal_time_params)\n format.html { redirect_to @cal_time, notice: 'Cal time was successfully updated.' }\n format.json { render :show, status: :ok, location: @cal_time }\n else\n format.html { render :edit }\n format.json { render json: @cal_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @time_of_day.update(time_of_day_params)\n format.html { redirect_to @time_of_day, notice: 'Time of day was successfully updated.' }\n format.json { render :show, status: :ok, location: @time_of_day }\n else\n format.html { render :edit }\n format.json { render json: @time_of_day.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @time_punch.update(time_punch_params)\n format.html { redirect_to @time_punch, notice: 'Time punch was successfully updated.' }\n format.json { render :show, status: :ok, location: @time_punch }\n else\n format.html { render :edit }\n format.json { render json: @time_punch.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @site = Site.first\n @first_time = @site.first_time\n respond_to do |format|\n if @first_time.update(first_time_params)\n format.html { redirect_to backstage_index_path, notice: 'first_time was successfully updated.' }\n # format.json { render :show, status: :ok, location: @first_time }\n else\n format.html { render :edit }\n # format.json { render json: @first_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @time_trial.update(time_trial_params)\n format.html { redirect_to @time_trial, notice: 'Time trial was successfully updated.' }\n format.json { render :show, status: :ok, location: @time_trial }\n else\n format.html { render :edit }\n format.json { render json: @time_trial.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n if @timing.update(timing_params)\n render :show, status: :ok, location: @timing\n else\n render json: @timing.errors, status: :unprocessable_entity\n end\n end","def update\n @meeting = Meeting.find(params[:id])\n @meeting.meeting_time = params[:meeting][:meeting_time]\n respond_to do |format|\n if @meeting.update_attributes(params[:meeting])\n format.html { redirect_to club_meeting_path(params[:club_id],@meeting), notice: 'Meeting was successfully updated.' }\n format.json { head :ok }\n \n else\n format.html { render action: \"edit\" }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n \n end\n end\n end","def update\n @hurdle_time = HurdleTime.find(params[:id])\n\n time = (params[:time][:minutes].to_i * 60) + params[:time][:seconds].to_i\n if params[:hurdle_time]\n params[:hurdle_time].store :time, time\n else\n params[:hurdle_time] = {}.store :time, time\n end\n\n respond_to do |format|\n if @hurdle_time.update_attributes(params[:hurdle_time])\n format.html { redirect_to hurdle_match_hurdle_times_path(@hurdle_time.hurdle_match), notice: 'Hurdle time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hurdle_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @day_timeslot.update(day_timeslot_params)\n format.html { redirect_to @day_timeslot, notice: 'Day timeslot was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @day_timeslot.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n begin\n @appointment = Appointment.find(params[:id])\n rescue\n respond_info('error', 'internal_server_error', 'Update Appointment Failed', :internal_server_error)\n return\n end\n if @appointment.update(appointment_params)\n render :json => @appointments, :status => :no_content #HTTP status code: 204 No Content\n else\n render json: @appointment.errors, status: :unprocessable_entity\n end\n end","def update\n respond_to do |format|\n self.unuse_pto_hours\n if @time_off_instance.update(time_off_instance_params)\n self.use_pto_hours\n format.html { redirect_to @time_off_instance, notice: 'Time off instance was successfully updated.' }\n format.json { render :show, status: :ok, location: @time_off_instance }\n else\n format.html { render :edit }\n format.json { render json: @time_off_instance.errors, status: :unprocessable_entity }\n end\n end\n end","def set_stay_time\n @stay_time = StayTime.find(params[:id])\n end","def update\n\n params[:appointment]['scheduled_at(5i)'] = '0'\n\n @appointment.scheduled_at = DateTime.new(params[:appointment]['scheduled_at(1i)'].to_i,\n params[:appointment]['scheduled_at(2i)'].to_i,\n params[:appointment]['scheduled_at(3i)'].to_i,\n params[:appointment]['scheduled_at(4i)'].to_i,\n params[:appointment]['scheduled_at(5i)'].to_i, 0)\n\n check_for_errors if params[:staff_ids].present?\n\n if @appointment.errors.present?\n render :json => {:success => false, :html => render_to_string(:partial => \"/appointments/errors\")}.to_json\n else\n if @appointment.update(appointment_params)\n create_appointment_users if params[:staff_ids].present?\n flash[:notice]= 'Appointment was successfully updated.'\n render :json => {:success => true,\n :html => render_to_string(:partial => \"/appointments/calandar\"),\n :flash => render_to_string(:partial => \"layouts/flash\")}.to_json\n else\n render :json => {:success => false, :html => render_to_string(:partial => \"/appointments/errors\")}.to_json\n end\n end\n\n end","def update\n respond_to do |format|\n if @order_break_time.update(order_break_time_params)\n format.html { redirect_to @order_break_time, notice: 'Order break time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render 'edit' }\n format.json { render json: @order_break_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @time_clock = TimeClock.find(params[:id])\n respond_to do |format|\n if @time_clock.update(time_clock_params)\n format.html { redirect_to @time_clock.user }\n format.json { render :show, status: :ok, location: @time_clock }\n else\n format.html { render :edit }\n format.json { render json: @time_clock.errors, status: :unprocessable_entity }\n end\n @time_clock.billed = 0\n @time_clock.hours = time_diff(@time_clock.clock_in, @time_clock.clock_out)\n @time_clock.save!\n end\n end","def update\n params[:thing][:time] = @thing.time + params[:thing][:time].to_f if @thing.time\n\n respond_to do |format|\n if @thing.update(thing_params)\n format.html { redirect_to things_url, notice: 'The thing was updated.' }\n format.json { render :show, status: :ok, location: @thing }\n\n # Realtime push\n message = {:channel => '/things', :data => { :name => @thing.name, :time => @thing.time}}\n uri = URI.parse(\"http://localhost:9292/faye\")\n Net::HTTP.post_form(uri, :message => message.to_json)\n else\n format.html { render :edit }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @nursing_time = NursingTime.find(params[:id])\n\n respond_to do |format|\n if @nursing_time.update_attributes(params[:nursing_time])\n format.html { redirect_to @nursing_time, notice: 'Nursing time was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @nursing_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @timed_task.update(timed_task_params)\n format.html { redirect_to @timed_task, notice: 'Timed task was successfully updated.' }\n format.json { render :show, status: :ok, location: @timed_task }\n else\n format.html { render :edit }\n format.json { render json: @timed_task.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @timetable = Timetable.find(params[:id])\n\n respond_to do |format|\n if @timetable.update_attributes(params[:timetable])\n format.html { redirect_to @timetable, notice: 'Timetable was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @timetable.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @allocated_time.update(allocated_time_params)\n format.html { redirect_to @allocated_time, notice: 'Allocated time was successfully updated.' }\n format.json { render :show, status: :ok, location: @allocated_time }\n else\n format.html { render :edit }\n format.json { render json: @allocated_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @trip_schedule.update(trip_schedule_params)\n format.html { redirect_to @trip_schedule, notice: 'Trip schedule was successfully updated.' }\n format.json { render :show, status: :ok, location: @trip_schedule }\n else\n format.html { render :edit }\n format.json { render json: @trip_schedule.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @work_order_time.update(work_order_time_params)\n format.html { redirect_to @work_order_time, notice: 'Work order time was successfully updated.' }\n format.json { render :show, status: :ok, location: @work_order_time }\n else\n format.html { render :edit }\n format.json { render json: @work_order_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @time_entry.update(time_entry_params)\n format.html { redirect_to @time_entry, notice: 'Time entry was successfully updated.' }\n format.json { render :show, status: :ok, location: @time_entry }\n else\n format.html { render :edit }\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @time_slot = TimeSlot.find(params[:id])\n @recurrence_array = @time_slot.recurrence_pattern.split(//)\n respond_to do |format|\n if @time_slot.update_attributes(params[:time_slot])\n format.html { redirect_to @time_slot, notice: 'Time slot was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @time_slot.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @p_time.update(p_time_params)\n format.html { redirect_to @p_time, notice: 'P time was successfully updated.' }\n format.json { render :show, status: :ok, location: @p_time }\n else\n format.html { render :edit }\n format.json { render json: @p_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @timetable.update(timetable_params)\n format.html { redirect_to request.referer, notice: 'Timetable was successfully updated.' }\n format.json { render :show, status: :ok, location: @timetable }\n else\n format.html { render :edit }\n format.json { render json: @timetable.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if UpdateTeaTime.call(@tea_time, tea_time_params)\n format.html { redirect_to profile_path, notice: 'Tea time was successfully updated.' }\n format.json { render json: @tea_time, status: :ok, location: @tea_time }\n else\n format.html { render :edit }\n format.json { render json: @tea_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @offset_time = OffsetTime.find(params[:id])\n\n respond_to do |format|\n if @offset_time.update_attributes(params[:offset_time])\n format.html { redirect_to @offset_time, notice: 'Offset time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @offset_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @time_control.update(time_control_params)\n format.html { redirect_to @time_control, notice: 'Time control was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @time_control.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @time_entry = TimeEntry.find(params[:id])\n\n respond_to do |format|\n if @time_entry.update_attributes(params[:time_entry])\n format.html { redirect_to @time_entry, notice: 'Time entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @time_entry = TimeEntry.find(params[:id])\n\n respond_to do |format|\n if @time_entry.update_attributes(params[:time_entry])\n format.html { redirect_to @time_entry, notice: 'Time entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n [:in_time, :out_time].each do |i|\n if shift_params[i] =~ /^[0-9]{1,2}:[0-9]{2}[ap]m$/\n params[:shift][i] = @shift.start_time.to_date.to_s(:db) + \" \" + shift_params[i]\n puts params[:shift][i]\n end\n end\n\n respond_to do |format|\n if @shift.update(shift_params)\n format.html { redirect_to :shifts, notice: 'Shift was successfully updated.' }\n format.json { render :show, status: :ok, location: @shift }\n else\n format.html { render :edit }\n format.json { render json: @shift.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @timer = Timer.find(params[:id])\n\n respond_to do |format|\n if @timer.update_attributes(params[:timer])\n format.html { redirect_to @timer, notice: 'Timer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @timer.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @selected_time.update(selected_time_params)\n format.html { redirect_to @selected_time, notice: 'Selected time was successfully updated.' }\n format.json { render :show, status: :ok, location: @selected_time }\n else\n format.html { render :edit }\n format.json { render json: @selected_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n if @appointment.check_updated_params(appointment_params)\n if @appointment.update(appointment_params)\n render json: @appointment, status: 200\n else\n render json: @appointment.errors, status: 422\n end\n else\n p \"did not work\"\n end\n end","def update\n operation = params[:operation]\n case operation\n when 'set_best_time'\n resp = @@serv.set_best_time(params['escape_room_id'], params['best_time'])\n render json: { success: resp.success, message: resp.message }, status: :ok\n else\n render json: { success: false, message: 'Operation can not be preformed' }, status: :bad_request\n end\n end","def update\n @timetable = Timetable.find(params[:id])\n\n respond_to do |format|\n if @timetable.update_attributes(timetable_params)\n format.html { redirect_to @timetable, notice: 'Timetable was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @timetable.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @time_tracker.update(time_tracker_params)\n format.html { redirect_to @time_tracker, notice: 'Time tracker was successfully updated.' }\n format.json { render :show, status: :ok, location: @time_tracker }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @time_tracker.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @planned_time = PlannedTime.find(params[:id])\n\n respond_to do |format|\n if @planned_time.update_attributes(params[:planned_time])\n format.html { redirect_to @planned_time, notice: 'Planned time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @planned_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @planning_time = PlanningTime.find(params[:id])\n\n respond_to do |format|\n if @planning_time.update_attributes(params[:planning_time])\n format.html { redirect_to @planning_time, notice: 'Planning time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @planning_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @punchtime.update(punchtime_params)\n format.html { redirect_to current_user, notice: 'Punchtime was successfully updated.' }\n format.json { render :show, status: :ok, location: @punchtime }\n else\n format.html { render :edit }\n format.json { render json: @punchtime.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @availibility_time_slot.update(availibility_time_slot_params)\n format.html { redirect_to @availibility_time_slot, notice: 'Availibility time slot was successfully updated.' }\n format.json { render :show, status: :ok, location: @availibility_time_slot }\n else\n format.html { render :edit }\n format.json { render json: @availibility_time_slot.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n set_appointments_patients\n respond_to do |format|\n if @appointment.update(just_appointment_params)\n format.html { redirect_to @appointment, notice: 'Appointment was successfully updated.' }\n format.json { render :show, status: :ok, location: @appointment }\n else\n format.html { render :edit }\n format.json { render json: @appointment.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @drop_route_start_time.update(drop_route_start_time_params)\n format.html { redirect_to drop_route_start_times_path, notice: 'Drop route start time was successfully updated.' }\n format.json { render :show, status: :ok, location: @drop_route_start_time }\n else\n format.html { render :edit }\n format.json { render json: @drop_route_start_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @appointment = Appointment.find(params[:id])\n str_datetime = params[:datetime].to_datetime\n # @appointment.date = DateTime.strptime(params[:appointment][:datetime], \"%m-%d-%Y\")\n @appointment.date = str_datetime\n @appointment.time = str_datetime\n @appointment.description = params[:appointment][:description]\n\n respond_to do |format|\n if @appointment.save()\n format.html { redirect_to manager_appointment_path(@appointment), notice: 'Appointment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @appointment.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @big_time_entry.update(big_time_entry_params)\n format.html { redirect_to @big_time_entry, notice: 'Big time entry was successfully updated.' }\n format.json { render :show, status: :ok, location: @big_time_entry }\n else\n format.html { render :edit }\n format.json { render json: @big_time_entry.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @receiver_time = ReceiverTime.find(params[:id])\n\n respond_to do |format|\n if @receiver_time.update_attributes(params[:receiver_time])\n format.html { redirect_to @receiver_time, notice: 'Receiver time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @receiver_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @scheduled_appointment = ScheduledAppointment.find(params[:id])\n\n respond_to do |format|\n if @scheduled_appointment.update_attributes(params.require(:scheduled_appointment).permit(:actual_date_time, :date_time, :purpose, :status, :store_id, :vehicle_id))\n format.html { redirect_to scheduled_appointments_url,\n notice: 'ScheduledAppointment was successfully updated.' }\n format.json { head :no_content }\n else\n prepFormVariables(@scheduled_appointment)\n format.html { render action: \"edit\" }\n format.json { render json: @scheduled_appointment.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @tombstone_timehold.update(tombstone_timehold_params)\n format.html { redirect_to @tombstone_timehold, notice: 'Tombstone timehold was successfully updated.' }\n format.json { render :show, status: :ok, location: @tombstone_timehold }\n else\n format.html { render :edit }\n format.json { render json: @tombstone_timehold.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @user = User.find(params[:user_id])\n @clock_time = @user.clock_times.find(params[:id])\n\n time_in_to_update = get_time_to_update(params[\"use_current\"], params[:clock_time], \"in\")\n\n @clock_time.in = time_in_to_update\n\n time_out_to_update = get_time_to_update(params[\"use_current_out\"], params[:clock_time], \"out\")\n\n if !time_out_to_update.nil?\n @clock_time.out = time_out_to_update\n end\n\n respond_to do |format|\n if @clock_time.update_attributes(params[:clock_time])\n format.html { redirect_to @user, notice: 'Your clock in time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clock_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @tap.update(tap_params)\n format.html { redirect_to taps_path, notice: 'Tap was successfully updated.' }\n format.json { head :no_content }\n else\n format.json { render json: @tap.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @class_time.update(class_time_params)\n format.html { redirect_to @class_time, notice: 'Class time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @class_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @request_meeting = RequestMeeting.find(params[:id])\n\n respond_to do |format|\n if @request_meeting.update_attributes(params[:request_meeting])\n format.html { redirect_to @request_meeting, notice: 'Request meeting was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @request_meeting.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @time_slot = TimeSlot.find(params[:id])\n\n respond_to do |format|\n if @time_slot.update_attributes(params[:time_slot])\n flash[:notice] = 'TimeSlot was successfully updated.'\n format.html { redirect_to(@time_slot) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @time_slot.errors, :status => :unprocessable_entity }\n end\n end\n end","def update\n @hotel_stay = HotelStay.find(params[:id])\n\n respond_to do |format|\n if @hotel_stay.update_attributes(params[:hotel_stay])\n format.html { redirect_to @hotel_stay, notice: 'Hotel stay was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hotel_stay.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @time_registration.update(time_registration_params)\n format.html { redirect_to @time_registration, notice: 'Time registration was successfully updated.' }\n format.json { render :show, status: :ok, location: @time_registration }\n else\n format.html { render :edit }\n format.json { render json: @time_registration.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @time_section = TimeSection.find(params[:id])\n\n respond_to do |format|\n if @time_section.update_attributes(params[:time_section])\n format.html { redirect_to @time_section, notice: 'Time section was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @time_section.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @daytime = Daytime.find(params[:id])\n\n respond_to do |format|\n if @daytime.update_attributes(params[:daytime])\n format.html { redirect_to @daytime, notice: 'Daytime was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @daytime.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @appointment.update(appointment_params)\n format.html { redirect_to @appointment, notice: 'Appointment was successfully updated.' }\n format.json { render :show, status: :ok, location: @appointment }\n else\n format.html { render :edit }\n format.json { render json: @appointment.errors, status: :unprocessable_entity }\n end\n end\nend","def update\n @time_task = TimeTask.find(params[:id])\n\n respond_to do |format|\n if @time_task.update_attributes(params[:time_task])\n flash[:notice] = 'TimeTask was successfully updated.'\n format.html { redirect_to(@time_task) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @time_task.errors, :status => :unprocessable_entity }\n end\n end\n end","def update\n @timer = Timer.find(params[:id])\n\n if @timer.update(timer_params)\n head :no_content\n else\n render json: @timer.errors, status: :unprocessable_entity\n end\n end","def update\n respond_to do |format|\n @past_request.received_help = true\n if @past_request.update(past_request_params)\n format.html { redirect_to requests_path, notice: \"You spent #{time_ago_in_words(Time.now - (Time.now - @past_request.created_at), include_seconds: true)}\" }\n format.json { render :show, status: :ok, location: @past_request }\n else\n format.html { render :edit }\n format.json { render json: @past_request.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n data = schedule_params\n data[:update_at] = Time.now\n if @schedule.update(data)\n format.html { redirect_to @schedule, notice: 'Schedule ha sido actualizado.' }\n format.json { render :index, status: :ok, location: @schedule }\n else\n format.html { render :edit }\n format.json { render json: @schedule.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @work_time = WorkTime.find(params[:id])\n\n # checks if work time is successfully updated in the database\n if @work_time.update(work_time_params)\n # if updated successfully, controller issues a response according to the format given\n respond_to do |format|\n # HTML redirects the user back to the work time index and makes a notice that editing was successful\n format.html { redirect_to api_work_time_path, notice: \"Successfully edited work time!\" }\n # JSON renders the work time updated in JSON\n format.json { render json: @work_time, status: :ok }\n # XML renders the work time updated in XML\n format.xml { render xml: @work_time, status: :ok }\n end\n else\n # if errors occured like wrong information/wrong format and so on, issues a response according to format\n respond_to do |format|\n # HTML redirects the user back to the work time edit page and shows a list of errors encountered\n format.html { redirect_to edit_api_work_time_path, notice: @work_times.errors.full_messages }\n # JSON renders all errors made and shows it in JSON and gives a negative response\n format.json { render json: @work_time.errors, status: :unprocessable_entity }\n # XML renders all errors made and shows it in XML and gives a negative response\n format.xml { render xml: @work_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @providers_opening_time.update(providers_opening_time_params)\n format.html { redirect_to providers_opening_times_path, notice: 'Opening time was successfully updated.' }\n format.json { render :show, status: :ok, location: @providers_opening_time }\n else\n format.html { render :edit }\n format.json { render json: @providers_opening_time.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n respond_to do |format|\n if @time_treinador.update(time_treinador_params)\n format.html { redirect_to @time_treinador, notice: 'Time alterado com sucesso' }\n format.json { render :show, status: :ok, location: @time_treinador }\n else\n format.html { render :edit }\n format.json { render json: @time_treinador.errors, status: :unprocessable_entity }\n end\n end\n end","def update\n @event = Event.from_param(params[:event_id])\n @time_table = @event.time_tables.where(:permalink => params[:id]).first\n success = params[:time_table] && params[:time_table][:times] && \n @time_table.update_attributes(:times => JSON.parse(params[:time_table][:times]))\n success ? update_success : update_failure\n rescue JSON::ParserError\n update_failure\n end"],"string":"[\n \"def update\\n @patient = Patient.find(params[:patient_id])\\n @schedule = @patient.schedules.find(params[:id])\\n @pill_times = @schedule.pill_times\\n\\n # TODO can improve it to use nested attributes\\n if params[:pill_time]\\n params[:pill_time].each_with_index do |pill_time, idx|\\n if @pill_times[idx]\\n @pill_times[idx].update_attributes(pill_time)\\n else\\n @pill_times.create(pill_time)\\n end\\n end\\n end\\n\\n # remove unused pill times\\n if params[:pill_time]\\n diff = @pill_times.size - params[:pill_time].size\\n @pill_times.destroy(@pill_times.last(diff)) if diff > 0\\n end\\n\\n respond_to do |format|\\n if @schedule.update_attributes(params[:schedule])\\n format.html { redirect_to [@patient, @schedule],\\n notice: 'Schedule was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @schedule.errors,\\n status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @time_gap = TimeGap.find(params[:id])\\n\\n respond_to do |format|\\n if @time_gap.update_attributes(params[:time_gap])\\n format.html { redirect_to @time_gap, notice: 'Time gap was successfully updated.' }\\n format.json { head :ok }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @time_gap.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @timing = Timing.find(params[:id])\\n if @timing.update_attributes(params[:timing].slice(:start, :stop, :days, :active))\\n render json: @timing\\n else\\n render json: { error: 'error: could not update timing' }\\n end\\n end\",\n \"def update\\n @meal_time = MealTime.find(params[:id])\\n\\n respond_to do |format|\\n if @meal_time.update_attributes(params[:meal_time])\\n format.html { redirect_to @meal_time, notice: 'Meal time was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @meal_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @cooking_time.update(cooking_time_params)\\n format.html { redirect_to cooking_times_path, notice: 'Cooking time was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: 'edit' }\\n format.json { render json: @cooking_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @working_time = WorkingTime.find(params[:id])\\n\\n respond_to do |format|\\n if @working_time.update_attributes(params[:working_time])\\n format.html { redirect_to time_tables_path }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @working_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @task.update(task_params)\\n @task.whenever_reset unless task_params[:every].blank? && task_params[:at].blank?\\n format.html { redirect_to @task, notice: 'Task was successfully updated.' }\\n format.json { render :show, status: :ok, location: @task }\\n else\\n format.html { render :edit }\\n format.json { render json: @task.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @meeting_time.update(meeting_time_params)\\n format.html { redirect_to @meeting_time, notice: 'Meeting time was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: 'edit' }\\n format.json { render json: @meeting_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @stime.update(stime_params)\\n format.html { redirect_to @stime, notice: 'Stime was successfully updated.' }\\n format.json { render :show, status: :ok, location: @stime }\\n else\\n format.html { render :edit }\\n format.json { render json: @stime.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n params[:task][:time] = parse_task_time(params[:task][:time], params[:anytime][:anytime])\\n \\n respond_to do |format|\\n if @task.update_attributes(params[:task])\\n format.html { redirect_to(tasks_url, :notice => 'Task was successfully updated.') }\\n format.xml { head :ok }\\n else\\n format.html { render :action => \\\"edit\\\" }\\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @my_time_trial = MyTimeTrial.find(params[:id])\\n\\n respond_to do |format|\\n if @my_time_trial.update_attributes(params[:my_time_trial])\\n format.html { redirect_to @my_time_trial, :notice => 'My time trial was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render :action => \\\"edit\\\" }\\n format.json { render :json => @my_time_trial.errors, :status => :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @wait_time = WaitTime.find(params[:id])\\n\\n respond_to do |format|\\n if @wait_time.update_attributes(params[:wait_time])\\n format.html { redirect_to @wait_time, notice: 'Wait time was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @wait_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @time_off_request = TimeOffRequest.find(params[:id])\\n respond_to do |format|\\n if @time_off_request.update_attributes(params[:time_off_request])\\n format.html { redirect_to admin_time_off_requests_url, notice: 'Time off request was successfully updated.' }\\n format.json { head :ok }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @time_off_request.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @time_clock.update(time_clock_params)\\n format.html { redirect_to time_sheet_index_path(@time_clock), notice: 'Time clock entry was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: 'edit' }\\n format.json { render json: @time_clock.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @service_time = ServiceTime.find(params[:id])\\n\\n respond_to do |format|\\n if @service_time.update_attributes(params[:service_time])\\n format.html { redirect_to @service_time, notice: 'Service time was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @service_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n\\n if @teetime.update(teetime_params)\\n\\n render json: @teetime,status: :ok\\n\\n else\\n\\n render json: {error: true,errors: @teetime.errors},status: :unprocessable_entity\\n\\n end\\n\\n \\t\\tend\",\n \"def update\\n @time_entry = current_firm.all_time_entries.find(params[:id])\\n\\n respond_to do |format|\\n if @time_entry.update_attributes(params[:time_entry])\\n format.html { redirect_to firm_time_entry_path(current_firm, @time_entry), notice: 'Time entry was successfully updated.' }\\n format.json { head :ok }\\n else\\n format.html { index }\\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n if @timeslot.update(timeslot_params)\\n render :show, status: :ok, location: @timeslot\\n else\\n render json: @timeslot.errors, status: :unprocessable_entity\\n end\\n end\",\n \"def update\\n if @can_edit\\n\\n # Clear out all other blocks\\n @timetable.free_times.destroy_all\\n times = JSON::Parser.new(params[:times]).parse\\n\\n # There's an array for each day of the week\\n times.each_with_index do |day, i|\\n # Each day of the week then has a list of blocks\\n day.each_with_index do |block, j|\\n unless block.empty?\\n # Each block has a start time and an end time for a free block\\n @timetable.free_times.create(:start_time => block[0], :end_time => block[1], :day_of_week => i, :weight => block[2], :css_class => block[3])\\n end\\n end\\n end\\n\\n @person ||= get_person\\n @timetable.update_attributes(:updated_by_person_id => @my.id)\\n @timetable.touch\\n return if @signup\\n\\n flash[:notice] = I18n.t('timetable.save_confirm')\\n\\n elsif !@can_edit\\n flash[:notice] = I18n.t('timetable.not_allowed_update')\\n end\\n\\n respond_to do |format|\\n format.html { redirect_to(person_timetable_path(@timetable.person, @timetable)) }\\n format.js\\n format.xml { head :ok }\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @time_slot.update(time_slot_params)\\n format.html { redirect_to @time_slot, notice: 'Time slot was successfully updated.' }\\n format.json { render :show, status: :ok, location: @time_slot }\\n else\\n format.html { render :edit }\\n format.json { render json: @time_slot.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @one_time_stop = OneTimeStop.find(params[:id])\\n\\n respond_to do |format|\\n if @one_time_stop.update_attributes(params[:one_time_stop])\\n format.html { redirect_to @one_time_stop, notice: 'One time stop was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @one_time_stop.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @where_to_stay = WhereToStay.find(params[:id])\\n\\n respond_to do |format|\\n if @where_to_stay.update_attributes(params[:where_to_stay])\\n format.html { redirect_to @where_to_stay, notice: 'Where to stay was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @where_to_stay.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @timeslot = current_event.timeslots.find(params[:id])\\n respond_to do |format|\\n @timeslot.start_time_will_change!\\n @timeslot.slot_date_will_change!\\n if @timeslot.update_attributes(params[:timeslot])\\n flash[:notice] = \\\"Timeslot was successfully updated.\\\"\\n format.html { redirect_to(timeslots_url) }\\n format.xml { head :ok }\\n else\\n format.html { render :action => \\\"edit\\\" }\\n format.xml { render :xml => @timeslot.errors, :status => :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @downtime.update(downtime_params)\\n format.html { redirect_to @downtime, notice: 'Downtime was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: 'edit' }\\n format.json { render json: @downtime.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @poi_time.update(poi_time_params)\\n format.html { redirect_to @poi_time, notice: 'Poi time was successfully updated.' }\\n format.json { render :show, status: :ok, location: @poi_time }\\n else\\n format.html { render :edit }\\n format.json { render json: @poi_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @timeslot.update(timeslot_params)\\n format.html { redirect_to @timeslot, notice: 'Timeslot was successfully updated.' }\\n format.json { render :show, status: :ok, location: @timeslot }\\n else\\n format.html { render :edit }\\n format.json { render json: @timeslot.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @location_time.update(location_time_params)\\n format.html { redirect_to @location_time, notice: 'Location time was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: 'edit' }\\n format.json { render json: @location_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n if @time_slot.update(time_slot_params)\\n render :show, status: :ok, location: @time_slot\\n else\\n render json: @time_slot.errors, status: :unprocessable_entity\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @wait_time.update(wait_time_params)\\n format.html { redirect_to @wait_time, notice: 'Wait time was successfully updated.' }\\n format.json { render :show, status: :ok, location: @wait_time }\\n else\\n format.html { render :edit }\\n format.json { render json: @wait_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @working_start_time.update(working_start_time_params)\\n format.html { redirect_to @working_start_time, notice: 'Working start time was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: 'edit' }\\n format.json { render json: @working_start_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n # @job = @shift.job\\n # @employee = @shift.employee\\n # time = @shift.time_out || @shift.time_in\\n # @shift.week = time.to_datetime\\n\\n respond_to do |format|\\n if @shift.update(shift_params)\\n format.html { redirect_to company_shift_path(@shift), notice: 'Shift was successfully updated.' }\\n format.json { render :show, status: :ok, location: @shift }\\n else\\n format.html { render :edit }\\n format.json { render json: @shift.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @stop_time = StopTime.find(params[:id])\\n\\n respond_to do |format|\\n if @stop_time.update_attributes(params[:stop_time])\\n format.html { redirect_to @stop_time, notice: 'Stop time was successfully updated.' }\\n format.json { head :ok }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @stop_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @work_time.update(work_time_params)\\n format.html { redirect_to @work_time, notice: 'Work time was successfully updated.' }\\n format.json { render :show, status: :ok, location: @work_time }\\n else\\n format.html { render :edit }\\n format.json { render json: @work_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @cal_time.update(cal_time_params)\\n format.html { redirect_to @cal_time, notice: 'Cal time was successfully updated.' }\\n format.json { render :show, status: :ok, location: @cal_time }\\n else\\n format.html { render :edit }\\n format.json { render json: @cal_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @time_of_day.update(time_of_day_params)\\n format.html { redirect_to @time_of_day, notice: 'Time of day was successfully updated.' }\\n format.json { render :show, status: :ok, location: @time_of_day }\\n else\\n format.html { render :edit }\\n format.json { render json: @time_of_day.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @time_punch.update(time_punch_params)\\n format.html { redirect_to @time_punch, notice: 'Time punch was successfully updated.' }\\n format.json { render :show, status: :ok, location: @time_punch }\\n else\\n format.html { render :edit }\\n format.json { render json: @time_punch.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @site = Site.first\\n @first_time = @site.first_time\\n respond_to do |format|\\n if @first_time.update(first_time_params)\\n format.html { redirect_to backstage_index_path, notice: 'first_time was successfully updated.' }\\n # format.json { render :show, status: :ok, location: @first_time }\\n else\\n format.html { render :edit }\\n # format.json { render json: @first_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @time_trial.update(time_trial_params)\\n format.html { redirect_to @time_trial, notice: 'Time trial was successfully updated.' }\\n format.json { render :show, status: :ok, location: @time_trial }\\n else\\n format.html { render :edit }\\n format.json { render json: @time_trial.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n if @timing.update(timing_params)\\n render :show, status: :ok, location: @timing\\n else\\n render json: @timing.errors, status: :unprocessable_entity\\n end\\n end\",\n \"def update\\n @meeting = Meeting.find(params[:id])\\n @meeting.meeting_time = params[:meeting][:meeting_time]\\n respond_to do |format|\\n if @meeting.update_attributes(params[:meeting])\\n format.html { redirect_to club_meeting_path(params[:club_id],@meeting), notice: 'Meeting was successfully updated.' }\\n format.json { head :ok }\\n \\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\\n \\n end\\n end\\n end\",\n \"def update\\n @hurdle_time = HurdleTime.find(params[:id])\\n\\n time = (params[:time][:minutes].to_i * 60) + params[:time][:seconds].to_i\\n if params[:hurdle_time]\\n params[:hurdle_time].store :time, time\\n else\\n params[:hurdle_time] = {}.store :time, time\\n end\\n\\n respond_to do |format|\\n if @hurdle_time.update_attributes(params[:hurdle_time])\\n format.html { redirect_to hurdle_match_hurdle_times_path(@hurdle_time.hurdle_match), notice: 'Hurdle time was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @hurdle_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @day_timeslot.update(day_timeslot_params)\\n format.html { redirect_to @day_timeslot, notice: 'Day timeslot was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: 'edit' }\\n format.json { render json: @day_timeslot.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n begin\\n @appointment = Appointment.find(params[:id])\\n rescue\\n respond_info('error', 'internal_server_error', 'Update Appointment Failed', :internal_server_error)\\n return\\n end\\n if @appointment.update(appointment_params)\\n render :json => @appointments, :status => :no_content #HTTP status code: 204 No Content\\n else\\n render json: @appointment.errors, status: :unprocessable_entity\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n self.unuse_pto_hours\\n if @time_off_instance.update(time_off_instance_params)\\n self.use_pto_hours\\n format.html { redirect_to @time_off_instance, notice: 'Time off instance was successfully updated.' }\\n format.json { render :show, status: :ok, location: @time_off_instance }\\n else\\n format.html { render :edit }\\n format.json { render json: @time_off_instance.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def set_stay_time\\n @stay_time = StayTime.find(params[:id])\\n end\",\n \"def update\\n\\n params[:appointment]['scheduled_at(5i)'] = '0'\\n\\n @appointment.scheduled_at = DateTime.new(params[:appointment]['scheduled_at(1i)'].to_i,\\n params[:appointment]['scheduled_at(2i)'].to_i,\\n params[:appointment]['scheduled_at(3i)'].to_i,\\n params[:appointment]['scheduled_at(4i)'].to_i,\\n params[:appointment]['scheduled_at(5i)'].to_i, 0)\\n\\n check_for_errors if params[:staff_ids].present?\\n\\n if @appointment.errors.present?\\n render :json => {:success => false, :html => render_to_string(:partial => \\\"/appointments/errors\\\")}.to_json\\n else\\n if @appointment.update(appointment_params)\\n create_appointment_users if params[:staff_ids].present?\\n flash[:notice]= 'Appointment was successfully updated.'\\n render :json => {:success => true,\\n :html => render_to_string(:partial => \\\"/appointments/calandar\\\"),\\n :flash => render_to_string(:partial => \\\"layouts/flash\\\")}.to_json\\n else\\n render :json => {:success => false, :html => render_to_string(:partial => \\\"/appointments/errors\\\")}.to_json\\n end\\n end\\n\\n end\",\n \"def update\\n respond_to do |format|\\n if @order_break_time.update(order_break_time_params)\\n format.html { redirect_to @order_break_time, notice: 'Order break time was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render 'edit' }\\n format.json { render json: @order_break_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @time_clock = TimeClock.find(params[:id])\\n respond_to do |format|\\n if @time_clock.update(time_clock_params)\\n format.html { redirect_to @time_clock.user }\\n format.json { render :show, status: :ok, location: @time_clock }\\n else\\n format.html { render :edit }\\n format.json { render json: @time_clock.errors, status: :unprocessable_entity }\\n end\\n @time_clock.billed = 0\\n @time_clock.hours = time_diff(@time_clock.clock_in, @time_clock.clock_out)\\n @time_clock.save!\\n end\\n end\",\n \"def update\\n params[:thing][:time] = @thing.time + params[:thing][:time].to_f if @thing.time\\n\\n respond_to do |format|\\n if @thing.update(thing_params)\\n format.html { redirect_to things_url, notice: 'The thing was updated.' }\\n format.json { render :show, status: :ok, location: @thing }\\n\\n # Realtime push\\n message = {:channel => '/things', :data => { :name => @thing.name, :time => @thing.time}}\\n uri = URI.parse(\\\"http://localhost:9292/faye\\\")\\n Net::HTTP.post_form(uri, :message => message.to_json)\\n else\\n format.html { render :edit }\\n format.json { render json: @thing.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @nursing_time = NursingTime.find(params[:id])\\n\\n respond_to do |format|\\n if @nursing_time.update_attributes(params[:nursing_time])\\n format.html { redirect_to @nursing_time, notice: 'Nursing time was successfully updated.' }\\n format.json { head :ok }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @nursing_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @timed_task.update(timed_task_params)\\n format.html { redirect_to @timed_task, notice: 'Timed task was successfully updated.' }\\n format.json { render :show, status: :ok, location: @timed_task }\\n else\\n format.html { render :edit }\\n format.json { render json: @timed_task.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @timetable = Timetable.find(params[:id])\\n\\n respond_to do |format|\\n if @timetable.update_attributes(params[:timetable])\\n format.html { redirect_to @timetable, notice: 'Timetable was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @timetable.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @allocated_time.update(allocated_time_params)\\n format.html { redirect_to @allocated_time, notice: 'Allocated time was successfully updated.' }\\n format.json { render :show, status: :ok, location: @allocated_time }\\n else\\n format.html { render :edit }\\n format.json { render json: @allocated_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @trip_schedule.update(trip_schedule_params)\\n format.html { redirect_to @trip_schedule, notice: 'Trip schedule was successfully updated.' }\\n format.json { render :show, status: :ok, location: @trip_schedule }\\n else\\n format.html { render :edit }\\n format.json { render json: @trip_schedule.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @work_order_time.update(work_order_time_params)\\n format.html { redirect_to @work_order_time, notice: 'Work order time was successfully updated.' }\\n format.json { render :show, status: :ok, location: @work_order_time }\\n else\\n format.html { render :edit }\\n format.json { render json: @work_order_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @time_entry.update(time_entry_params)\\n format.html { redirect_to @time_entry, notice: 'Time entry was successfully updated.' }\\n format.json { render :show, status: :ok, location: @time_entry }\\n else\\n format.html { render :edit }\\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @time_slot = TimeSlot.find(params[:id])\\n @recurrence_array = @time_slot.recurrence_pattern.split(//)\\n respond_to do |format|\\n if @time_slot.update_attributes(params[:time_slot])\\n format.html { redirect_to @time_slot, notice: 'Time slot was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @time_slot.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @p_time.update(p_time_params)\\n format.html { redirect_to @p_time, notice: 'P time was successfully updated.' }\\n format.json { render :show, status: :ok, location: @p_time }\\n else\\n format.html { render :edit }\\n format.json { render json: @p_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @timetable.update(timetable_params)\\n format.html { redirect_to request.referer, notice: 'Timetable was successfully updated.' }\\n format.json { render :show, status: :ok, location: @timetable }\\n else\\n format.html { render :edit }\\n format.json { render json: @timetable.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if UpdateTeaTime.call(@tea_time, tea_time_params)\\n format.html { redirect_to profile_path, notice: 'Tea time was successfully updated.' }\\n format.json { render json: @tea_time, status: :ok, location: @tea_time }\\n else\\n format.html { render :edit }\\n format.json { render json: @tea_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @offset_time = OffsetTime.find(params[:id])\\n\\n respond_to do |format|\\n if @offset_time.update_attributes(params[:offset_time])\\n format.html { redirect_to @offset_time, notice: 'Offset time was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @offset_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @time_control.update(time_control_params)\\n format.html { redirect_to @time_control, notice: 'Time control was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: 'edit' }\\n format.json { render json: @time_control.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @time_entry = TimeEntry.find(params[:id])\\n\\n respond_to do |format|\\n if @time_entry.update_attributes(params[:time_entry])\\n format.html { redirect_to @time_entry, notice: 'Time entry was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @time_entry = TimeEntry.find(params[:id])\\n\\n respond_to do |format|\\n if @time_entry.update_attributes(params[:time_entry])\\n format.html { redirect_to @time_entry, notice: 'Time entry was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @time_entry.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n [:in_time, :out_time].each do |i|\\n if shift_params[i] =~ /^[0-9]{1,2}:[0-9]{2}[ap]m$/\\n params[:shift][i] = @shift.start_time.to_date.to_s(:db) + \\\" \\\" + shift_params[i]\\n puts params[:shift][i]\\n end\\n end\\n\\n respond_to do |format|\\n if @shift.update(shift_params)\\n format.html { redirect_to :shifts, notice: 'Shift was successfully updated.' }\\n format.json { render :show, status: :ok, location: @shift }\\n else\\n format.html { render :edit }\\n format.json { render json: @shift.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @timer = Timer.find(params[:id])\\n\\n respond_to do |format|\\n if @timer.update_attributes(params[:timer])\\n format.html { redirect_to @timer, notice: 'Timer was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @timer.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @selected_time.update(selected_time_params)\\n format.html { redirect_to @selected_time, notice: 'Selected time was successfully updated.' }\\n format.json { render :show, status: :ok, location: @selected_time }\\n else\\n format.html { render :edit }\\n format.json { render json: @selected_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n if @appointment.check_updated_params(appointment_params)\\n if @appointment.update(appointment_params)\\n render json: @appointment, status: 200\\n else\\n render json: @appointment.errors, status: 422\\n end\\n else\\n p \\\"did not work\\\"\\n end\\n end\",\n \"def update\\n operation = params[:operation]\\n case operation\\n when 'set_best_time'\\n resp = @@serv.set_best_time(params['escape_room_id'], params['best_time'])\\n render json: { success: resp.success, message: resp.message }, status: :ok\\n else\\n render json: { success: false, message: 'Operation can not be preformed' }, status: :bad_request\\n end\\n end\",\n \"def update\\n @timetable = Timetable.find(params[:id])\\n\\n respond_to do |format|\\n if @timetable.update_attributes(timetable_params)\\n format.html { redirect_to @timetable, notice: 'Timetable was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @timetable.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @time_tracker.update(time_tracker_params)\\n format.html { redirect_to @time_tracker, notice: 'Time tracker was successfully updated.' }\\n format.json { render :show, status: :ok, location: @time_tracker }\\n else\\n format.html { render :edit, status: :unprocessable_entity }\\n format.json { render json: @time_tracker.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @planned_time = PlannedTime.find(params[:id])\\n\\n respond_to do |format|\\n if @planned_time.update_attributes(params[:planned_time])\\n format.html { redirect_to @planned_time, notice: 'Planned time was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @planned_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @planning_time = PlanningTime.find(params[:id])\\n\\n respond_to do |format|\\n if @planning_time.update_attributes(params[:planning_time])\\n format.html { redirect_to @planning_time, notice: 'Planning time was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @planning_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @punchtime.update(punchtime_params)\\n format.html { redirect_to current_user, notice: 'Punchtime was successfully updated.' }\\n format.json { render :show, status: :ok, location: @punchtime }\\n else\\n format.html { render :edit }\\n format.json { render json: @punchtime.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @availibility_time_slot.update(availibility_time_slot_params)\\n format.html { redirect_to @availibility_time_slot, notice: 'Availibility time slot was successfully updated.' }\\n format.json { render :show, status: :ok, location: @availibility_time_slot }\\n else\\n format.html { render :edit }\\n format.json { render json: @availibility_time_slot.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n set_appointments_patients\\n respond_to do |format|\\n if @appointment.update(just_appointment_params)\\n format.html { redirect_to @appointment, notice: 'Appointment was successfully updated.' }\\n format.json { render :show, status: :ok, location: @appointment }\\n else\\n format.html { render :edit }\\n format.json { render json: @appointment.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @drop_route_start_time.update(drop_route_start_time_params)\\n format.html { redirect_to drop_route_start_times_path, notice: 'Drop route start time was successfully updated.' }\\n format.json { render :show, status: :ok, location: @drop_route_start_time }\\n else\\n format.html { render :edit }\\n format.json { render json: @drop_route_start_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @appointment = Appointment.find(params[:id])\\n str_datetime = params[:datetime].to_datetime\\n # @appointment.date = DateTime.strptime(params[:appointment][:datetime], \\\"%m-%d-%Y\\\")\\n @appointment.date = str_datetime\\n @appointment.time = str_datetime\\n @appointment.description = params[:appointment][:description]\\n\\n respond_to do |format|\\n if @appointment.save()\\n format.html { redirect_to manager_appointment_path(@appointment), notice: 'Appointment was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @appointment.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @big_time_entry.update(big_time_entry_params)\\n format.html { redirect_to @big_time_entry, notice: 'Big time entry was successfully updated.' }\\n format.json { render :show, status: :ok, location: @big_time_entry }\\n else\\n format.html { render :edit }\\n format.json { render json: @big_time_entry.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @receiver_time = ReceiverTime.find(params[:id])\\n\\n respond_to do |format|\\n if @receiver_time.update_attributes(params[:receiver_time])\\n format.html { redirect_to @receiver_time, notice: 'Receiver time was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @receiver_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @scheduled_appointment = ScheduledAppointment.find(params[:id])\\n\\n respond_to do |format|\\n if @scheduled_appointment.update_attributes(params.require(:scheduled_appointment).permit(:actual_date_time, :date_time, :purpose, :status, :store_id, :vehicle_id))\\n format.html { redirect_to scheduled_appointments_url,\\n notice: 'ScheduledAppointment was successfully updated.' }\\n format.json { head :no_content }\\n else\\n prepFormVariables(@scheduled_appointment)\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @scheduled_appointment.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @tombstone_timehold.update(tombstone_timehold_params)\\n format.html { redirect_to @tombstone_timehold, notice: 'Tombstone timehold was successfully updated.' }\\n format.json { render :show, status: :ok, location: @tombstone_timehold }\\n else\\n format.html { render :edit }\\n format.json { render json: @tombstone_timehold.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @user = User.find(params[:user_id])\\n @clock_time = @user.clock_times.find(params[:id])\\n\\n time_in_to_update = get_time_to_update(params[\\\"use_current\\\"], params[:clock_time], \\\"in\\\")\\n\\n @clock_time.in = time_in_to_update\\n\\n time_out_to_update = get_time_to_update(params[\\\"use_current_out\\\"], params[:clock_time], \\\"out\\\")\\n\\n if !time_out_to_update.nil?\\n @clock_time.out = time_out_to_update\\n end\\n\\n respond_to do |format|\\n if @clock_time.update_attributes(params[:clock_time])\\n format.html { redirect_to @user, notice: 'Your clock in time was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @clock_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @tap.update(tap_params)\\n format.html { redirect_to taps_path, notice: 'Tap was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.json { render json: @tap.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @class_time.update(class_time_params)\\n format.html { redirect_to @class_time, notice: 'Class time was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: 'edit' }\\n format.json { render json: @class_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @request_meeting = RequestMeeting.find(params[:id])\\n\\n respond_to do |format|\\n if @request_meeting.update_attributes(params[:request_meeting])\\n format.html { redirect_to @request_meeting, notice: 'Request meeting was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @request_meeting.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @time_slot = TimeSlot.find(params[:id])\\n\\n respond_to do |format|\\n if @time_slot.update_attributes(params[:time_slot])\\n flash[:notice] = 'TimeSlot was successfully updated.'\\n format.html { redirect_to(@time_slot) }\\n format.xml { head :ok }\\n else\\n format.html { render :action => \\\"edit\\\" }\\n format.xml { render :xml => @time_slot.errors, :status => :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @hotel_stay = HotelStay.find(params[:id])\\n\\n respond_to do |format|\\n if @hotel_stay.update_attributes(params[:hotel_stay])\\n format.html { redirect_to @hotel_stay, notice: 'Hotel stay was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @hotel_stay.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @time_registration.update(time_registration_params)\\n format.html { redirect_to @time_registration, notice: 'Time registration was successfully updated.' }\\n format.json { render :show, status: :ok, location: @time_registration }\\n else\\n format.html { render :edit }\\n format.json { render json: @time_registration.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @time_section = TimeSection.find(params[:id])\\n\\n respond_to do |format|\\n if @time_section.update_attributes(params[:time_section])\\n format.html { redirect_to @time_section, notice: 'Time section was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @time_section.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @daytime = Daytime.find(params[:id])\\n\\n respond_to do |format|\\n if @daytime.update_attributes(params[:daytime])\\n format.html { redirect_to @daytime, notice: 'Daytime was successfully updated.' }\\n format.json { head :no_content }\\n else\\n format.html { render action: \\\"edit\\\" }\\n format.json { render json: @daytime.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @appointment.update(appointment_params)\\n format.html { redirect_to @appointment, notice: 'Appointment was successfully updated.' }\\n format.json { render :show, status: :ok, location: @appointment }\\n else\\n format.html { render :edit }\\n format.json { render json: @appointment.errors, status: :unprocessable_entity }\\n end\\n end\\nend\",\n \"def update\\n @time_task = TimeTask.find(params[:id])\\n\\n respond_to do |format|\\n if @time_task.update_attributes(params[:time_task])\\n flash[:notice] = 'TimeTask was successfully updated.'\\n format.html { redirect_to(@time_task) }\\n format.xml { head :ok }\\n else\\n format.html { render :action => \\\"edit\\\" }\\n format.xml { render :xml => @time_task.errors, :status => :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @timer = Timer.find(params[:id])\\n\\n if @timer.update(timer_params)\\n head :no_content\\n else\\n render json: @timer.errors, status: :unprocessable_entity\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n @past_request.received_help = true\\n if @past_request.update(past_request_params)\\n format.html { redirect_to requests_path, notice: \\\"You spent #{time_ago_in_words(Time.now - (Time.now - @past_request.created_at), include_seconds: true)}\\\" }\\n format.json { render :show, status: :ok, location: @past_request }\\n else\\n format.html { render :edit }\\n format.json { render json: @past_request.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n data = schedule_params\\n data[:update_at] = Time.now\\n if @schedule.update(data)\\n format.html { redirect_to @schedule, notice: 'Schedule ha sido actualizado.' }\\n format.json { render :index, status: :ok, location: @schedule }\\n else\\n format.html { render :edit }\\n format.json { render json: @schedule.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @work_time = WorkTime.find(params[:id])\\n\\n # checks if work time is successfully updated in the database\\n if @work_time.update(work_time_params)\\n # if updated successfully, controller issues a response according to the format given\\n respond_to do |format|\\n # HTML redirects the user back to the work time index and makes a notice that editing was successful\\n format.html { redirect_to api_work_time_path, notice: \\\"Successfully edited work time!\\\" }\\n # JSON renders the work time updated in JSON\\n format.json { render json: @work_time, status: :ok }\\n # XML renders the work time updated in XML\\n format.xml { render xml: @work_time, status: :ok }\\n end\\n else\\n # if errors occured like wrong information/wrong format and so on, issues a response according to format\\n respond_to do |format|\\n # HTML redirects the user back to the work time edit page and shows a list of errors encountered\\n format.html { redirect_to edit_api_work_time_path, notice: @work_times.errors.full_messages }\\n # JSON renders all errors made and shows it in JSON and gives a negative response\\n format.json { render json: @work_time.errors, status: :unprocessable_entity }\\n # XML renders all errors made and shows it in XML and gives a negative response\\n format.xml { render xml: @work_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @providers_opening_time.update(providers_opening_time_params)\\n format.html { redirect_to providers_opening_times_path, notice: 'Opening time was successfully updated.' }\\n format.json { render :show, status: :ok, location: @providers_opening_time }\\n else\\n format.html { render :edit }\\n format.json { render json: @providers_opening_time.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n respond_to do |format|\\n if @time_treinador.update(time_treinador_params)\\n format.html { redirect_to @time_treinador, notice: 'Time alterado com sucesso' }\\n format.json { render :show, status: :ok, location: @time_treinador }\\n else\\n format.html { render :edit }\\n format.json { render json: @time_treinador.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def update\\n @event = Event.from_param(params[:event_id])\\n @time_table = @event.time_tables.where(:permalink => params[:id]).first\\n success = params[:time_table] && params[:time_table][:times] && \\n @time_table.update_attributes(:times => JSON.parse(params[:time_table][:times]))\\n success ? update_success : update_failure\\n rescue JSON::ParserError\\n update_failure\\n end\"\n]"},"negative_scores":{"kind":"list like","value":["0.6653054","0.66524994","0.6601323","0.6582362","0.6573549","0.65660256","0.6546499","0.6529287","0.6527774","0.6489228","0.6447293","0.64378303","0.6422342","0.641576","0.6414202","0.6411619","0.6408857","0.6397323","0.639375","0.6386395","0.6381744","0.63801914","0.6353734","0.63528013","0.6350535","0.6349531","0.6335187","0.633248","0.63109475","0.62985986","0.629333","0.62913203","0.6288821","0.62772816","0.627409","0.6268616","0.6267601","0.62648135","0.6245133","0.6243057","0.6228353","0.6223843","0.6219732","0.62190855","0.6216214","0.6202801","0.62007004","0.6200237","0.61851424","0.61793613","0.61691856","0.6161513","0.6160769","0.6158495","0.61536473","0.61479235","0.6142414","0.6137027","0.6135917","0.6130264","0.6129659","0.61285955","0.6127055","0.6127055","0.6121312","0.61206263","0.6111371","0.6107174","0.60868716","0.6086108","0.6071882","0.60707706","0.606296","0.6062796","0.6061714","0.6060584","0.60540825","0.605114","0.6046673","0.6038729","0.6033487","0.60327446","0.6032353","0.60319555","0.60197574","0.60192704","0.6018504","0.6014657","0.5996531","0.5994654","0.5993393","0.5991575","0.5990629","0.5986251","0.59852797","0.5984254","0.5978703","0.5978264","0.59779626","0.59766966"],"string":"[\n \"0.6653054\",\n \"0.66524994\",\n \"0.6601323\",\n \"0.6582362\",\n \"0.6573549\",\n \"0.65660256\",\n \"0.6546499\",\n \"0.6529287\",\n \"0.6527774\",\n \"0.6489228\",\n \"0.6447293\",\n \"0.64378303\",\n \"0.6422342\",\n \"0.641576\",\n \"0.6414202\",\n \"0.6411619\",\n \"0.6408857\",\n \"0.6397323\",\n \"0.639375\",\n \"0.6386395\",\n \"0.6381744\",\n \"0.63801914\",\n \"0.6353734\",\n \"0.63528013\",\n \"0.6350535\",\n \"0.6349531\",\n \"0.6335187\",\n \"0.633248\",\n \"0.63109475\",\n \"0.62985986\",\n \"0.629333\",\n \"0.62913203\",\n \"0.6288821\",\n \"0.62772816\",\n \"0.627409\",\n \"0.6268616\",\n \"0.6267601\",\n \"0.62648135\",\n \"0.6245133\",\n \"0.6243057\",\n \"0.6228353\",\n \"0.6223843\",\n \"0.6219732\",\n \"0.62190855\",\n \"0.6216214\",\n \"0.6202801\",\n \"0.62007004\",\n \"0.6200237\",\n \"0.61851424\",\n \"0.61793613\",\n \"0.61691856\",\n \"0.6161513\",\n \"0.6160769\",\n \"0.6158495\",\n \"0.61536473\",\n \"0.61479235\",\n \"0.6142414\",\n \"0.6137027\",\n \"0.6135917\",\n \"0.6130264\",\n \"0.6129659\",\n \"0.61285955\",\n \"0.6127055\",\n \"0.6127055\",\n \"0.6121312\",\n \"0.61206263\",\n \"0.6111371\",\n \"0.6107174\",\n \"0.60868716\",\n \"0.6086108\",\n \"0.6071882\",\n \"0.60707706\",\n \"0.606296\",\n \"0.6062796\",\n \"0.6061714\",\n \"0.6060584\",\n \"0.60540825\",\n \"0.605114\",\n \"0.6046673\",\n \"0.6038729\",\n \"0.6033487\",\n \"0.60327446\",\n \"0.6032353\",\n \"0.60319555\",\n \"0.60197574\",\n \"0.60192704\",\n \"0.6018504\",\n \"0.6014657\",\n \"0.5996531\",\n \"0.5994654\",\n \"0.5993393\",\n \"0.5991575\",\n \"0.5990629\",\n \"0.5986251\",\n \"0.59852797\",\n \"0.5984254\",\n \"0.5978703\",\n \"0.5978264\",\n \"0.59779626\",\n \"0.59766966\"\n]"},"document_score":{"kind":"string","value":"0.7227714"},"document_rank":{"kind":"string","value":"0"}}},{"rowIdx":129,"cells":{"query":{"kind":"string","value":"DELETE /stay_times/1 DELETE /stay_times/1.json"},"document":{"kind":"string","value":"def destroy\n @stay_time.destroy\n respond_to do |format|\n format.html { redirect_to stay_times_url, notice: 'Stay time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def destroy\n @time_gap = TimeGap.find(params[:id])\n @time_gap.destroy\n\n respond_to do |format|\n format.html { redirect_to time_gaps_url }\n format.json { head :ok }\n end\n end","def destroy\n @meal_time = MealTime.find(params[:id])\n @meal_time.destroy\n\n respond_to do |format|\n format.html { redirect_to meal_times_url }\n format.json { head :no_content }\n end\n end","def destroy\n @hurdle_time = HurdleTime.find(params[:id])\n @hurdle_time.destroy\n\n respond_to do |format|\n format.html { redirect_to hurdle_times_url }\n format.json { head :no_content }\n end\n end","def destroy\n @cooking_time.destroy\n respond_to do |format|\n format.html { redirect_to cooking_times_url }\n format.json { head :no_content }\n end\n end","def destroy\n @downtime.destroy\n respond_to do |format|\n format.html { redirect_to downtimes_url }\n format.json { head :no_content }\n end\n end","def destroy\n @stime.destroy\n respond_to do |format|\n format.html { redirect_to stimes_url, notice: 'Stime was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @service_time = ServiceTime.find(params[:id])\n @service_time.destroy\n\n respond_to do |format|\n format.html { redirect_to service_times_url }\n format.json { head :no_content }\n end\n end","def destroy\n @nursing_time = NursingTime.find(params[:id])\n @nursing_time.destroy\n\n respond_to do |format|\n format.html { redirect_to nursing_times_url }\n format.json { head :ok }\n end\n end","def destroy\n @wait_time = WaitTime.find(params[:id])\n @wait_time.destroy\n\n respond_to do |format|\n format.html { redirect_to wait_times_url }\n format.json { head :no_content }\n end\n end","def destroy\n @meeting_time.destroy\n respond_to do |format|\n format.html { redirect_to meeting_times_url }\n format.json { head :no_content }\n end\n end","def destroy\n @time_clock.destroy\n respond_to do |format|\n format.html { redirect_to time_sheet_index_path }\n format.json { head :no_content }\n end\n end","def destroy\n @my_time_trial = MyTimeTrial.find(params[:id])\n @my_time_trial.destroy\n\n respond_to do |format|\n format.html { redirect_to my_time_trials_url }\n format.json { head :no_content }\n end\n end","def destroy\n @daytime = Daytime.find(params[:id])\n @daytime.destroy\n\n respond_to do |format|\n format.html { redirect_to daytimes_url }\n format.json { head :no_content }\n end\n end","def destroy\n @location_time.destroy\n respond_to do |format|\n format.html { redirect_to location_times_url }\n format.json { head :no_content }\n end\n end","def destroy\n @time_of_day.destroy\n respond_to do |format|\n format.html { redirect_to time_of_days_url, notice: 'Time of day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @where_to_stay = WhereToStay.find(params[:id])\n @where_to_stay.destroy\n\n respond_to do |format|\n format.html { redirect_to where_to_stays_url }\n format.json { head :no_content }\n end\n end","def destroy\n @allocated_time.destroy\n respond_to do |format|\n format.html { redirect_to allocated_times_url, notice: 'Allocated time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @time_off_request = TimeOffRequest.find(params[:id])\n @time_off_request.destroy\n \n respond_to do |format|\n format.html { redirect_to admin_time_off_requests_url}\n format.json { head :ok }\n end\n end","def destroy\n @stay_night.destroy\n respond_to do |format|\n format.html { redirect_to stay_nights_url }\n format.json { head :no_content }\n format.js\n end\n end","def destroy\n @one_time_stop = OneTimeStop.find(params[:id])\n @one_time_stop.destroy\n\n respond_to do |format|\n format.html { redirect_to one_time_stops_url }\n format.json { head :no_content }\n end\n end","def destroy\n @working_start_time.destroy\n respond_to do |format|\n format.html { redirect_to working_start_times_url }\n format.json { head :no_content }\n end\n end","def destroy\n @day_timeslot.destroy\n respond_to do |format|\n format.html { redirect_to day_timeslots_url }\n format.json { head :no_content }\n end\n end","def destroy\n @stop_time = StopTime.find(params[:id])\n @stop_time.destroy\n\n respond_to do |format|\n format.html { redirect_to stop_times_url }\n format.json { head :ok }\n end\n end","def destroy\n @order_break_time.destroy\n respond_to do |format|\n format.html { redirect_to order_break_times_url }\n format.json { head :no_content }\n end\n end","def destroy\n @disatance_and_time.destroy\n respond_to do |format|\n format.html { redirect_to disatance_and_times_url, notice: 'Disatance and time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @poi_time.destroy\n respond_to do |format|\n format.html { redirect_to poi_times_url, notice: 'Poi time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @cal_time.destroy\n respond_to do |format|\n format.html { redirect_to cal_times_url, notice: 'Cal time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @time_entry = TimeEntry.with_deleted.find(params[:id])\n @time_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to time_entries_url }\n format.json { head :no_content }\n end\n end","def destroy\n @time_trial.destroy\n respond_to do |format|\n format.html { redirect_to '/admin', notice: 'Time trial was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @time_entry = current_firm.all_time_entries.find(params[:id])\n @time_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to params[:ret] || firm_time_entries_path(current_firm) }\n format.json { head :ok }\n end\n end","def destroy\n @time_log = TimeLog.find(params[:id])\n @time_log.destroy\n\n respond_to do |format|\n format.html { redirect_to time_logs_url }\n format.json { head :ok }\n end\n end","def deleteEntityOpening_times( entity_id)\n params = Hash.new\n params['entity_id'] = entity_id\n return doCurl(\"delete\",\"/entity/opening_times\",params)\n end","def destroy\n @hotel_stay = HotelStay.find(params[:id])\n @hotel_stay.destroy\n\n respond_to do |format|\n format.html { redirect_to hotel_stays_url }\n format.json { head :no_content }\n end\n end","def destroy\n @working_time = WorkingTime.find(params[:id])\n @working_time.destroy\n\n respond_to do |format|\n format.html { redirect_to time_tables_url }\n format.json { head :no_content }\n end\n end","def destroy\n @time_slot = TimeSlot.find(params[:id])\n @time_slot.destroy\n\n respond_to do |format|\n format.html { redirect_to time_slots_url }\n format.json { head :no_content }\n end\n end","def delete\n client.delete(\"/#{id}\")\n end","def destroy\n @wait_time.destroy\n respond_to do |format|\n format.html { redirect_to wait_times_url, notice: 'Wait time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @class_time.destroy\n respond_to do |format|\n format.html { redirect_to class_times_url }\n format.json { head :no_content }\n end\n end","def destroy\n @planning_time = PlanningTime.find(params[:id])\n @planning_time.destroy\n\n respond_to do |format|\n format.html { redirect_to planning_times_url }\n format.json { head :no_content }\n end\n end","def destroy\n @time_entry = TimeEntry.find(params[:id])\n @time_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to time_entries_url }\n format.json { head :no_content }\n end\n end","def destroy\n @time_entry = TimeEntry.find(params[:id])\n @time_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to time_entries_url }\n format.json { head :no_content }\n end\n end","def destroy\n @timeslot.destroy\n respond_to do |format|\n format.html { redirect_to timeslots_url, notice: 'Timeslot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @member_time = MemberTime.find(params[:id])\n @member_time.destroy\n\n respond_to do |format|\n format.html { redirect_to member_times_url }\n format.json { head :no_content }\n end\n end","def destroy\n @titletime.destroy\n respond_to do |format|\n format.html { redirect_to titletimes_url }\n format.json { head :no_content }\n end\n end","def destroy\n @showtime.destroy\n respond_to do |format|\n format.html { redirect_to showtimes_url, notice: \"Showtime was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end","def destroy\n @time_entry.destroy\n respond_to do |format|\n format.html { redirect_to time_entries_url, notice: 'Time entry was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @timetable = Timetable.find(params[:id])\n @timetable.destroy\n\n respond_to do |format|\n format.html { redirect_to timetables_url }\n format.json { head :no_content }\n end\n end","def destroy\n @tombstone_timehold.destroy\n respond_to do |format|\n format.html { redirect_to tombstone_timeholds_url, notice: 'Tombstone timehold was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @time_period.destroy\n format.json { head :no_content }\n end","def destroy\n @section_time.destroy\n respond_to do |format|\n format.html { redirect_to section_times_url, notice: 'Section time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @p_time.destroy\n respond_to do |format|\n format.html { redirect_to p_times_url, notice: 'P time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n #Uncomment this if for some reason users should be able to delete TTs\n #@tea_time.destroy\n respond_to do |format|\n format.html { render text: \"I can't let you do that, #{current_user.name}\" }\n format.json { head 403 }\n end\n end","def destroy\n @selected_time.destroy\n respond_to do |format|\n format.html { redirect_to selected_times_url, notice: 'Selected time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @offset_time = OffsetTime.find(params[:id])\n @offset_time.destroy\n\n respond_to do |format|\n format.html { redirect_to offset_times_url }\n format.json { head :no_content }\n end\n end","def destroy\n @time_section = TimeSection.find(params[:id])\n @time_section.destroy\n\n respond_to do |format|\n format.html { redirect_to time_sections_url }\n format.json { head :no_content }\n end\n end","def destroy\n return if new_record?\n \n @api.delete \"/meetings/#{shortcode_url}.json\"\n end","def destroy\n\n if @teetime.destroy\n\n render json: {teetime: {id: params[:id].to_i}},status: :ok\n\n else\n\n render json: {error: true,errors: @teetime.errors},status: :unprocessable_entity\n\n end\n\n \t\tend","def destroy\n @timelog.destroy\n respond_to do |format|\n format.html { redirect_to timelogs_url, notice: 'Timelog was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @time_slots_list.destroy\n respond_to do |format|\n format.html { redirect_to time_slots_lists_url }\n format.json { head :no_content }\n end\n end","def destroy\n @mealtime.destroy\n respond_to do |format|\n format.html { redirect_to mealtimes_url, notice: 'Mealtime was successfully destroyed.' }\n end\n end","def destroy\n @work_time.destroy\n respond_to do |format|\n format.html { redirect_to work_times_url, notice: 'Work time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @appointment.destroy\n head 204\n end","def delete path\n make_request(path, \"delete\", {})\n end","def destroy\n @time_record = TimeRecord.find(params[:id])\n @time_record.destroy\n\n respond_to do |format|\n format.html { redirect_to time_records_url }\n format.json { head :no_content }\n end\n end","def destroy\n @time_record = TimeRecord.find(params[:id])\n @time_record.destroy\n\n respond_to do |format|\n format.html { redirect_to time_records_url }\n format.json { head :no_content }\n end\n end","def destroy\n @time_slot.destroy\n respond_to do |format|\n format.html { redirect_to time_slots_url, notice: 'Time slot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @time_visitor = TimeVisitor.find(params[:id])\n @time_visitor.destroy\n\n respond_to do |format|\n format.html { redirect_to tour_visitor_time_visitors_url }\n format.json { head :no_content }\n end\n end","def destroy\n @timeentry = Timeentry.find(params[:id])\n @timeentry.destroy\n\n respond_to do |format|\n format.html { redirect_to timeentries_url }\n format.json { head :no_content }\n end\n end","def destroy\n @time_record.destroy\n respond_to do |format|\n format.html { redirect_to time_records_url, notice: 'Time record was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @clinic_timing = ClinicTiming.find(params[:id])\n @clinic_timing.destroy\n\n respond_to do |format|\n format.html { redirect_to clinic_timings_url }\n format.json { head :no_content }\n end\n end","def destroy\n @drop_route_start_time.destroy\n respond_to do |format|\n format.html { redirect_to drop_route_start_times_url, notice: 'Drop route start time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend","def destroy\n @time_table.destroy\n respond_to do |format|\n format.html { redirect_to time_tables_url, notice: 'Time table was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @downtime_record.destroy\n respond_to do |format|\n format.html { redirect_to downtime_records_url, notice: '成功删除.' }\n format.json { head :no_content }\n end\n end","def destroy\n @timetable_entry.destroy\n respond_to do |format|\n format.html { redirect_to timetable_entries_url }\n format.json { head :no_content }\n end\n end","def destroy\n puts @iot_datum.count\n if @iot_datum.count > 0\n @deleted_rec = IotDatum.new\n @deleted_rec.workbench_number = @iot_datum.workbench_number\n @deleted_rec.part_number = @iot_datum.part_number\n @deleted_rec.target = @iot_datum.target\n @deleted_rec.lot_size = @iot_datum.lot_size\n @deleted_rec.employee_name = @iot_datum.employee_name\n @deleted_rec.shift = @iot_datum.shift\n @deleted_rec.device_id = @iot_datum.device_id\n @deleted_rec.count = @iot_datum.count\n @deleted_rec.status = 'Deleted'\n @deleted_rec.save!\n @iot_datum.destroy\n else\n @iot_datum.destroy\n end\n respond_to do |format|\n format.html { redirect_to iot_data_url, notice: 'Planner was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @timecontroll.destroy\n respond_to do |format|\n format.html { redirect_to timecontrolls_url }\n format.json { head :no_content }\n end\n end","def destroy\n @time_line.destroy\n respond_to do |format|\n format.html { redirect_to time_lines_url, notice: 'Time line was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @doctor_timing = DoctorTiming.find(params[:id])\n @doctor_timing.destroy\n\n respond_to do |format|\n format.html { redirect_to doctor_timings_url }\n format.json { head :no_content }\n end\n end","def destroy\n @timed_task.destroy\n respond_to do |format|\n format.html { redirect_to timed_tasks_url, notice: 'Timed task was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n set_user\n @time_off.destroy\n respond_to do |format|\n format.html { redirect_to user_time_offs_url }\n format.json { head :no_content }\n end\n end","def delete(path)\n RestClient.delete request_base+path\n end","def destroy\n @downtime_type.destroy\n respond_to do |format|\n format.html { redirect_to downtime_types_url, notice: '成功删除.' }\n format.json { head :no_content }\n end\n end","def destroy\n @big_time_entry.destroy\n respond_to do |format|\n format.html { redirect_to big_time_entries_url, notice: 'Big time entry was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @treq = Treq.find(params[:id])\n @treq.destroy\n\n respond_to do |format|\n format.html { redirect_to treqs_url }\n format.json { head :no_content }\n end\n end","def destroy\n @time_task = TimeTask.find(params[:id])\n @time_task.destroy\n\n respond_to do |format|\n format.html { redirect_to(time_tasks_url) }\n format.xml { head :ok }\n end\n end","def destroy\n @now.destroy\n respond_to do |format|\n format.html { redirect_to nows_url, notice: 'Now was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n self.unuse_pto_hours\n @time_off_instance.destroy\n respond_to do |format|\n format.html { redirect_to time_off_instances_url, notice: 'Time off instance was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @beat = Beat.find(params[:id])\n @beat.destroy\n\n respond_to do |format|\n format.html { redirect_to beats_url }\n format.json { head :no_content }\n end\n end","def destroy\n @planned_time = PlannedTime.find(params[:id])\n @planned_time.destroy\n\n respond_to do |format|\n format.html { redirect_to planned_times_url }\n format.json { head :no_content }\n end\n end","def destroy\n @timeslot = current_event.timeslots.find(params[:id])\n @timeslot.destroy\n\n respond_to do |format|\n format.html { redirect_to(timeslots_url) }\n format.xml { head :ok }\n end\n end","def destroy\n @time_block.destroy\n respond_to do |format|\n format.html { redirect_to time_blocks_url, notice: 'Time block was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end","def delete(path, params)\n parse_response @client[path].delete(:params => params)\n end","def destroy\n check_admin\n @time_balance = TimeBalance.find(params[:id])\n @time_balance.destroy\n\n respond_to do |format|\n format.html { redirect_to time_balances_url }\n format.json { head :ok }\n end\n end","def destroy\n @timetable.destroy\n respond_to do |format|\n format.html { redirect_to timetables_url, notice: 'Timetable was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @time_punch.destroy\n respond_to do |format|\n format.html { redirect_to time_punches_url, notice: 'Time punch was successfully destroyed.' }\n format.json { head :no_content }\n end\n end","def destroy\n @receiver_time = ReceiverTime.find(params[:id])\n @receiver_time.destroy\n\n respond_to do |format|\n format.html { redirect_to receiver_times_url }\n format.json { head :no_content }\n end\n end","def destroy\n @work_time = WorkTime.find(params[:id])\n @work_time.destroy\n # after deleting, controller issues a response according to the format given\n respond_to do |format|\n # HTML redirects back to work time index and shows the notice\n format.html { redirect_to api_work_times_path, notice: \"Successfully deleted work time!\" }\n # JSON will just give a deleted response\n format.json { head :no_content }\n # XML will just give a deleted response\n format.xml { head :no_content }\n end\n end","def destroy\n @stay.destroy\n end"],"string":"[\n \"def destroy\\n @time_gap = TimeGap.find(params[:id])\\n @time_gap.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to time_gaps_url }\\n format.json { head :ok }\\n end\\n end\",\n \"def destroy\\n @meal_time = MealTime.find(params[:id])\\n @meal_time.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to meal_times_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @hurdle_time = HurdleTime.find(params[:id])\\n @hurdle_time.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to hurdle_times_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @cooking_time.destroy\\n respond_to do |format|\\n format.html { redirect_to cooking_times_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @downtime.destroy\\n respond_to do |format|\\n format.html { redirect_to downtimes_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @stime.destroy\\n respond_to do |format|\\n format.html { redirect_to stimes_url, notice: 'Stime was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @service_time = ServiceTime.find(params[:id])\\n @service_time.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to service_times_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @nursing_time = NursingTime.find(params[:id])\\n @nursing_time.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to nursing_times_url }\\n format.json { head :ok }\\n end\\n end\",\n \"def destroy\\n @wait_time = WaitTime.find(params[:id])\\n @wait_time.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to wait_times_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @meeting_time.destroy\\n respond_to do |format|\\n format.html { redirect_to meeting_times_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @time_clock.destroy\\n respond_to do |format|\\n format.html { redirect_to time_sheet_index_path }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @my_time_trial = MyTimeTrial.find(params[:id])\\n @my_time_trial.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to my_time_trials_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @daytime = Daytime.find(params[:id])\\n @daytime.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to daytimes_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @location_time.destroy\\n respond_to do |format|\\n format.html { redirect_to location_times_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @time_of_day.destroy\\n respond_to do |format|\\n format.html { redirect_to time_of_days_url, notice: 'Time of day was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @where_to_stay = WhereToStay.find(params[:id])\\n @where_to_stay.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to where_to_stays_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @allocated_time.destroy\\n respond_to do |format|\\n format.html { redirect_to allocated_times_url, notice: 'Allocated time was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @time_off_request = TimeOffRequest.find(params[:id])\\n @time_off_request.destroy\\n \\n respond_to do |format|\\n format.html { redirect_to admin_time_off_requests_url}\\n format.json { head :ok }\\n end\\n end\",\n \"def destroy\\n @stay_night.destroy\\n respond_to do |format|\\n format.html { redirect_to stay_nights_url }\\n format.json { head :no_content }\\n format.js\\n end\\n end\",\n \"def destroy\\n @one_time_stop = OneTimeStop.find(params[:id])\\n @one_time_stop.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to one_time_stops_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @working_start_time.destroy\\n respond_to do |format|\\n format.html { redirect_to working_start_times_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @day_timeslot.destroy\\n respond_to do |format|\\n format.html { redirect_to day_timeslots_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @stop_time = StopTime.find(params[:id])\\n @stop_time.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to stop_times_url }\\n format.json { head :ok }\\n end\\n end\",\n \"def destroy\\n @order_break_time.destroy\\n respond_to do |format|\\n format.html { redirect_to order_break_times_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @disatance_and_time.destroy\\n respond_to do |format|\\n format.html { redirect_to disatance_and_times_url, notice: 'Disatance and time was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @poi_time.destroy\\n respond_to do |format|\\n format.html { redirect_to poi_times_url, notice: 'Poi time was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @cal_time.destroy\\n respond_to do |format|\\n format.html { redirect_to cal_times_url, notice: 'Cal time was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @time_entry = TimeEntry.with_deleted.find(params[:id])\\n @time_entry.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to time_entries_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @time_trial.destroy\\n respond_to do |format|\\n format.html { redirect_to '/admin', notice: 'Time trial was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @time_entry = current_firm.all_time_entries.find(params[:id])\\n @time_entry.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to params[:ret] || firm_time_entries_path(current_firm) }\\n format.json { head :ok }\\n end\\n end\",\n \"def destroy\\n @time_log = TimeLog.find(params[:id])\\n @time_log.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to time_logs_url }\\n format.json { head :ok }\\n end\\n end\",\n \"def deleteEntityOpening_times( entity_id)\\n params = Hash.new\\n params['entity_id'] = entity_id\\n return doCurl(\\\"delete\\\",\\\"/entity/opening_times\\\",params)\\n end\",\n \"def destroy\\n @hotel_stay = HotelStay.find(params[:id])\\n @hotel_stay.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to hotel_stays_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @working_time = WorkingTime.find(params[:id])\\n @working_time.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to time_tables_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @time_slot = TimeSlot.find(params[:id])\\n @time_slot.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to time_slots_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def delete\\n client.delete(\\\"/#{id}\\\")\\n end\",\n \"def destroy\\n @wait_time.destroy\\n respond_to do |format|\\n format.html { redirect_to wait_times_url, notice: 'Wait time was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @class_time.destroy\\n respond_to do |format|\\n format.html { redirect_to class_times_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @planning_time = PlanningTime.find(params[:id])\\n @planning_time.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to planning_times_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @time_entry = TimeEntry.find(params[:id])\\n @time_entry.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to time_entries_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @time_entry = TimeEntry.find(params[:id])\\n @time_entry.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to time_entries_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @timeslot.destroy\\n respond_to do |format|\\n format.html { redirect_to timeslots_url, notice: 'Timeslot was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @member_time = MemberTime.find(params[:id])\\n @member_time.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to member_times_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @titletime.destroy\\n respond_to do |format|\\n format.html { redirect_to titletimes_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @showtime.destroy\\n respond_to do |format|\\n format.html { redirect_to showtimes_url, notice: \\\"Showtime was successfully destroyed.\\\" }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @time_entry.destroy\\n respond_to do |format|\\n format.html { redirect_to time_entries_url, notice: 'Time entry was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @timetable = Timetable.find(params[:id])\\n @timetable.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to timetables_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @tombstone_timehold.destroy\\n respond_to do |format|\\n format.html { redirect_to tombstone_timeholds_url, notice: 'Tombstone timehold was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @time_period.destroy\\n format.json { head :no_content }\\n end\",\n \"def destroy\\n @section_time.destroy\\n respond_to do |format|\\n format.html { redirect_to section_times_url, notice: 'Section time was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @p_time.destroy\\n respond_to do |format|\\n format.html { redirect_to p_times_url, notice: 'P time was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n #Uncomment this if for some reason users should be able to delete TTs\\n #@tea_time.destroy\\n respond_to do |format|\\n format.html { render text: \\\"I can't let you do that, #{current_user.name}\\\" }\\n format.json { head 403 }\\n end\\n end\",\n \"def destroy\\n @selected_time.destroy\\n respond_to do |format|\\n format.html { redirect_to selected_times_url, notice: 'Selected time was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @offset_time = OffsetTime.find(params[:id])\\n @offset_time.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to offset_times_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @time_section = TimeSection.find(params[:id])\\n @time_section.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to time_sections_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n return if new_record?\\n \\n @api.delete \\\"/meetings/#{shortcode_url}.json\\\"\\n end\",\n \"def destroy\\n\\n if @teetime.destroy\\n\\n render json: {teetime: {id: params[:id].to_i}},status: :ok\\n\\n else\\n\\n render json: {error: true,errors: @teetime.errors},status: :unprocessable_entity\\n\\n end\\n\\n \\t\\tend\",\n \"def destroy\\n @timelog.destroy\\n respond_to do |format|\\n format.html { redirect_to timelogs_url, notice: 'Timelog was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @time_slots_list.destroy\\n respond_to do |format|\\n format.html { redirect_to time_slots_lists_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @mealtime.destroy\\n respond_to do |format|\\n format.html { redirect_to mealtimes_url, notice: 'Mealtime was successfully destroyed.' }\\n end\\n end\",\n \"def destroy\\n @work_time.destroy\\n respond_to do |format|\\n format.html { redirect_to work_times_url, notice: 'Work time was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @appointment.destroy\\n head 204\\n end\",\n \"def delete path\\n make_request(path, \\\"delete\\\", {})\\n end\",\n \"def destroy\\n @time_record = TimeRecord.find(params[:id])\\n @time_record.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to time_records_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @time_record = TimeRecord.find(params[:id])\\n @time_record.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to time_records_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @time_slot.destroy\\n respond_to do |format|\\n format.html { redirect_to time_slots_url, notice: 'Time slot was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @time_visitor = TimeVisitor.find(params[:id])\\n @time_visitor.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to tour_visitor_time_visitors_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @timeentry = Timeentry.find(params[:id])\\n @timeentry.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to timeentries_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @time_record.destroy\\n respond_to do |format|\\n format.html { redirect_to time_records_url, notice: 'Time record was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @clinic_timing = ClinicTiming.find(params[:id])\\n @clinic_timing.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to clinic_timings_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @drop_route_start_time.destroy\\n respond_to do |format|\\n format.html { redirect_to drop_route_start_times_url, notice: 'Drop route start time was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def delete_tenant_circle(args = {}) \\n delete(\\\"/tenantcircles.json/#{args[:circleId]}\\\", args)\\nend\",\n \"def destroy\\n @time_table.destroy\\n respond_to do |format|\\n format.html { redirect_to time_tables_url, notice: 'Time table was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @downtime_record.destroy\\n respond_to do |format|\\n format.html { redirect_to downtime_records_url, notice: '成功删除.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @timetable_entry.destroy\\n respond_to do |format|\\n format.html { redirect_to timetable_entries_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n puts @iot_datum.count\\n if @iot_datum.count > 0\\n @deleted_rec = IotDatum.new\\n @deleted_rec.workbench_number = @iot_datum.workbench_number\\n @deleted_rec.part_number = @iot_datum.part_number\\n @deleted_rec.target = @iot_datum.target\\n @deleted_rec.lot_size = @iot_datum.lot_size\\n @deleted_rec.employee_name = @iot_datum.employee_name\\n @deleted_rec.shift = @iot_datum.shift\\n @deleted_rec.device_id = @iot_datum.device_id\\n @deleted_rec.count = @iot_datum.count\\n @deleted_rec.status = 'Deleted'\\n @deleted_rec.save!\\n @iot_datum.destroy\\n else\\n @iot_datum.destroy\\n end\\n respond_to do |format|\\n format.html { redirect_to iot_data_url, notice: 'Planner was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @timecontroll.destroy\\n respond_to do |format|\\n format.html { redirect_to timecontrolls_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @time_line.destroy\\n respond_to do |format|\\n format.html { redirect_to time_lines_url, notice: 'Time line was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @doctor_timing = DoctorTiming.find(params[:id])\\n @doctor_timing.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to doctor_timings_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @timed_task.destroy\\n respond_to do |format|\\n format.html { redirect_to timed_tasks_url, notice: 'Timed task was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n set_user\\n @time_off.destroy\\n respond_to do |format|\\n format.html { redirect_to user_time_offs_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def delete(path)\\n RestClient.delete request_base+path\\n end\",\n \"def destroy\\n @downtime_type.destroy\\n respond_to do |format|\\n format.html { redirect_to downtime_types_url, notice: '成功删除.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @big_time_entry.destroy\\n respond_to do |format|\\n format.html { redirect_to big_time_entries_url, notice: 'Big time entry was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @treq = Treq.find(params[:id])\\n @treq.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to treqs_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @time_task = TimeTask.find(params[:id])\\n @time_task.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to(time_tasks_url) }\\n format.xml { head :ok }\\n end\\n end\",\n \"def destroy\\n @now.destroy\\n respond_to do |format|\\n format.html { redirect_to nows_url, notice: 'Now was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n self.unuse_pto_hours\\n @time_off_instance.destroy\\n respond_to do |format|\\n format.html { redirect_to time_off_instances_url, notice: 'Time off instance was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @beat = Beat.find(params[:id])\\n @beat.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to beats_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @planned_time = PlannedTime.find(params[:id])\\n @planned_time.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to planned_times_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @timeslot = current_event.timeslots.find(params[:id])\\n @timeslot.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to(timeslots_url) }\\n format.xml { head :ok }\\n end\\n end\",\n \"def destroy\\n @time_block.destroy\\n respond_to do |format|\\n format.html { redirect_to time_blocks_url, notice: 'Time block was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def delete_json(path)\\n url = [base_url, path].join\\n resp = HTTParty.delete(url, headers: standard_headers)\\n parse_json(url, resp)\\n end\",\n \"def delete(path, params)\\n parse_response @client[path].delete(:params => params)\\n end\",\n \"def destroy\\n check_admin\\n @time_balance = TimeBalance.find(params[:id])\\n @time_balance.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to time_balances_url }\\n format.json { head :ok }\\n end\\n end\",\n \"def destroy\\n @timetable.destroy\\n respond_to do |format|\\n format.html { redirect_to timetables_url, notice: 'Timetable was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @time_punch.destroy\\n respond_to do |format|\\n format.html { redirect_to time_punches_url, notice: 'Time punch was successfully destroyed.' }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @receiver_time = ReceiverTime.find(params[:id])\\n @receiver_time.destroy\\n\\n respond_to do |format|\\n format.html { redirect_to receiver_times_url }\\n format.json { head :no_content }\\n end\\n end\",\n \"def destroy\\n @work_time = WorkTime.find(params[:id])\\n @work_time.destroy\\n # after deleting, controller issues a response according to the format given\\n respond_to do |format|\\n # HTML redirects back to work time index and shows the notice\\n format.html { redirect_to api_work_times_path, notice: \\\"Successfully deleted work time!\\\" }\\n # JSON will just give a deleted response\\n format.json { head :no_content }\\n # XML will just give a deleted response\\n format.xml { head :no_content }\\n end\\n end\",\n \"def destroy\\n @stay.destroy\\n end\"\n]"},"negative_scores":{"kind":"list like","value":["0.7226604","0.69612134","0.6939054","0.6817791","0.681168","0.6803863","0.67897755","0.6786757","0.6783543","0.6771888","0.6769168","0.6741878","0.67337954","0.6730354","0.66895","0.6688952","0.6681023","0.66767806","0.66705346","0.6667793","0.66658086","0.66479504","0.66271615","0.66242707","0.6619212","0.6610823","0.6597983","0.6596513","0.6596408","0.6595423","0.6592631","0.6590447","0.6575402","0.6575282","0.65720695","0.656644","0.655881","0.65538365","0.6537909","0.6529713","0.6529713","0.65233874","0.6519638","0.65126234","0.65110797","0.65105844","0.65102386","0.6488335","0.64779884","0.64761925","0.6475635","0.64744455","0.64710516","0.64661807","0.6463887","0.6463216","0.64594096","0.6455315","0.64522165","0.6441454","0.64411396","0.6439136","0.6432285","0.64310557","0.64310557","0.6429203","0.6423224","0.6421499","0.6415421","0.64136106","0.6411741","0.6411016","0.64040124","0.63996327","0.6398035","0.6385433","0.63786983","0.63774335","0.6377047","0.63747513","0.63697886","0.6368996","0.63660955","0.6359253","0.63572097","0.63535446","0.6352894","0.6351936","0.63496035","0.63473177","0.63468695","0.63467634","0.6345951","0.6341486","0.6339213","0.633783","0.633613","0.6333864","0.6327428","0.63249385"],"string":"[\n \"0.7226604\",\n \"0.69612134\",\n \"0.6939054\",\n \"0.6817791\",\n \"0.681168\",\n \"0.6803863\",\n \"0.67897755\",\n \"0.6786757\",\n \"0.6783543\",\n \"0.6771888\",\n \"0.6769168\",\n \"0.6741878\",\n \"0.67337954\",\n \"0.6730354\",\n \"0.66895\",\n \"0.6688952\",\n \"0.6681023\",\n \"0.66767806\",\n \"0.66705346\",\n \"0.6667793\",\n \"0.66658086\",\n \"0.66479504\",\n \"0.66271615\",\n \"0.66242707\",\n \"0.6619212\",\n \"0.6610823\",\n \"0.6597983\",\n \"0.6596513\",\n \"0.6596408\",\n \"0.6595423\",\n \"0.6592631\",\n \"0.6590447\",\n \"0.6575402\",\n \"0.6575282\",\n \"0.65720695\",\n \"0.656644\",\n \"0.655881\",\n \"0.65538365\",\n \"0.6537909\",\n \"0.6529713\",\n \"0.6529713\",\n \"0.65233874\",\n \"0.6519638\",\n \"0.65126234\",\n \"0.65110797\",\n \"0.65105844\",\n \"0.65102386\",\n \"0.6488335\",\n \"0.64779884\",\n \"0.64761925\",\n \"0.6475635\",\n \"0.64744455\",\n \"0.64710516\",\n \"0.64661807\",\n \"0.6463887\",\n \"0.6463216\",\n \"0.64594096\",\n \"0.6455315\",\n \"0.64522165\",\n \"0.6441454\",\n \"0.64411396\",\n \"0.6439136\",\n \"0.6432285\",\n \"0.64310557\",\n \"0.64310557\",\n \"0.6429203\",\n \"0.6423224\",\n \"0.6421499\",\n \"0.6415421\",\n \"0.64136106\",\n \"0.6411741\",\n \"0.6411016\",\n \"0.64040124\",\n \"0.63996327\",\n \"0.6398035\",\n \"0.6385433\",\n \"0.63786983\",\n \"0.63774335\",\n \"0.6377047\",\n \"0.63747513\",\n \"0.63697886\",\n \"0.6368996\",\n \"0.63660955\",\n \"0.6359253\",\n \"0.63572097\",\n \"0.63535446\",\n \"0.6352894\",\n \"0.6351936\",\n \"0.63496035\",\n \"0.63473177\",\n \"0.63468695\",\n \"0.63467634\",\n \"0.6345951\",\n \"0.6341486\",\n \"0.6339213\",\n \"0.633783\",\n \"0.633613\",\n \"0.6333864\",\n \"0.6327428\",\n \"0.63249385\"\n]"},"document_score":{"kind":"string","value":"0.74384403"},"document_rank":{"kind":"string","value":"0"}}},{"rowIdx":130,"cells":{"query":{"kind":"string","value":"Use callbacks to share common setup or constraints between actions."},"document":{"kind":"string","value":"def set_stay_time\n @stay_time = StayTime.find(params[:id])\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def set_required_actions\n # TODO: check what fields change to asign required fields\n end","def action_hook; end","def run_actions; end","def define_action_hook; end","def actions; end","def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end","def add_actions; end","def callbacks; end","def callbacks; end","def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end","def define_action_helpers; end","def post_setup\n end","def action_methods; end","def action_methods; end","def action_methods; end","def before_setup; end","def action_run\n end","def execute(setup)\n @action.call(setup)\n end","def define_action_helpers?; end","def set_actions\n actions :all\n end","def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end","def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end","def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end","def before_actions(*logic)\n self.before_actions = logic\n end","def setup_handler\n end","def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end","def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end","def action; end","def action; end","def action; end","def action; end","def action; end","def workflow\n end","def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end","def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end","def before(action)\n invoke_callbacks *self.class.send(action).before\n end","def process_action(...)\n send_action(...)\n end","def before_dispatch(env); end","def after_actions(*logic)\n self.after_actions = logic\n end","def setup\n # override and do something appropriate\n end","def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end","def setup(_context)\n end","def setup(resources) ; end","def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end","def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end","def determine_valid_action\n\n end","def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end","def startcompany(action)\n @done = true\n action.setup\n end","def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end","def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end","def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end","def define_tasks\n define_weave_task\n connect_common_tasks\n end","def setup(&block)\n define_method(:setup, &block)\n end","def setup\n transition_to(:setup)\n end","def setup\n transition_to(:setup)\n end","def action\n end","def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend","def config(action, *args); end","def setup\n @setup_proc.call(self) if @setup_proc\n end","def before_action \n end","def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end","def action\n end","def matt_custom_action_begin(label); end","def setup\n # override this if needed\n end","def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend","def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend","def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end","def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end","def after(action)\n invoke_callbacks *options_for(action).after\n end","def pre_task\n end","def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end","def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end","def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end","def setup_signals; end","def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend","def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend","def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end","def initialize(*args)\n super\n @action = :set\nend","def after_set_callback; end","def setup\n #implement in subclass;\n end","def lookup_action; end","def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end","def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end","def release_actions; end","def around_hooks; end","def save_action; end","def setup(easy)\n super\n easy.customrequest = @verb\n end","def action_target()\n \n end","def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end","def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end","def before_setup\n # do nothing by default\n end","def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end","def default_action; end","def setup(&blk)\n @setup_block = blk\n end","def callback_phase\n super\n end","def advice\n end","def _handle_action_missing(*args); end","def duas1(action)\n action.call\n action.call\nend","def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end","def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end","def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"],"string":"[\n \"def set_required_actions\\n # TODO: check what fields change to asign required fields\\n end\",\n \"def action_hook; end\",\n \"def run_actions; end\",\n \"def define_action_hook; end\",\n \"def actions; end\",\n \"def define_action_helpers\\n if super && action == :save\\n @instance_helper_module.class_eval do\\n define_method(:valid?) do |*args|\\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\\n end\\n end\\n end\\n end\",\n \"def add_actions; end\",\n \"def callbacks; end\",\n \"def callbacks; end\",\n \"def setup *actions, &proc\\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\\n end\",\n \"def define_action_helpers; end\",\n \"def post_setup\\n end\",\n \"def action_methods; end\",\n \"def action_methods; end\",\n \"def action_methods; end\",\n \"def before_setup; end\",\n \"def action_run\\n end\",\n \"def execute(setup)\\n @action.call(setup)\\n end\",\n \"def define_action_helpers?; end\",\n \"def set_actions\\n actions :all\\n end\",\n \"def action_done(action)\\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\\n :done_reducing, :finalize => :done_finalizing } \\n self.send dispatch[action[:action]], action\\n end\",\n \"def dependencies action, &block\\n @actions.each do |other|\\n if action[:requires].include? other[:provide]\\n block.call other\\n end\\n end\\n end\",\n \"def setup!\\n return unless @setup_procs\\n http_actions = actions\\n @setup_procs.each do |setup_proc|\\n proc, actions = setup_proc\\n @setup__actions = actions.map do |action|\\n\\n action.is_a?(Regexp) ?\\n http_actions.select { |a| a.to_s =~ action } :\\n action.is_a?(String) && action =~ /\\\\A\\\\./ ?\\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\\n action\\n\\n end.flatten\\n self.class_exec &proc\\n @setup__actions = nil\\n end\\n @setup_procs = nil\\n end\",\n \"def before_actions(*logic)\\n self.before_actions = logic\\n end\",\n \"def setup_handler\\n end\",\n \"def set_action(opts)\\n opts = check_params(opts,[:actions])\\n super(opts)\\n end\",\n \"def setup(action)\\n @targets.clear\\n unless action.item.target_filters.empty?\\n @targets = SES::TargetManager.make_targets(action)\\n else\\n item = action.item\\n if item.for_opponent?\\n @targets = $game_troop.alive_members\\n elsif item.for_dead_friend?\\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\\n else\\n $game_party.battle_members.select { |actor| actor.alive? }\\n end\\n end\\n @item_max = @targets.size\\n create_contents\\n refresh\\n show\\n activate\\n end\",\n \"def action; end\",\n \"def action; end\",\n \"def action; end\",\n \"def action; end\",\n \"def action; end\",\n \"def workflow\\n end\",\n \"def revisable_shared_setup(args, block)\\n class << self\\n attr_accessor :revisable_options\\n end\\n options = args.extract_options!\\n self.revisable_options = Options.new(options, &block)\\n \\n self.send(:include, Common)\\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\\n self.send(:include, WithoutScope::QuotedColumnConditions)\\n end\",\n \"def setup\\n @action = SampleActionAndroid.new(os_name: 'android',\\n app_name: APP_PATH)\\n end\",\n \"def before(action)\\n invoke_callbacks *self.class.send(action).before\\n end\",\n \"def process_action(...)\\n send_action(...)\\n end\",\n \"def before_dispatch(env); end\",\n \"def after_actions(*logic)\\n self.after_actions = logic\\n end\",\n \"def setup\\n # override and do something appropriate\\n end\",\n \"def setup(client)\\n return unless @setup\\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\\n actions.each do |action|\\n action.execute(client)\\n end\\n self\\n end\",\n \"def setup(_context)\\n end\",\n \"def setup(resources) ; end\",\n \"def validate_actions\\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\\n end\",\n \"def setup\\n @resource_config = {\\n :callbacks => {\\n :before_create => nil,\\n :after_create => nil,\\n :before_update => nil,\\n :after_update => nil,\\n :before_destroy => nil,\\n :after_destroy => nil,\\n },\\n :child_assoc => nil,\\n :model => nil,\\n :parent => nil,\\n :path => nil,\\n :permission => {},\\n :properties => {},\\n :relation => {\\n :create => nil,\\n :delete => nil,\\n },\\n :roles => nil,\\n }\\n end\",\n \"def determine_valid_action\\n\\n end\",\n \"def process_shared\\n handle_taxes\\n handle_shippings\\n create_adjustments_from_params\\n handle_status\\n handle_inventory_refunds\\n handle_payment_transactions\\n order.updater.update\\n end\",\n \"def startcompany(action)\\n @done = true\\n action.setup\\n end\",\n \"def init_actions\\n am = action_manager()\\n am.add_action(Action.new(\\\"&Disable selection\\\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\\n am.add_action(Action.new(\\\"&Edit Toggle\\\") { @edit_toggle = !@edit_toggle; $status_message.value = \\\"Edit toggle is #{@edit_toggle}\\\" })\\n end\",\n \"def event_callbacks(event, metadata={})\\n case event\\n when :reset, :review\\n if confirmed\\n update_attributes(confirmed: false)\\n end\\n when :confirm\\n confirm\\n # trigger :order for all applicable items\\n # NOTE: :order event is common to both physical and digital items\\n items.each do |i|\\n if i.event_permitted(:order)\\n user_id = last_transition.user_id\\n i.trigger!(:order, { order_id: id, user_id: user_id })\\n end\\n end\\n when :complete_work\\n request = metadata[:request]\\n work_complete_notification(request)\\n when :close\\n close\\n end\\n if event != :close && !open\\n reopen\\n end\\n end\",\n \"def setup_action\\n return unless PONY::ERRNO::check_sequence(current_act)\\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\\n @sequence_index = 0\\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\\n execute_sequence\\n end\",\n \"def define_tasks\\n define_weave_task\\n connect_common_tasks\\n end\",\n \"def setup(&block)\\n define_method(:setup, &block)\\n end\",\n \"def setup\\n transition_to(:setup)\\n end\",\n \"def setup\\n transition_to(:setup)\\n end\",\n \"def action\\n end\",\n \"def setup( *args )\\n\\t\\t\\tself.class.setupBlocks.each {|sblock|\\n\\t\\t\\t\\tdebugMsg \\\"Calling setup block method #{sblock}\\\"\\n\\t\\t\\t\\tself.send( sblock )\\n\\t\\t\\t}\\n\\t\\t\\tsuper( *args )\\n\\t\\tend\",\n \"def config(action, *args); end\",\n \"def setup\\n @setup_proc.call(self) if @setup_proc\\n end\",\n \"def before_action \\n end\",\n \"def setup_callbacks\\n defined_callbacks.each do |meth|\\n unless respond_to?(\\\"call_#{meth}_callbacks\\\".to_sym)\\n self.class.module_eval <<-EOE\\n def call_#{meth}_callbacks(*args)\\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\\n self.send :#{meth}, *args if respond_to?(:#{meth})\\n end\\n EOE\\n end\\n end\\n end\",\n \"def action\\n end\",\n \"def matt_custom_action_begin(label); end\",\n \"def setup\\n # override this if needed\\n end\",\n \"def setup\\n\\t\\t\\t\\t\\t\\t# Do nothing\\n\\t\\t\\t\\tend\",\n \"def setup\\n\\t\\t\\t\\t\\t\\t# Do nothing\\n\\t\\t\\t\\tend\",\n \"def action(options,&callback)\\n new_action = Action===options ? options : Action.new(options,&callback)\\n # replace any with (shared name/alias or both default) + same arity\\n @actions.delete_if do |existing_action|\\n ((existing_action.names & new_action.names).size > 0 ||\\n existing_action.default? && new_action.default?) &&\\n existing_action.required.size == new_action.required.size &&\\n existing_action.optional.size <= new_action.optional.size\\n end\\n @actions = (@actions + [new_action]).sort\\n new_action\\n end\",\n \"def set_target_and_action target, action\\n self.target = target\\n self.action = 'sugarcube_handle_action:'\\n @sugarcube_action = action\\n end\",\n \"def after(action)\\n invoke_callbacks *options_for(action).after\\n end\",\n \"def pre_task\\n end\",\n \"def setup(server)\\n server.on('beforeMethod', method(:before_method), 10)\\n end\",\n \"def add_actions\\n attribute = machine.attribute\\n name = self.name\\n \\n owner_class.class_eval do\\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\\n define_method(\\\"#{name}!\\\") {self.class.state_machines[attribute].events[name].fire!(self)}\\n define_method(\\\"can_#{name}?\\\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\\n end\\n end\",\n \"def init_actions\\n @select_action = SelectAction.new\\n @endpoint_mouse_action = EndpointMouseAction.new\\n @move_action = MoveAction.new\\n end\",\n \"def setup_signals; end\",\n \"def after_created\\r\\n return unless compile_time\\r\\n Array(action).each do |action|\\r\\n run_action(action)\\r\\n end\\r\\nend\",\n \"def after_created\\r\\n return unless compile_time\\r\\n Array(action).each do |action|\\r\\n run_action(action)\\r\\n end\\r\\nend\",\n \"def set_target_and_action target, action\\n self.target = target\\n self.action = 'sugarcube_handle_action:'\\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\\n end\",\n \"def initialize(*args)\\n super\\n @action = :set\\nend\",\n \"def after_set_callback; end\",\n \"def setup\\n #implement in subclass;\\n end\",\n \"def lookup_action; end\",\n \"def setup &block\\n if block_given?\\n @setup = block\\n else\\n @setup.call\\n end\\n end\",\n \"def setup_action\\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\\n actions = TSBS::AnimLoop[@acts[1]]\\n if actions.nil?\\n show_action_error(@acts[1])\\n end\\n @sequence_stack.push(@acts[1])\\n @used_sequence = @acts[1]\\n actions.each do |acts|\\n @acts = acts\\n execute_sequence\\n break if @break_action\\n end\\n @sequence_stack.pop\\n @used_sequence = @sequence_stack[-1]\\n end\",\n \"def release_actions; end\",\n \"def around_hooks; end\",\n \"def save_action; end\",\n \"def setup(easy)\\n super\\n easy.customrequest = @verb\\n end\",\n \"def action_target()\\n \\n end\",\n \"def setup\\n callback(:setup) do\\n notify(:setup)\\n migration_check.last_deployed_commit\\n end\\n end\",\n \"def setup\\n return unless @setup\\n\\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\\n run_actions_and_retry(actions)\\n self\\n end\",\n \"def before_setup\\n # do nothing by default\\n end\",\n \"def my_actions(options)\\n @setup = false\\n get_template_part(\\\"custom_used\\\",\\\"action_users\\\",true)\\n end\",\n \"def default_action; end\",\n \"def setup(&blk)\\n @setup_block = blk\\n end\",\n \"def callback_phase\\n super\\n end\",\n \"def advice\\n end\",\n \"def _handle_action_missing(*args); end\",\n \"def duas1(action)\\n action.call\\n action.call\\nend\",\n \"def shared_action(name, &block)\\n @controller.shared_actions[name] = block\\n end\",\n \"def before_action action, &block\\n @audience[:before][action] ||= Set.new\\n @audience[:before][action] << block\\n end\",\n \"def setup_initial_state\\n\\n state_a = State.new(\\\"a\\\", 0)\\n state_b = State.new(\\\"b\\\", 0)\\n state_c = State.new(\\\"c\\\", 10)\\n\\n move_to_b = Action.new(\\\"move_to_b\\\", 1, state_b)\\n\\n move_to_c = Action.new(\\\"move_to_c\\\", 1, state_c)\\n\\n state_a.actions = [move_to_b, move_to_c]\\n\\n return state_a\\n \\nend\"\n]"},"negative_scores":{"kind":"list like","value":["0.6163163","0.6045976","0.5946146","0.591683","0.5890051","0.58349305","0.5776858","0.5703237","0.5703237","0.5652805","0.5621621","0.54210985","0.5411113","0.5411113","0.5411113","0.5391541","0.53794575","0.5357573","0.53402257","0.53394014","0.53321576","0.53124547","0.529654","0.5296262","0.52952296","0.52600986","0.52442724","0.52385926","0.52385926","0.52385926","0.52385926","0.52385926","0.5232394","0.523231","0.5227454","0.52226824","0.52201617","0.5212327","0.52079266","0.52050185","0.51754695","0.51726824","0.51710224","0.5166172","0.5159343","0.51578903","0.51522785","0.5152022","0.51518047","0.51456624","0.51398855","0.5133759","0.5112076","0.5111866","0.5111866","0.5110294","0.5106169","0.509231","0.50873137","0.5081088","0.508059","0.50677156","0.50562143","0.5050554","0.50474834","0.50474834","0.5036181","0.5026331","0.5022976","0.5015441","0.50121695","0.5000944","0.5000019","0.4996878","0.4989888","0.4989888","0.49864885","0.49797225","0.49785787","0.4976161","0.49683493","0.4965126","0.4958034","0.49559742","0.4954353","0.49535993","0.4952725","0.49467874","0.49423352","0.49325448","0.49282882","0.49269363","0.49269104","0.49252945","0.4923091","0.49194667","0.49174926","0.49173003","0.49171105","0.4915879","0.49155936"],"string":"[\n \"0.6163163\",\n \"0.6045976\",\n \"0.5946146\",\n \"0.591683\",\n \"0.5890051\",\n \"0.58349305\",\n \"0.5776858\",\n \"0.5703237\",\n \"0.5703237\",\n \"0.5652805\",\n \"0.5621621\",\n \"0.54210985\",\n \"0.5411113\",\n \"0.5411113\",\n \"0.5411113\",\n \"0.5391541\",\n \"0.53794575\",\n \"0.5357573\",\n \"0.53402257\",\n \"0.53394014\",\n \"0.53321576\",\n \"0.53124547\",\n \"0.529654\",\n \"0.5296262\",\n \"0.52952296\",\n \"0.52600986\",\n \"0.52442724\",\n \"0.52385926\",\n \"0.52385926\",\n \"0.52385926\",\n \"0.52385926\",\n \"0.52385926\",\n \"0.5232394\",\n \"0.523231\",\n \"0.5227454\",\n \"0.52226824\",\n \"0.52201617\",\n \"0.5212327\",\n \"0.52079266\",\n \"0.52050185\",\n \"0.51754695\",\n \"0.51726824\",\n \"0.51710224\",\n \"0.5166172\",\n \"0.5159343\",\n \"0.51578903\",\n \"0.51522785\",\n \"0.5152022\",\n \"0.51518047\",\n \"0.51456624\",\n \"0.51398855\",\n \"0.5133759\",\n \"0.5112076\",\n \"0.5111866\",\n \"0.5111866\",\n \"0.5110294\",\n \"0.5106169\",\n \"0.509231\",\n \"0.50873137\",\n \"0.5081088\",\n \"0.508059\",\n \"0.50677156\",\n \"0.50562143\",\n \"0.5050554\",\n \"0.50474834\",\n \"0.50474834\",\n \"0.5036181\",\n \"0.5026331\",\n \"0.5022976\",\n \"0.5015441\",\n \"0.50121695\",\n \"0.5000944\",\n \"0.5000019\",\n \"0.4996878\",\n \"0.4989888\",\n \"0.4989888\",\n \"0.49864885\",\n \"0.49797225\",\n \"0.49785787\",\n \"0.4976161\",\n \"0.49683493\",\n \"0.4965126\",\n \"0.4958034\",\n \"0.49559742\",\n \"0.4954353\",\n \"0.49535993\",\n \"0.4952725\",\n \"0.49467874\",\n \"0.49423352\",\n \"0.49325448\",\n \"0.49282882\",\n \"0.49269363\",\n \"0.49269104\",\n \"0.49252945\",\n \"0.4923091\",\n \"0.49194667\",\n \"0.49174926\",\n \"0.49173003\",\n \"0.49171105\",\n \"0.4915879\",\n \"0.49155936\"\n]"},"document_score":{"kind":"string","value":"0.0"},"document_rank":{"kind":"string","value":"-1"}}},{"rowIdx":131,"cells":{"query":{"kind":"string","value":"Never trust parameters from the scary internet, only allow the white list through."},"document":{"kind":"string","value":"def stay_time_params\n params.require(:stay_time).permit(:arrive_date, :leave_date, :nationality, :country_stay, :day_stay)\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def strong_params\n params.require(:user).permit(param_whitelist)\n end","def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end","def allow_params_authentication!; end","def allowed_params\n ALLOWED_PARAMS\n end","def default_param_whitelist\n [\"mode\"]\n end","def param_whitelist\n [:role, :title]\n end","def expected_permitted_parameter_names; end","def safe_params\n params.except(:host, :port, :protocol).permit!\n end","def strong_params\n params.require(:team_member).permit(param_whitelist)\n end","def permitir_parametros\n \t\tparams.permit!\n \tend","def strong_params\n params.require(:community).permit(param_whitelist)\n end","def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end","def strong_params\n params.require(:education).permit(param_whitelist)\n end","def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end","def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end","def param_whitelist\n [:rating, :review]\n end","def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end","def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end","def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end","def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end","def valid_params_request?; end","def strong_params\n params.require(:experience).permit(param_whitelist)\n end","def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end","def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end","def allowed_params\n params.require(:allowed).permit(:email)\n end","def permitted_params\n []\n end","def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end","def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end","def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend","def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end","def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end","def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end","def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end","def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end","def safe_params\n params.require(:user).permit(:name)\n end","def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend","def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end","def check_params; true; end","def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end","def quote_params\n params.permit!\n end","def valid_params?; end","def paramunold_params\n params.require(:paramunold).permit!\n end","def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend","def filtered_parameters; end","def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end","def filtering_params\n params.permit(:email, :name)\n end","def check_params\n true\n end","def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end","def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end","def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end","def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend","def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend","def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end","def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end","def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end","def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend","def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end","def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end","def active_code_params\n params[:active_code].permit\n end","def filtering_params\n params.permit(:email)\n end","def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end","def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end","def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end","def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end","def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end","def list_params\n params.permit(:name)\n end","def filter_parameters; end","def filter_parameters; end","def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end","def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end","def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end","def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end","def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end","def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end","def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end","def url_whitelist; end","def admin_social_network_params\n params.require(:social_network).permit!\n end","def filter_params\n params.require(:filters).permit(:letters)\n end","def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end","def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end","def sensitive_params=(params)\n @sensitive_params = params\n end","def permit_request_params\n params.permit(:address)\n end","def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end","def secure_params\n params.require(:location).permit(:name)\n end","def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end","def question_params\n params.require(:survey_question).permit(question_whitelist)\n end","def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end","def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end","def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end","def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end","def url_params\n params[:url].permit(:full)\n end","def backend_user_params\n params.permit!\n end","def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend","def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end","def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end","def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end","def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end","def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end","def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end","def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end","def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"],"string":"[\n \"def strong_params\\n params.require(:user).permit(param_whitelist)\\n end\",\n \"def strong_params\\n params.require(:listing_member).permit(param_whitelist)\\n end\",\n \"def allow_params_authentication!; end\",\n \"def allowed_params\\n ALLOWED_PARAMS\\n end\",\n \"def default_param_whitelist\\n [\\\"mode\\\"]\\n end\",\n \"def param_whitelist\\n [:role, :title]\\n end\",\n \"def expected_permitted_parameter_names; end\",\n \"def safe_params\\n params.except(:host, :port, :protocol).permit!\\n end\",\n \"def strong_params\\n params.require(:team_member).permit(param_whitelist)\\n end\",\n \"def permitir_parametros\\n \\t\\tparams.permit!\\n \\tend\",\n \"def strong_params\\n params.require(:community).permit(param_whitelist)\\n end\",\n \"def permitted_strong_parameters\\n :all #or an array of parameters, example: [:name, :email]\\n end\",\n \"def strong_params\\n params.require(:education).permit(param_whitelist)\\n end\",\n \"def restricted_params\\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\\n raise(\\\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\\\")\\n end\",\n \"def allowed_params\\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\\n end\",\n \"def param_whitelist\\n [:rating, :review]\\n end\",\n \"def param_whitelist\\n whitelist = [\\n :username, :name,\\n :parent_id,\\n :headline, :description, :video,\\n :policy, :signup_mode, :category,\\n :website, :facebook, :twitter, :linkedin,\\n :founded_at,\\n privacy: [\\n :events,\\n :resources\\n ],\\n permission: [\\n :profile,\\n :members,\\n :children,\\n :statistics,\\n :posts,\\n :listings,\\n :resources,\\n :events\\n ],\\n location: [\\n :description,\\n :street,\\n :city,\\n :state,\\n :zip,\\n :country,\\n :latitude,\\n :longitude\\n ]\\n ]\\n \\n if action_name === 'update'\\n whitelist.delete(:parent_id)\\n unless current_user.role_in(@community) === 'owner'\\n whitelist.delete(:privacy)\\n whitelist.delete(:permission)\\n end\\n end\\n \\n whitelist\\n end\",\n \"def param_whitelist\\n if @user.present? && current_user != @user\\n return [:followed]\\n end\\n \\n whitelist = [\\n :username, :email, :password,\\n :first_name, :last_name,\\n :birthday, :gender,\\n :headline, :biography, :ask_about, :focus,\\n :website, :facebook, :linkedin, :twitter, :github,\\n roles: [],\\n skills: [],\\n interests: [],\\n privacy: { contact: [] },\\n location: [\\n :description,\\n :street,\\n :city,\\n :state,\\n :zip,\\n :country,\\n :latitude,\\n :longitude\\n ]\\n ]\\n \\n if action_name === 'update'\\n whitelist.delete(:email)\\n whitelist.delete(:password)\\n end\\n \\n whitelist\\n end\",\n \"def user_params \\n \\tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\\n end\",\n \"def user_params\\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \\n end\",\n \"def valid_params_request?; end\",\n \"def strong_params\\n params.require(:experience).permit(param_whitelist)\\n end\",\n \"def trim_whitelisted(params, whitelist)\\n # remove any parameters that are not whitelisted\\n params.each do |key, value|\\n # if white listed\\n if whitelist.include? key\\n # strip the parameters of any extra spaces, save as string\\n params[key] = value.to_s.strip\\n else\\n # delete any unauthorized parameters\\n params.delete key\\n end\\n end\\n params\\n end\",\n \"def whitelist_url_params\\n params.require(:whitelist_url).permit(:domain)\\n end\",\n \"def allowed_params\\n params.require(:allowed).permit(:email)\\n end\",\n \"def permitted_params\\n []\\n end\",\n \"def trim_whitelisted(params, whitelist)\\n # remove any parameters that are not whitelisted\\n params.each do |key, value|\\n # if white listed\\n if whitelist.include? key\\n # strip the parameters of any extra spaces, save as string\\n params[key] = value.to_s.strip\\n else\\n # delete any unauthorized parameters\\n params.delete key\\n end\\n end\\n params\\n end\",\n \"def safe_params\\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\\n end\",\n \"def query_param\\n\\t\\tparams.permit(:first_name, :last_name, :phone)\\n\\tend\",\n \"def strong_params\\n params.require(:success_metric).permit(param_whitelist)\\n end\",\n \"def devise_filter\\r\\n logger.debug(\\\"In devise_filter =>PARAMS: #{params.inspect}\\\")\\r\\n\\r\\n # White list for sign_up\\r\\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\\r\\n\\r\\n # White list for account update\\r\\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\\r\\n\\r\\n # White list for Invitation creation\\r\\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\\r\\n\\r\\n # White list for accept invitation\\r\\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\\r\\n\\r\\n end\",\n \"def whitelisted_user_params\\n params.require(:user).\\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\\n end\",\n \"def user_params\\n ActionController::Parameters.permit_all_parameters = true\\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\\n end\",\n \"def strong_params\\n params.require(:metric_change).permit(param_whitelist)\\n end\",\n \"def safe_params\\n params.require(:user).permit(:name)\\n end\",\n \"def get_params\\n\\t\\treturn ActionController::Parameters.new(self.attributes).permit(\\\"account_id\\\", \\\"title\\\", \\\"category\\\", \\\"introduction\\\", \\\"tags\\\", \\\"segment_type\\\", \\\"visible\\\", \\\"status\\\", \\\"main_image\\\")\\n\\tend\",\n \"def grant_params\\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\\n end\",\n \"def check_params; true; end\",\n \"def param_whitelist\\n whitelist = [\\n :description,\\n :progress,\\n :kpi_id\\n ]\\n \\n unless action_name === 'create'\\n whitelist.delete(:kpi_id)\\n end\\n \\n whitelist\\n end\",\n \"def quote_params\\n params.permit!\\n end\",\n \"def valid_params?; end\",\n \"def paramunold_params\\n params.require(:paramunold).permit!\\n end\",\n \"def user_params\\n\\t\\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\\n\\tend\",\n \"def filtered_parameters; end\",\n \"def user_params\\n params.permit(\\n \\t:id,\\n \\t:email, \\n \\t:first_name, \\n \\t:last_name, \\n \\t:password, \\n \\t:confirm_token, \\n \\t:phone_number,\\n \\t:facebook_link,\\n \\t:car_model,\\n \\t:license_plate)\\n end\",\n \"def filtering_params\\n params.permit(:email, :name)\\n end\",\n \"def check_params\\n true\\n end\",\n \"def wx_public_params\\n params.require(:wx_public).permit(:nickname, :manager, :alias)\\n end\",\n \"def allowed_params\\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\\n end\",\n \"def allowed_params\\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\\n end\",\n \"def listing_params\\n\\t\\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\\n\\tend\",\n \"def social_account_params\\n\\t\\t\\tparams.require(:social_account).permit!\\n\\t\\tend\",\n \"def safe_params\\n resurce_name = self.class.resource_name\\n params_method_name = \\\"#{resurce_name}_params\\\".to_sym\\n if params[resurce_name]\\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\\n send(params_method_name)\\n else\\n raise ActiveModel::ForbiddenAttributesError, \\\"Please, define the '#{params_method_name}' method in #{self.class.name}\\\"\\n end\\n end\\n end\",\n \"def url_params\\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\\n end\",\n \"def user_params\\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\\n end\",\n \"def model_params\\n\\t\\tparams.require(:manager).permit(\\n\\t :user_name,\\n :password,\\n :email,\\n \\t\\t\\t)\\n\\tend\",\n \"def article_params_whitelist\\n params.require(:article).permit(:title, :description, category_ids: [])\\n end\",\n \"def college_whitelist_params\\n params.require(:college_whitelist).permit(:status)\\n end\",\n \"def active_code_params\\n params[:active_code].permit\\n end\",\n \"def filtering_params\\n params.permit(:email)\\n end\",\n \"def valid_params(params)\\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\\n end\",\n \"def ip_address_params\\n\\t\\t\\tparams.require(:ip_address).permit!\\n end\",\n \"def pull_request_params\\n whitelist = [\\n :url,\\n :id,\\n :html_url,\\n :diff_url,\\n :patch_url,\\n :issue_url,\\n :number,\\n :state,\\n :locked,\\n :title\\n ]\\n params.require(:pull_request).permit(whitelist)\\n end\",\n \"def reserved_params\\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\\n end\",\n \"def post_params\\n if current_user.admin? \\n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\\n else \\n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\\n end \\n end\",\n \"def list_params\\n params.permit(:name)\\n end\",\n \"def filter_parameters; end\",\n \"def filter_parameters; end\",\n \"def vineyard_params\\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\\n end\",\n \"def available_activity_params\\n # params.require(:available_activity).permit(:type,:geometry,:properties)\\n whitelisted = ActionController::Parameters.new({\\n type: params.require(:available_activity)[:type],\\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\\n }).try(:permit!)\\n end\",\n \"def user_params\\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\\n end\",\n \"def user_params_pub\\n\\t \\tparams[:user].permit(:hruid)\\n\\t end\",\n \"def user_params\\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\\n :user, :color, :solde)\\n end\",\n \"def validate_search_inputs\\n @whitelisted = params.fetch(:user, nil)\\n if @whitelisted.blank?\\n render_error(400, \\\"#{I18n.t('general_error.params_missing_key')}\\\": [I18n.t('general_error.params_missing_value', model: \\\"review\\\")])\\n return\\n else\\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\\n end\\n end\",\n \"def param_whitelist\\n [\\n :title,\\n :description,\\n :organization,\\n :team_id,\\n :started_at,\\n :finished_at,\\n location: [\\n :description,\\n :street,\\n :city,\\n :state,\\n :zip,\\n :country,\\n :latitude,\\n :longitude\\n ]\\n ]\\n end\",\n \"def url_whitelist; end\",\n \"def admin_social_network_params\\n params.require(:social_network).permit!\\n end\",\n \"def filter_params\\n params.require(:filters).permit(:letters)\\n end\",\n \"def origin_params\\n params.permit(:country, :state, :city, :postal_code, :address, :description)\\n end\",\n \"def valid_params(params)\\n params.permit(:login, :first_name, :last_name, \\n :password, :password_confirmation)\\n end\",\n \"def sensitive_params=(params)\\n @sensitive_params = params\\n end\",\n \"def permit_request_params\\n params.permit(:address)\\n end\",\n \"def user_params\\n # Ensure a user can't give themselves admin priveleges\\n params.delete(:admin) if current_user.admin?\\n params.require(:user).permit(:name, :email, :admin, :image)\\n end\",\n \"def secure_params\\n params.require(:location).permit(:name)\\n end\",\n \"def strong_params\\n params.require( :setting ).\\n permit( :global_scan_limit, :per_user_scan_limit,\\n :target_whitelist_patterns, :target_blacklist_patterns )\\n end\",\n \"def question_params\\n params.require(:survey_question).permit(question_whitelist)\\n end\",\n \"def case_insensitive_params\\n params.require(:case_insensitive).permit(:name)\\n end\",\n \"def empire_master_no_match_params\\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\\n end\",\n \"def maintenance_request_params\\n params[:maintenance_request].permit! #allow all parameters for now\\n end\",\n \"def unwanted_params\\n params.require(:unwanted).permit(:title, :description, :image)\\n end\",\n \"def url_params\\n params[:url].permit(:full)\\n end\",\n \"def backend_user_params\\n params.permit!\\n end\",\n \"def filter_params\\n\\t\\treturn params[:candidate].permit(:name_for_filter)\\n\\tend\",\n \"def speed_measurement_params\\n\\n #fuckit, to lazy to deal with permit crap right now\\n ActionController::Parameters.permit_all_parameters = true\\n\\n params[:speed_measurement]\\n end\",\n \"def user_params\\n params.permit(:name, :age, :username, :display_photo, :password)\\n end\",\n \"def get_params\\r\\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\\r\\n params.require(:article).permit!\\r\\n\\r\\n end\",\n \"def pub_params\\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\\n end\",\n \"def pass_params\\n params[:pass].permit(:name, :price, :description, :colour, :events)\\n end\",\n \"def droptraining_params\\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\\n end\",\n \"def person_params\\n # params whitelist does *not* include admin, sub, remember_token\\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\\n # NOTE: do not include 'admin' in this list!\\n params.require(:person).permit(\\n :name, \\n :email, \\n :description,\\n :password, \\n :password_confirmation\\n )\\n end\",\n \"def parameter_params\\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\\n end\"\n]"},"negative_scores":{"kind":"list like","value":["0.69792545","0.6781151","0.67419964","0.674013","0.6734356","0.6591046","0.6502396","0.6496313","0.6480641","0.6477825","0.64565","0.6438387","0.63791263","0.63740575","0.6364131","0.63192815","0.62991166","0.62978333","0.6292148","0.6290449","0.6290076","0.62894756","0.6283177","0.6242471","0.62382483","0.6217549","0.6214457","0.6209053","0.6193042","0.6177802","0.6174604","0.61714715","0.6161512","0.6151757","0.6150663","0.61461","0.61213595","0.611406","0.6106206","0.6105114","0.6089039","0.6081015","0.6071004","0.60620916","0.6019971","0.601788","0.6011056","0.6010898","0.6005122","0.6005122","0.6001556","0.6001049","0.59943926","0.5992201","0.59909594","0.5990628","0.5980841","0.59669393","0.59589154","0.5958826","0.5957911","0.5957385","0.5953072","0.59526145","0.5943361","0.59386164","0.59375334","0.59375334","0.5933856","0.59292704","0.59254247","0.5924164","0.59167904","0.59088355","0.5907542","0.59064597","0.5906243","0.5898226","0.589687","0.5896091","0.5894501","0.5894289","0.5891739","0.58860534","0.5882406","0.587974","0.58738774","0.5869024","0.58679986","0.5867561","0.5865932","0.5864461","0.58639693","0.58617616","0.5861436","0.5860451","0.58602303","0.5854586","0.58537364","0.5850427","0.5850199"],"string":"[\n \"0.69792545\",\n \"0.6781151\",\n \"0.67419964\",\n \"0.674013\",\n \"0.6734356\",\n \"0.6591046\",\n \"0.6502396\",\n \"0.6496313\",\n \"0.6480641\",\n \"0.6477825\",\n \"0.64565\",\n \"0.6438387\",\n \"0.63791263\",\n \"0.63740575\",\n \"0.6364131\",\n \"0.63192815\",\n \"0.62991166\",\n \"0.62978333\",\n \"0.6292148\",\n \"0.6290449\",\n \"0.6290076\",\n \"0.62894756\",\n \"0.6283177\",\n \"0.6242471\",\n \"0.62382483\",\n \"0.6217549\",\n \"0.6214457\",\n \"0.6209053\",\n \"0.6193042\",\n \"0.6177802\",\n \"0.6174604\",\n \"0.61714715\",\n \"0.6161512\",\n \"0.6151757\",\n \"0.6150663\",\n \"0.61461\",\n \"0.61213595\",\n \"0.611406\",\n \"0.6106206\",\n \"0.6105114\",\n \"0.6089039\",\n \"0.6081015\",\n \"0.6071004\",\n \"0.60620916\",\n \"0.6019971\",\n \"0.601788\",\n \"0.6011056\",\n \"0.6010898\",\n \"0.6005122\",\n \"0.6005122\",\n \"0.6001556\",\n \"0.6001049\",\n \"0.59943926\",\n \"0.5992201\",\n \"0.59909594\",\n \"0.5990628\",\n \"0.5980841\",\n \"0.59669393\",\n \"0.59589154\",\n \"0.5958826\",\n \"0.5957911\",\n \"0.5957385\",\n \"0.5953072\",\n \"0.59526145\",\n \"0.5943361\",\n \"0.59386164\",\n \"0.59375334\",\n \"0.59375334\",\n \"0.5933856\",\n \"0.59292704\",\n \"0.59254247\",\n \"0.5924164\",\n \"0.59167904\",\n \"0.59088355\",\n \"0.5907542\",\n \"0.59064597\",\n \"0.5906243\",\n \"0.5898226\",\n \"0.589687\",\n \"0.5896091\",\n \"0.5894501\",\n \"0.5894289\",\n \"0.5891739\",\n \"0.58860534\",\n \"0.5882406\",\n \"0.587974\",\n \"0.58738774\",\n \"0.5869024\",\n \"0.58679986\",\n \"0.5867561\",\n \"0.5865932\",\n \"0.5864461\",\n \"0.58639693\",\n \"0.58617616\",\n \"0.5861436\",\n \"0.5860451\",\n \"0.58602303\",\n \"0.5854586\",\n \"0.58537364\",\n \"0.5850427\",\n \"0.5850199\"\n]"},"document_score":{"kind":"string","value":"0.0"},"document_rank":{"kind":"string","value":"-1"}}},{"rowIdx":132,"cells":{"query":{"kind":"string","value":"rubocop:enable Metrics/MethodLength rubocop:disable Metrics/MethodLength"},"document":{"kind":"string","value":"def deny_encryption_using_incorrect_key_statement(\n bucket_name,\n kms_key_arn\n )\n {\n effect: 'Deny',\n principal: '*',\n action: 's3:PutObject',\n resource: \"arn:aws:s3:::#{bucket_name}/*\",\n condition: {\n 'StringNotEqualsIfExists' => {\n 's3:x-amz-server-side-encryption-aws-kms-key-id' => kms_key_arn\n }\n }\n }\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def private; end","def probers; end","def implementation; end","def implementation; end","def schubert; end","def specie; end","def specie; end","def specie; end","def specie; end","def refutal()\n end","def custom; end","def custom; end","def offences_by; end","def suivre; end","def strategy; end","def used?; end","def private_method\n end","def operations; end","def operations; end","def isolated; end","def isolated; end","def intensifier; end","def extra; end","def internal; end","def missing; end","def formation; end","def who_we_are\r\n end","def initialize\n\n end","def initialize\n\n end","def overrides; end","def celebration; end","def initialize; end","def initialize; end","def initialize; end","def initialize; end","def initialize; end","def initialize; end","def initialize; end","def initialize; end","def initialize; end","def initialize; end","def initialize; end","def initialize\n \n end","def villian; end","def ignores; end","def initialize\n \n end","def initialize\n super\n end","def initialize\n super\n end","def initialize\n super\n end","def spec; end","def spec; end","def initialize\n super()\n end","def anchored; end","def methods; end","def methods; end","def methods; end","def methods; end","def initialize\n\t\t\n\tend","def weber; end","def apply\n\t\t\n\tend","def apply\n\t\t\n\tend","def initialize\n end","def initialize\n end","def initialize\n end","def initialize\n end","def initialize\n end","def initialize\n end","def initialize\n end","def initialize\n end","def initialize\n end","def initialize\n end","def terpene; end","def same; end","def operation; end","def verdi; end","def common\n \n end","def initialize() end","def wrapper; end","def missing?; end","def initialize\r\n\r\n end","def relatorios\n end","def requirements; end","def requirements; end","def requirements; end","def requirements; end","def internship_passed; end","def processor; end","def ignore; end","def returns; end","def identify; end","def appraisals; end","def appraisals; end","def init; end","def init; end","def init; end","def init; end","def initialize\n # nothing here for now\n end","def initialize\n\n\tend","def initialize\n\n\tend","def sitemaps; end","def under_construction\n end"],"string":"[\n \"def private; end\",\n \"def probers; end\",\n \"def implementation; end\",\n \"def implementation; end\",\n \"def schubert; end\",\n \"def specie; end\",\n \"def specie; end\",\n \"def specie; end\",\n \"def specie; end\",\n \"def refutal()\\n end\",\n \"def custom; end\",\n \"def custom; end\",\n \"def offences_by; end\",\n \"def suivre; end\",\n \"def strategy; end\",\n \"def used?; end\",\n \"def private_method\\n end\",\n \"def operations; end\",\n \"def operations; end\",\n \"def isolated; end\",\n \"def isolated; end\",\n \"def intensifier; end\",\n \"def extra; end\",\n \"def internal; end\",\n \"def missing; end\",\n \"def formation; end\",\n \"def who_we_are\\r\\n end\",\n \"def initialize\\n\\n end\",\n \"def initialize\\n\\n end\",\n \"def overrides; end\",\n \"def celebration; end\",\n \"def initialize; end\",\n \"def initialize; end\",\n \"def initialize; end\",\n \"def initialize; end\",\n \"def initialize; end\",\n \"def initialize; end\",\n \"def initialize; end\",\n \"def initialize; end\",\n \"def initialize; end\",\n \"def initialize; end\",\n \"def initialize; end\",\n \"def initialize\\n \\n end\",\n \"def villian; end\",\n \"def ignores; end\",\n \"def initialize\\n \\n end\",\n \"def initialize\\n super\\n end\",\n \"def initialize\\n super\\n end\",\n \"def initialize\\n super\\n end\",\n \"def spec; end\",\n \"def spec; end\",\n \"def initialize\\n super()\\n end\",\n \"def anchored; end\",\n \"def methods; end\",\n \"def methods; end\",\n \"def methods; end\",\n \"def methods; end\",\n \"def initialize\\n\\t\\t\\n\\tend\",\n \"def weber; end\",\n \"def apply\\n\\t\\t\\n\\tend\",\n \"def apply\\n\\t\\t\\n\\tend\",\n \"def initialize\\n end\",\n \"def initialize\\n end\",\n \"def initialize\\n end\",\n \"def initialize\\n end\",\n \"def initialize\\n end\",\n \"def initialize\\n end\",\n \"def initialize\\n end\",\n \"def initialize\\n end\",\n \"def initialize\\n end\",\n \"def initialize\\n end\",\n \"def terpene; end\",\n \"def same; end\",\n \"def operation; end\",\n \"def verdi; end\",\n \"def common\\n \\n end\",\n \"def initialize() end\",\n \"def wrapper; end\",\n \"def missing?; end\",\n \"def initialize\\r\\n\\r\\n end\",\n \"def relatorios\\n end\",\n \"def requirements; end\",\n \"def requirements; end\",\n \"def requirements; end\",\n \"def requirements; end\",\n \"def internship_passed; end\",\n \"def processor; end\",\n \"def ignore; end\",\n \"def returns; end\",\n \"def identify; end\",\n \"def appraisals; end\",\n \"def appraisals; end\",\n \"def init; end\",\n \"def init; end\",\n \"def init; end\",\n \"def init; end\",\n \"def initialize\\n # nothing here for now\\n end\",\n \"def initialize\\n\\n\\tend\",\n \"def initialize\\n\\n\\tend\",\n \"def sitemaps; end\",\n \"def under_construction\\n end\"\n]"},"negative_scores":{"kind":"list like","value":["0.78097546","0.6550692","0.6393907","0.6393907","0.63413805","0.6341239","0.6341239","0.6341239","0.6341239","0.63261473","0.6132386","0.6132386","0.6035665","0.60181385","0.59858197","0.597906","0.59612405","0.58933866","0.58933866","0.5888103","0.5888103","0.5863022","0.5837961","0.58362275","0.5806279","0.5795523","0.5794152","0.5791959","0.5791959","0.5769047","0.5761127","0.5760442","0.5760442","0.5760442","0.5760442","0.5760442","0.5760442","0.5760442","0.5760442","0.5760442","0.5760442","0.5760442","0.5757446","0.57485706","0.57399124","0.5737555","0.572034","0.572034","0.572034","0.57172394","0.57172394","0.5709601","0.5702412","0.5697405","0.5697405","0.5697405","0.5697405","0.5697184","0.5695819","0.5695533","0.5695533","0.5680522","0.5680522","0.5680522","0.5680522","0.5680522","0.5680522","0.5680522","0.5680522","0.5680522","0.5680522","0.56670296","0.566359","0.5655269","0.56464344","0.56259644","0.5616344","0.56120664","0.5611277","0.56054115","0.56052166","0.5599771","0.5599771","0.5599771","0.5599771","0.55996317","0.5598495","0.5589104","0.5588666","0.5585893","0.5581739","0.5581739","0.5581481","0.5581481","0.5581481","0.5581481","0.55735034","0.55711466","0.55711466","0.55611944","0.5558025"],"string":"[\n \"0.78097546\",\n \"0.6550692\",\n \"0.6393907\",\n \"0.6393907\",\n \"0.63413805\",\n \"0.6341239\",\n \"0.6341239\",\n \"0.6341239\",\n \"0.6341239\",\n \"0.63261473\",\n \"0.6132386\",\n \"0.6132386\",\n \"0.6035665\",\n \"0.60181385\",\n \"0.59858197\",\n \"0.597906\",\n \"0.59612405\",\n \"0.58933866\",\n \"0.58933866\",\n \"0.5888103\",\n \"0.5888103\",\n \"0.5863022\",\n \"0.5837961\",\n \"0.58362275\",\n \"0.5806279\",\n \"0.5795523\",\n \"0.5794152\",\n \"0.5791959\",\n \"0.5791959\",\n \"0.5769047\",\n \"0.5761127\",\n \"0.5760442\",\n \"0.5760442\",\n \"0.5760442\",\n \"0.5760442\",\n \"0.5760442\",\n \"0.5760442\",\n \"0.5760442\",\n \"0.5760442\",\n \"0.5760442\",\n \"0.5760442\",\n \"0.5760442\",\n \"0.5757446\",\n \"0.57485706\",\n \"0.57399124\",\n \"0.5737555\",\n \"0.572034\",\n \"0.572034\",\n \"0.572034\",\n \"0.57172394\",\n \"0.57172394\",\n \"0.5709601\",\n \"0.5702412\",\n \"0.5697405\",\n \"0.5697405\",\n \"0.5697405\",\n \"0.5697405\",\n \"0.5697184\",\n \"0.5695819\",\n \"0.5695533\",\n \"0.5695533\",\n \"0.5680522\",\n \"0.5680522\",\n \"0.5680522\",\n \"0.5680522\",\n \"0.5680522\",\n \"0.5680522\",\n \"0.5680522\",\n \"0.5680522\",\n \"0.5680522\",\n \"0.5680522\",\n \"0.56670296\",\n \"0.566359\",\n \"0.5655269\",\n \"0.56464344\",\n \"0.56259644\",\n \"0.5616344\",\n \"0.56120664\",\n \"0.5611277\",\n \"0.56054115\",\n \"0.56052166\",\n \"0.5599771\",\n \"0.5599771\",\n \"0.5599771\",\n \"0.5599771\",\n \"0.55996317\",\n \"0.5598495\",\n \"0.5589104\",\n \"0.5588666\",\n \"0.5585893\",\n \"0.5581739\",\n \"0.5581739\",\n \"0.5581481\",\n \"0.5581481\",\n \"0.5581481\",\n \"0.5581481\",\n \"0.55735034\",\n \"0.55711466\",\n \"0.55711466\",\n \"0.55611944\",\n \"0.5558025\"\n]"},"document_score":{"kind":"string","value":"0.0"},"document_rank":{"kind":"string","value":"-1"}}},{"rowIdx":133,"cells":{"query":{"kind":"string","value":"rubocop:enable Metrics/MethodLength rubocop:disable Metrics/MethodLength"},"document":{"kind":"string","value":"def deny_un_encrypted_inflight_operations_statement(\n bucket_name\n )\n {\n effect: 'Deny',\n principal: '*',\n action: 's3:*',\n resource: \"arn:aws:s3:::#{bucket_name}/*\",\n condition: {\n 'Bool' => {\n 'aws:SecureTransport' => 'false'\n }\n }\n }\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def private; end","def probers; end","def implementation; end","def implementation; end","def specie; end","def specie; end","def specie; end","def specie; end","def schubert; end","def refutal()\n end","def custom; end","def custom; end","def offences_by; end","def suivre; end","def strategy; end","def used?; end","def private_method\n end","def operations; end","def operations; end","def isolated; end","def isolated; end","def intensifier; end","def extra; end","def internal; end","def missing; end","def formation; end","def who_we_are\r\n end","def initialize\n\n end","def initialize\n\n end","def overrides; end","def celebration; end","def initialize; end","def initialize; end","def initialize; end","def initialize; end","def initialize; end","def initialize; end","def initialize; end","def initialize; end","def initialize; end","def initialize; end","def initialize; end","def initialize\n \n end","def villian; end","def ignores; end","def initialize\n \n end","def initialize\n super\n end","def initialize\n super\n end","def initialize\n super\n end","def spec; end","def spec; end","def initialize\n super()\n end","def anchored; end","def initialize\n\t\t\n\tend","def methods; end","def methods; end","def methods; end","def methods; end","def apply\n\t\t\n\tend","def apply\n\t\t\n\tend","def weber; end","def initialize\n end","def initialize\n end","def initialize\n end","def initialize\n end","def initialize\n end","def initialize\n end","def initialize\n end","def initialize\n end","def initialize\n end","def initialize\n end","def terpene; end","def same; end","def operation; end","def verdi; end","def common\n \n end","def initialize() end","def wrapper; end","def missing?; end","def initialize\r\n\r\n end","def relatorios\n end","def internship_passed; end","def requirements; end","def requirements; end","def requirements; end","def requirements; end","def processor; end","def returns; end","def ignore; end","def identify; end","def init; end","def init; end","def init; end","def init; end","def appraisals; end","def appraisals; end","def initialize\n # nothing here for now\n end","def initialize\n\n\tend","def initialize\n\n\tend","def sitemaps; end","def under_construction\n end"],"string":"[\n \"def private; end\",\n \"def probers; end\",\n \"def implementation; end\",\n \"def implementation; end\",\n \"def specie; end\",\n \"def specie; end\",\n \"def specie; end\",\n \"def specie; end\",\n \"def schubert; end\",\n \"def refutal()\\n end\",\n \"def custom; end\",\n \"def custom; end\",\n \"def offences_by; end\",\n \"def suivre; end\",\n \"def strategy; end\",\n \"def used?; end\",\n \"def private_method\\n end\",\n \"def operations; end\",\n \"def operations; end\",\n \"def isolated; end\",\n \"def isolated; end\",\n \"def intensifier; end\",\n \"def extra; end\",\n \"def internal; end\",\n \"def missing; end\",\n \"def formation; end\",\n \"def who_we_are\\r\\n end\",\n \"def initialize\\n\\n end\",\n \"def initialize\\n\\n end\",\n \"def overrides; end\",\n \"def celebration; end\",\n \"def initialize; end\",\n \"def initialize; end\",\n \"def initialize; end\",\n \"def initialize; end\",\n \"def initialize; end\",\n \"def initialize; end\",\n \"def initialize; end\",\n \"def initialize; end\",\n \"def initialize; end\",\n \"def initialize; end\",\n \"def initialize; end\",\n \"def initialize\\n \\n end\",\n \"def villian; end\",\n \"def ignores; end\",\n \"def initialize\\n \\n end\",\n \"def initialize\\n super\\n end\",\n \"def initialize\\n super\\n end\",\n \"def initialize\\n super\\n end\",\n \"def spec; end\",\n \"def spec; end\",\n \"def initialize\\n super()\\n end\",\n \"def anchored; end\",\n \"def initialize\\n\\t\\t\\n\\tend\",\n \"def methods; end\",\n \"def methods; end\",\n \"def methods; end\",\n \"def methods; end\",\n \"def apply\\n\\t\\t\\n\\tend\",\n \"def apply\\n\\t\\t\\n\\tend\",\n \"def weber; end\",\n \"def initialize\\n end\",\n \"def initialize\\n end\",\n \"def initialize\\n end\",\n \"def initialize\\n end\",\n \"def initialize\\n end\",\n \"def initialize\\n end\",\n \"def initialize\\n end\",\n \"def initialize\\n end\",\n \"def initialize\\n end\",\n \"def initialize\\n end\",\n \"def terpene; end\",\n \"def same; end\",\n \"def operation; end\",\n \"def verdi; end\",\n \"def common\\n \\n end\",\n \"def initialize() end\",\n \"def wrapper; end\",\n \"def missing?; end\",\n \"def initialize\\r\\n\\r\\n end\",\n \"def relatorios\\n end\",\n \"def internship_passed; end\",\n \"def requirements; end\",\n \"def requirements; end\",\n \"def requirements; end\",\n \"def requirements; end\",\n \"def processor; end\",\n \"def returns; end\",\n \"def ignore; end\",\n \"def identify; end\",\n \"def init; end\",\n \"def init; end\",\n \"def init; end\",\n \"def init; end\",\n \"def appraisals; end\",\n \"def appraisals; end\",\n \"def initialize\\n # nothing here for now\\n end\",\n \"def initialize\\n\\n\\tend\",\n \"def initialize\\n\\n\\tend\",\n \"def sitemaps; end\",\n \"def under_construction\\n end\"\n]"},"negative_scores":{"kind":"list like","value":["0.781014","0.6551781","0.63943195","0.63943195","0.63432074","0.63432074","0.63432074","0.63432074","0.6342304","0.632547","0.61320364","0.61320364","0.6036338","0.601888","0.5986253","0.5978609","0.5960824","0.589437","0.589437","0.5888722","0.5888722","0.58635813","0.583836","0.58364916","0.5806411","0.5796488","0.5794451","0.5792431","0.5792431","0.57694495","0.57617295","0.5761488","0.5761488","0.5761488","0.5761488","0.5761488","0.5761488","0.5761488","0.5761488","0.5761488","0.5761488","0.5761488","0.5758301","0.57489896","0.5740668","0.5738773","0.5720218","0.5720218","0.5720218","0.5717897","0.5717897","0.570929","0.5703585","0.5698848","0.5698099","0.5698099","0.5698099","0.5698099","0.5696275","0.5696275","0.5695931","0.5680935","0.5680935","0.5680935","0.5680935","0.5680935","0.5680935","0.5680935","0.5680935","0.5680935","0.5680935","0.56683034","0.5664958","0.5655457","0.564768","0.56269085","0.5617756","0.5612248","0.56111354","0.5606687","0.5605637","0.56006247","0.5599622","0.5599622","0.5599622","0.5599622","0.55989754","0.5589023","0.5588836","0.5587438","0.55828524","0.55828524","0.55828524","0.55828524","0.5580421","0.5580421","0.5573223","0.55724686","0.55724686","0.5561573","0.55586284"],"string":"[\n \"0.781014\",\n \"0.6551781\",\n \"0.63943195\",\n \"0.63943195\",\n \"0.63432074\",\n \"0.63432074\",\n \"0.63432074\",\n \"0.63432074\",\n \"0.6342304\",\n \"0.632547\",\n \"0.61320364\",\n \"0.61320364\",\n \"0.6036338\",\n \"0.601888\",\n \"0.5986253\",\n \"0.5978609\",\n \"0.5960824\",\n \"0.589437\",\n \"0.589437\",\n \"0.5888722\",\n \"0.5888722\",\n \"0.58635813\",\n \"0.583836\",\n \"0.58364916\",\n \"0.5806411\",\n \"0.5796488\",\n \"0.5794451\",\n \"0.5792431\",\n \"0.5792431\",\n \"0.57694495\",\n \"0.57617295\",\n \"0.5761488\",\n \"0.5761488\",\n \"0.5761488\",\n \"0.5761488\",\n \"0.5761488\",\n \"0.5761488\",\n \"0.5761488\",\n \"0.5761488\",\n \"0.5761488\",\n \"0.5761488\",\n \"0.5761488\",\n \"0.5758301\",\n \"0.57489896\",\n \"0.5740668\",\n \"0.5738773\",\n \"0.5720218\",\n \"0.5720218\",\n \"0.5720218\",\n \"0.5717897\",\n \"0.5717897\",\n \"0.570929\",\n \"0.5703585\",\n \"0.5698848\",\n \"0.5698099\",\n \"0.5698099\",\n \"0.5698099\",\n \"0.5698099\",\n \"0.5696275\",\n \"0.5696275\",\n \"0.5695931\",\n \"0.5680935\",\n \"0.5680935\",\n \"0.5680935\",\n \"0.5680935\",\n \"0.5680935\",\n \"0.5680935\",\n \"0.5680935\",\n \"0.5680935\",\n \"0.5680935\",\n \"0.5680935\",\n \"0.56683034\",\n \"0.5664958\",\n \"0.5655457\",\n \"0.564768\",\n \"0.56269085\",\n \"0.5617756\",\n \"0.5612248\",\n \"0.56111354\",\n \"0.5606687\",\n \"0.5605637\",\n \"0.56006247\",\n \"0.5599622\",\n \"0.5599622\",\n \"0.5599622\",\n \"0.5599622\",\n \"0.55989754\",\n \"0.5589023\",\n \"0.5588836\",\n \"0.5587438\",\n \"0.55828524\",\n \"0.55828524\",\n \"0.55828524\",\n \"0.55828524\",\n \"0.5580421\",\n \"0.5580421\",\n \"0.5573223\",\n \"0.55724686\",\n \"0.55724686\",\n \"0.5561573\",\n \"0.55586284\"\n]"},"document_score":{"kind":"string","value":"0.0"},"document_rank":{"kind":"string","value":"-1"}}},{"rowIdx":134,"cells":{"query":{"kind":"string","value":"Returns a list of open hours grouped by same days"},"document":{"kind":"string","value":"def grouped_open_hours\n\n open_hours = []\n start_day = nil\n end_day = nil\n current_period = nil\n\n standard_hours.sort.each_with_index do |o, i|\n if not o.open?\n period = \"Stengt\"\n else\n period = I18n.l(o.open_time, format: :time) + \" - \" + I18n.l(o.close_time, format: :time)\n end\n\n # Track day\n if start_day == nil\n start_day = o.day\n current_period = period\n end\n\n # Previous group ended, add it\n if period != current_period\n day = I18n.t(\"days.#{start_day}\")\n if end_day != nil\n day += \" - \" + I18n.t(\"days.#{end_day}\")\n end\n # Hverdager custom string\n if start_day == \"monday\" and end_day == \"friday\"\n day = \"Hverdager\"\n end\n open_hours.append([day, current_period])\n current_period = period\n start_day = o.day\n end_day = nil\n end\n\n # Update period end\n if start_day != o.day\n end_day = o.day\n end\n\n # Last day closes period\n if i >= standard_hours.count - 1\n day = I18n.t(\"days.#{start_day}\")\n if end_day != nil\n day += \" - \" + I18n.t(\"days.#{o.day}\")\n end\n open_hours.append([day, current_period])\n end\n\n end\n\n open_hours\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def grouped_office_hours\n merged_hours.map { |hash_list|\n days = if hash_list.length == 1\n hash_list.first[:day]\n elsif hash_list.length > 1\n \"#{hash_list.first[:day]} - #{hash_list.last[:day]}\"\n end\n {:hours => hash_list.first[:hours],\n :day => days }\n }.delete_if {|hash| hash[:hours].blank? }\n end","def opening_hours\n hours = @data[:godziny_pracy]\n keys = {weekdays: :dni_robocze, saturdays: :soboty, sundays: :niedz_i_sw}\n Hash[\n keys.map do |h, x|\n value = unless hours[x].nil?\n [hours[x][:godziny].to_s, hours[x][:uwagi].to_s]\n end\n\n [h, value]\n end\n ]\n end","def group_by_hour\n group_by { |e| e.timestamp.hour }\n end","def each_open_day\n each do |day, times|\n unless times.empty?\n yield day, times\n end\n end\n end","def get_hours_array hours\n hours_array = []\n hours.each { |h| hours_array << h.date }\n return hours_array\n end","def show\n @open_hours = Hash.new\n @place.open_times.each do |schedule|\n @open_hours[schedule.day] = \"#{schedule.open_time.strftime('%l:%M %P')} - #{schedule.close_time.strftime('%l:%M %P')}\"\n end\n end","def grid\n Date::DAYNAMES.map do |name|\n daily_hours = send(name.downcase)\n HOURS.map do |hour|\n daily_hours.include? hour\n end\n end\n end","def open_close_times(date)\n open_close = @open_close[as_string(date)] || @open_close[as_sym(date)] || @default_open_close\n open_close.collect { |h| Time.parse(\"#{as_string(date)} #{h}\") }\n end","def show_opening_hours(times, formatted_times, event_date)\n result = 'Not Open Today'\n event_day = transformToFourSquareDay(event_date.in_time_zone.wday)\n times.each_with_index do |time, index|\n unless time.days.index(event_day).nil?\n result = formatted_times[index].open[0].renderedTime\n end\n end\n result\n end","def hours_in_day(*hours)\n @test_time = @time if @test_time.nil?\n x_in_list_of_y(@test_time.hour, Configuration.parse_range(hours).flatten)\n end","def trucks_currently_open\n trucks = self.class.get_truck_data\n date = self.class.get_time\n\n trucks_open_now = []\n trucks.each do |truck|\n if date.strftime('%H:%M') <= truck[\"end24\"] && \n date.strftime('%H:%M') > truck[\"start24\"]\n trucks_open_now << truck[\"applicant\"]\n end \n end\n p trucks_open_now\n end","def hours\n @hours ||= []\n return @hours if !@hours.empty?\n src['hours'].each{|h| @hours << Stormglass::Hour.new(h) }\n @hours\n end","def hourly_totals(emoji)\n hour_zero = self.last_hour.where(emoji: emoji).pluck(:created_at).size\n hour_one = self.last_hour_plus_one.where(emoji: emoji).pluck(:created_at).size\n hour_two = self.last_hour_plus_two.where(emoji: emoji).pluck(:created_at).size\n hour_three = self.last_hour_plus_three.where(emoji: emoji).pluck(:created_at).size\n hour_four = self.last_hour_plus_four.where(emoji: emoji).pluck(:created_at).size\n some_days = [hour_zero, hour_one, hour_two, hour_three, hour_four]\n end","def closed(day)\n week.each do |weekday,hours_array|\n if day == weekday \n week[weekday] = [\"closed\"]\n \n end\n end\n end","def open?\n return false if close_today?\n today = self.time_tables.find_by(day_of_week: Time.now.wday)\n (today.opened_at...today.closed_at).include?(Time.now.hour)\nend","def hour_events(selected_day, hour, events)\n h = hour.split(\":\")\n hour_end = \"#{h[0]}:59\"\n events.select { |e| e.start_time.to_date == selected_day && (e.start_time.to_time.strftime(\"%H:%M\") >= hour) && (e.start_time.to_time.strftime(\"%H:%M\") < hour_end) }\n end","def open_slots_for_select(date)\n open_slots(date).map do |slot|\n [\"#{slot.starts_at.strftime('%d/%m/%Y, %H:%M ')}\", slot.starts_at]\n end\n end","def index\n @open_hours = OpenHour.all\n end","def next_weeks_open_house_dates(open_house_dow)\n now = Time.now\n dates = []\n (0...7).each do |day_offset|\n days = day_offset*24*60*60\n date = now + days\n if open_house_dow.include?(date.wday)\n dates << now + days\n end\n end\n dates\n end","def day_meetings\n days = []\n @course.weekdays.each_char.each_with_index do |w, i|\n days.push(DAYS_AS_SYM[i]) if w.to_i == 1\n end\n days\n end","def hour_of_day(*hours)\n merge(hour: hours)\n end","def days\n return self.day_shifts.keys\n end","def group_by_day\n\n\tend","def get_worked_hours_hash hours_array, hash\n first_hour_pos = 0\n hours_array.each do |hour|\n if is_different_day? hour.day, hours_array[first_hour_pos].day\n current_day = hours_array[first_hour_pos]\n first_hour_pos = hours_array.index(hour)\n worked_hours = get_worked_hours(current_day, hours_array[first_hour_pos - 1])\n hash = build_hash hash, current_day, worked_hours, hours_array[first_hour_pos - 1]\n elsif hours_array.index(hour) == hours_array.size - 1\n worked_hours = get_worked_hours(hours_array[first_hour_pos], hours_array[hours_array.size - 1])\n hash = build_hash hash, hours_array[first_hour_pos], worked_hours, hours_array[hours_array.size - 1]\n end\n end\n return hash\n end","def time_slots\n collection=[]\n start_time=Time.now.beginning_of_hour\n end_time=Time.now.tomorrow.midnight-1.hour\n time=start_time\n\n while time < end_time\n collection<<[time.beginning_of_hour.hour, time.beginning_of_hour]\n time=time+1.hour\n end\n\n collection\n end","def group_by_day\n group_by { |e| e.timestamp.strftime '%Y-%m-%d' }\n end","def hours_for(hours)\n return 'closed' if hours.blank?\n\n hours.reduce '' do |memo, time_range|\n midnight = Time.current.midnight\n start_time = midnight.since(time_range.begin).strftime(TIME_FORMAT).strip\n end_time = midnight.since(time_range.end).strftime(TIME_FORMAT).strip\n\n memo + \"#{memo.empty? ? '' : ', '}#{start_time} to #{end_time}\"\n end\n end","def remaining_hours_by_day\n values_by_day(0, true) { |x| model.remaining_hours_for_day_number(x) }\n end","def trucks_open_today\n trucks = self.class.get_truck_data\n date = self.class.get_time\n\n trucks_today = []\n trucks.each do |truck|\n if date.strftime(\"%A\") == truck[\"dayofweekstr\"]\n trucks_today << truck[\"applicant\"]\n end \n end\n p trucks_today\n end","def hours( calculator )\n a = []\n a << terse_hours( calculator.total ) if ( @report.include_totals )\n a << terse_hours( calculator.committed ) if ( @report.include_committed )\n a << terse_hours( calculator.not_committed ) if ( @report.include_not_committed )\n return a\n end","def day_times\n @day_times ||= available_times.map(&:day_time)\n @day_times\n end","def neighborhood_openings(start_date, end_date)\n openings = []\n self.listings.each do |listing|\n listing.reservations.each do |r|\n booked_dates = r.checkin..r.checkout\n unless booked_dates === start_date || booked_dates === end_date\n openings << listing\n end\n end\n end\n return openings\n end","def events_on_day(day_num)\n events = []\n event.each { |e| events << e if e.days.include? day_num }\n events.sort_by(&:start_time)\n end","def attendance_logs_by_date\n attendance_logs.group_by { |al| al.occured_at.strftime(\"%F\") }\n end","def hour_of_day(hours, *extras)\n merge(hour: hours.array_concat(extras))\n end","def meetings_on(day)\n ((@ending_meetings_by_days[day] || []) + (@starting_meetings_by_days[day] || [])).uniq.sort_by {|meeting| meeting.start_date}\n end","def days_assigned\r\n days_assigned = []\r\n self.groups.each {|g| days_assigned.push(g.day)}\r\n return days_assigned\r\n end","def events_on(day)\n ((@ending_events_by_days[day] || []) + (@starting_events_by_days[day] || [])).uniq\n end","def neighborhood_openings(start_date, end_date)\n openings(start_date, end_date)\n end","def to_a\n (first_calendar_day..last_calendar_day).to_a.in_groups_of(7)\n end","def grouped_happening_cases(this)\n\t\t\tsession_id_list = []\n\t\t\tthis.offering_sessions.each do |os|\n\t\t\t\tsession_id_list << os.id\n\t\t\tend\n\n\t\t\tsorted_happening_cases = HappeningCase.where(happening_type: \"OfferingSession\", happening_id: session_id_list).group_by(&:date_and_time)\n\t\tend","def time_rows\n rows = []\n (0..NUM_HALF_HOURS-1).each do |half_hour|\n cols = []\n row = content_tag :tr do\n cols << hour_cell(half_hour)\n cols << minute_cell(half_hour)\n (0..(num_days-1)).each do |day|\n cols << event_cells(half_hour,day)\n end\n cols.join.html_safe\n end\n rows << row\n end\n rows.join.html_safe\n end","def public_holidays_to_array\n holidays = []\n public_holidays&.each do |day, meta|\n next if !meta\n next if !meta['active']\n next if meta['removed']\n\n holidays.push Date.parse(day)\n end\n holidays\n end","def index\n @day_hours = DayHour.all\n end","def openings_on(date)\n events = openings.starts_on(date).to_a\n events.present? ? events : recurrent_openings_for(date)\n end","def hours\n _nudge[0]\n end","def how_many_available_on(day, hour)\n who_is_available_on(day, hour).size\n end","def day_events(date, events)\n events.select { |e| e.start_time.to_date == date }.sort_by { |e| e.start_time }\n end","def day\n @client = Client.new\n @title = @current_user.name\n @view = 'day'\n # TODO is Date.parse in current time zone? If not add.\n @date = params[:date].nil? ? Date.current : Date.parse(params[:date])\n # TODO: brakeman is warning of security problem with this line\n @nav_title = @date.strftime(NAV_TITLE[@view.to_sym])\n # TODO: should employees stay or go?\n @employees = [1]\n\n @appointments_by_hour = Hash.new\n r = Appointment.where(time: @date.in_time_zone.beginning_of_day..@date.in_time_zone.end_of_day).order(:time).includes(:client)\n r.each do |appointment| #.order(:time).group_by(&:time)\n k = appointment.time.hour\n if @appointments_by_hour.has_key?(k)\n @appointments_by_hour[k].push(appointment)\n else\n @appointments_by_hour[k] = [appointment]\n end\n end\n\n render 'index'\n end","def duplicate_days\r\n duplicates = 0\r\n dup_hash(self.days_assigned).each_value{|v| duplicates += v}\r\n return duplicates\r\n end","def days\n attendances.order(date: :asc).map(&:date)\n end","def opening_hour\n 11\n end","def hours_per_day(entries)\n hours_per_day = Hash.new(0.0)\n entries.each do |entry|\n hours_per_day[entry[:start].to_date] += (entry[:end] - entry[:start]) / 3600.0\n end\n hours_per_day\nend","def groups_total_hours(records, from, to, rows)\n groups_total_hours = []\n # days difference between rows\n days = ((to - from) / rows).to_i + 1\n (0..rows-1).each do |i|\n i_from = to - (i+1) * days\n i_to = to - i * days\n # break if time period of current row is out of time area delimited by from and to \n break if from > i_to\n date = i_to - days / 2\n total_hours = records.where(\"date(records.created_at) > ? and date(records.created_at) <= ?\", i_from, i_to).sum(\"hours\")\n groups_total_hours << {date: date, total_hours: total_hours}\n end\n groups_total_hours \n end","def events_seven_days()\n events = []\n today = Date.today\n for i in 0..6 do\n events += events_by_date(today + i)\n end\n return events\nend","def get_work_days\n puts \"Getting work days...\"\n work_days = []\n biweek = get_biweek\n week_1 = @schedule[biweek[0]].compact.uniq\n week_2 = @schedule[biweek[1]].compact.uniq\n\n @schedule.each_with_index do |row, i|\n DAYS.each_with_index do |day, j|\n date = ( i < biweek[1] ? week_1[j] : week_2[j] )\n day_name = day[:day]\n name = row[day[:name]]\n hours = row[day[:hours]]\n if name && hours && name.downcase.include?(@person.downcase)\n work_days.push({\n :name => @person,\n :date => get_date(date, hours)\n })\n end\n end\n end\n puts \"Work days:\\n#{work_days}\"\n return work_days\nend","def opening(day)\n Time.now.utc.midnight\n .advance(seconds: opening_second(day)).strftime('%H:%M')\n end","def requests_per_hour\n group_by_hour.map { |hour, ents|\n [hour, ents.size]\n }.sort { |a,b|\n a[0] <=> b[0]\n }\n end","def opening_hour\n 11 # 11am\n end","def timeslots\n data['timeslots'].map { |ts|\n Timeslot.new(\n Time.at(ts['start_date']),\n Time.at(ts['end_date'] || ts['start_date']),\n data['timezone']\n )\n }.reject(&:finished?).sort_by(&:start_date)\n end","def list_of_days_worked_out\n array = []\n workouts = Workout.all.find_all do |workout| \n workout.user_id == self.id \n end\n dates = workouts.each do |workout|\n array << workout.date\n end\n array\n end","def hour_select_array(hour, end_time = false)\n # makes list for time selector in Visits view\n hour = DateTime.now.hour if hour == -1\n array = ((hour-4)..(hour+1)).to_a\n hour >= 12 ? array.delete_if { |a| a < 12 } : array.delete_if { |a| a >= 12 }\n array.map! { |h| h < 0 ? h + 24 : h }\n end_time ? [-1] + array : array\nend","def index\n @grouped_schedule_places = SchedulePlace.all\n .order(:weekday_id, :start_time).group_by{ |sp| sp.weekday.name }\n @weekdays = Weekday.all.map { |wd| [wd.name, wd.id] }\n end","def find_open_dates(pages)\n open_dates = Hash.new([])\n\n pages.each do |page|\n page.search(\"a.avail\").each do |link|\n site = link.parent.parent.at_css(\"td.sn div.siteListLabel a\").text.to_sym\n url = link.attr('href')\n\n if open_dates[site].empty?\n open_dates[site] = [url]\n else\n open_dates[site] << url\n end\n end\n end\n\n open_dates\n end","def days_worked\n days = account.account_setting.working_days\n Hash[days.map { |k,v| [k, (v == \"1\")] }]\n end","def users_by_day(days=30)\n joins(:code_cell)\n .where('executions.updated_at > ?', days.days.ago)\n .select('COUNT(DISTINCT(user_id)) AS count, DATE(executions.updated_at) AS day')\n .group('day')\n .map {|e| [e.day, e.count]}\n .sort_by {|day, _count| day}\n .to_h\n end","def commit_time_line events\n events.map(&:date).uniq.sort.each_cons(2).map {|before,after| [before, (after.to_i - before.to_i) / (60 * 60 * 24)] }\nend","def all_matchday_times\n all_matches = fetch_matches\n matchtimes = Hash[(1..38).collect { |md| [md, []] }]\n all_matches.each do |m|\n matchtimes[m['matchday']].push(m['utcDate'])\n end\n matchtimes\n end","def calls_by_hour\n gmt_offset = Time.now.getlocal.gmt_offset\n select = \"EXTRACT(HOUR FROM contacts.arrived + '#{gmt_offset} seconds') AS hour, COUNT(*) AS count\"\n data = answered_contacts.select(select).group('hour')\n\n result = Array.new(24, 0)\n data.each { |d| result[(d['hour'])] = d['count'] }\n result\n end","def employees\n times.map(&:employee).uniq\n end","def weekdays\n if @range\n first = WEEKDAYS.find {|key,val| key.include? @range.first }.last.first\n last = WEEKDAYS.find {|key,val| key.include? @range.last }.last.last\n return (first..last).to_a\n else\n output = []\n @tokens.each do |token|\n WEEKDAYS.each_pair do |labels,wdays|\n output.concat(wdays) and break if labels.include?(token)\n end\n end\n output\n end\n end","def graph_by_day(array)\n if array.empty?\n graph = [[Time.now, 0]]\n else\n array.sort!{|x,y| x.created_at <=> y.created_at}\n finish = array.last.created_at + 1.day\n start = array.first.created_at - 1.day\n days = []\n day = start.midnight\n while day < finish.midnight\n days << day\n day += 1.day\n end\n graph = days.map{|day| [day, array.select{|object| object.created_at > day && object.created_at < day + 1.day}.count]}\n end\n end","def neighborhood_openings(start_date, end_date)\n self.listings.select {|l| l.reservations.where(\"checkout < start_date OR checkin > end_date\")}\n end","def happy_hour\n event_display(\"It's HAPPY HOUR! Everybody let's loose.\")\n group_event_hash_creator({soft_skills: 2, wellbeing: 2})\n end","def consolidate_day\n t = Time.zone.local(2012,12,10);\n\n two_days_ago = t - 2.days\n one_days_ago = t - 1.day\n\n last_couple_days = self.energy_data.where(:year => t.year, :month => t.month, :day => one_days_ago.day) #we're 1-indexed\n dayofInterest = self.energy_data.where(:year => t.year, :month => t.month, :day => t.day, :hour => (1..(t.hour+1))) #we're 1-indexed\n @dayTotals = Array.new\n count = 0\n\n hour_sim = 0\n\n #previous couple days\n last_couple_days.each do |day|\n @dayTotals[count] = [Time.utc(day.year,day.month,day.day,day.hour).to_i*1000, day.power]\n count = count + 1\n end\n\n # create array with [hour, power]\n dayofInterest.each do |day|\n last_hour = day.hour\n @dayTotals[count] = [Time.utc(day.year,day.month,day.day,day.hour).to_i*1000, day.power]\n count = count + 1\n end\n\n @dayTotals\n end","def day_sort\n days_arry = []\n @all_days_arr = [] \n @coordinator_classes.order('day asc,time asc').group_by(&:day).each do |day,gp_class| \n if day.to_i == 0 \n days_arry << {:day => day, :gp_class => gp_class }\n else \n @all_days_arr << {:day => day, :gp_class => gp_class}\n end \n end\n @all_days_arr = @all_days_arr + days_arry\n end","def index\n @events = Event.where('event_start >= ?', Date.today).order(:event_start, :time_begin)\n @date_events_hash = @events.group_by(&:event_start)\n end","def in_transit_days\n \tresult = []\n \tdelivery_duration.times do |num|\n active_day = num_to_day((day_to_num(self.order_day) + num) % 7)\n \t\tresult << active_day if active_day != self.order_day && active_day != self.delivery_day\n \tend\n \tresult\n end","def open_occurrences(days_out = 90, date_start = Time.zone.now)\n schedule = IceCube::Schedule.new(date_start)\n date_end = date_start + days_out.days\n\n # add a recurrence for each business day\n business_days.each do |bd|\n day = bd.name.downcase.to_sym\n schedule.add_recurrence_rule IceCube::Rule.weekly.day(day)\n end\n\n return schedule.occurrences(date_end)\n end","def day_info(date)\n {\n date: date,\n current_period: @user.critical_periods.has_date(date).first,\n close_periods: @user.critical_periods.near_by_date(date).all.to_a,\n }\n end","def hourly\n (0..23).collect { |h| redis.get(\"#{prefix_hourly}:#{Time.now.year}:#{Time.now.month}:#{Time.now.day}:#{h}\").to_i }\n end","def events_in_period\n t0 = start.midnight\n tf = finish.end_of_day\n\n events = []\n while t0 < tf\n t1 = [t0.advance(days: 21), tf].min\n events.concat(dog.stream(t0, t1, tags: @job_tags)[1]['events'])\n t0 = t1\n end\n events\n end","def get_work_intervals(intervals)\n intervals\n .group_by do |interval|\n interval.time_in.to_date\n end\n .values\n end","def index\n @operating_hours = OperatingHour.all\n end","def get_repeated\n if self.repeated.nil?\n return nil\n end\n\n days = Array.new\n DAY_VALUES.each do |k,v|\n if (self.repeated % v) == 0\n days << k\n end\n end\n\n return days\n end","def all_potential_meetings\n meetings = []\n day_meetings.each do |day|\n @timeline_week_count.times do |wk|\n meetings << (@beginning_of_first_week + wk.weeks).date_of_upcoming(day)\n end\n end\n meetings.sort\n end","def days_of_week_array\n dow = days_of_week_hash\n\n @days_of_week_array ||= [\n dow[:sunday],\n dow[:monday],\n dow[:tuesday],\n dow[:wednesday],\n dow[:thursday],\n dow[:friday],\n dow[:saturday]\n ]\n end","def hours\n response[\"hours\"]\n end","def time_range_for(open_time, close_time)\n content_tag :span, class: 'opening-hours' do\n \"#{hour_content_for(open_time, 'opens-at')} - \" \\\n \"#{hour_content_for(close_time, 'closes-at')}\".html_safe\n end\n end","def group_entries entries\n @time_cache ||= {}\n entries.group_by do |title, _|\n begin\n time = @time_cache[title]\n (time || parse_date(title)).strftime '%Y-%m-%d'\n rescue NoMethodError, ArgumentError\n time, = title.split ' ', 2\n parse_date(time).strftime '%Y-%m-%d'\n end\n end\n end","def get_list_for(day, hour, dayname, today)\n months = [_(:january), _(:february), _(:march), _(:april), _(:may), _(:june),\n _(:july), _(:august), _(:september), _(:october), _(:november), _(:december)]\n nobroad = \" #{_(:no_broadcast_on)}\"\n broad = \"#{_(:broadcast_on)}\"\n\n aday = DatesSchedule.get_day(@language, day)\n if aday.kind_of?(Array) and !aday.blank?\n d = aday[0].d\n m = aday[0].m - 1\n else\n d = 1\n m = 0\n end\n dm = \"#{d} #{months[m]}\"\n\n alist = Listing.get_day(@language, day)\n return \"
#{nobroad} #{dayname}, #{dm}
\" if alist.blank?\n list = \"
#{broad} #{dayname}, #{dm}
\"\n alist.each_with_index { |item, index|\n time = sprintf(\"
end utility methods private The methods below should not be private methods, as they will be called from outside of this file. Namely, it will be taken care of by the controller, with input coming from the statistics UI template. Statistic creation initially goes through a pipeline of operations which successively cleans the unstructured data and organizes it in such a way that analytics can be made possible. Currently Statistic creation is done during the destruction of a Scenario, whereby the bash data is brought down from an s3 bucket and parsed into a nested Hash, mapping users to timestamps to commands. The methods defined below are helper methods that allow the investigator to reveal certain aspects of the data.
def perform_analytics(data)
# input -> data: a hash of the form { users -> list of strings of commands }
# output -> results: a nested array of two-element arrays
results = [] # [[ string, count ]] or {string => count}, chartkick can deal with either.
frequencies = Hash.new(0)
data.keys.each do | user |
data[user].each do | cmd |
if !frequencies.include?(cmd)
frequencies[cmd] = 1
else
frequencies[cmd] += 1
end
end
end
return frequencies
end
[
"def allow?(name) \n return return_symbol if name_matchers.reject{|name_matcher| !name.match(name_matcher) } \n end",
"def valid_name (name)\r\n /^\\w+$/.match (name)\r\n end",
"def name_can_not_be_greg\n if self && self.name.downcase == \"greg\"\n self.errors.add(:name, \"Can not be Greg\")\n end \n end",
"def validate_name(name)\n !name.scan(/\\D/).empty?\n end",
"def validate_name(arg = nil)\n set_or_return(:name, arg, :kind_of => String, :callbacks => {\n \"user must be string of word characters and Engine ID should be either empty string or 5 to 32 octets separated by colons\" => lambda {\n |name| !@@title_pattern.match(name).nil?\n }\n })\n end",
"def name_valid?(name)\n name.nil? || /^[A-Za-z]{2,}$/.match?(name)\n end",
"def validate_name(arg=nil)\n set_or_return(:name, arg, kind_of: String, callbacks: {\n 'user must be string of word characters and ' \\\n 'Engine ID should be either empty string or ' \\\n '5 to 32 octets separated by colons' => lambda do |name|\n !@@title_pattern.match(name).nil?\n end,\n })\n end",
"def validate_name\n\t\t\tunless Nacreon::NameRX.match(name)\n\t\t\t\terrors.add(:name,\n\t\t\t\t\t'must contain only letters, numbers, and \"-\".')\n\t\t\tend\n\t\tend",
"def valid_name!(name)\n not_empty!(name)\n unless [String, Symbol].include?(name.class)\n coercion_error!\n end\n name\n end",
"def validate_name\n if name.match(/\\|/)\n errors.add(:name, \"cannot have a '|' character\")\n end\n end",
"def your_name_is_not_dumb\n if name.include?(\"dumb\")\n errors.add(:name, \"is dumb\")\n end\n end",
"def get_valid_name\r\n while true \r\n name = gets.chomp\r\n break if valid_name(name)\r\n puts \"Please only use letters, numbers or '_' in your name\"\r\n end\r\n name\r\n end",
"def correct_name\n name == \"Chris\" || name == \"Blake\"\nend",
"def correct_name\n name == \"Chris\" || name == \"Blak\"\nend",
"def match_name?(gotten_name, requested_name)\n gotten_name.text.strip.downcase == requested_name.downcase\n end",
"def name_valid_format\n if name.present? and not name.match(/[\\w]+([\\s]+[\\w]+){1}+/)\n errors.add :name , \"must be seperated by space and should not contain any special characters.\"\n end\n end",
"def name_valid(name)\n if !name.empty?\n self.name = name\n return true\n end\n end",
"def is_valid_name?(name)\n return name.class == String && name.match(/[a-zA-Z]+?/)\n end",
"def name_valid(name)\n if !name.empty?\n self.name = name\n return true\n else\n return false\n end\n end",
"def name_is_valid?(user, name)\n\t\t\tuser.respond_to? \"#{name}s_participating\" and [\"event\",\"class\",\"game\", \"offering_session\", \"personal_trainer\", \"group_training\"].include? name.underscore\n\t\tend",
"def name_check(name)\n if name.nil? or name.empty? or name =~ /\\W+/ or name == \"0\"\n\n #raise an error in case of invalid input\n raise ArgumentError.new(\"Error - invalid name\")\n end\n #capitalize the first letter of the name\n name = name.capitalize\n end",
"def name_check(name)\n if name.nil? or name.empty? or name =~ /\\W+/ or name == \"0\"\n\n #raise an error in case of invalid input\n raise ArgumentError.new(\"Error - invalid name\")\n end\n #capitalize the first letter of the name\n name = name.capitalize\n end",
"def carefull_name?(name)\n not !! (name =~ /\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}/)\nend",
"def name_legal?\n if @params\n if self.name.include?(\"\\\\\") or self.name.include?(\"/\")\n errors.add(\"Invalid name:\", \"Slashes not allowed in names.\")\n elsif self.name == \"\"\n errors.add(\"Invalid name:\", \"No name provided.\")\n end\n end\n end",
"def _validate_name(name)\n if name =~ %r{/}\n results.add_error('name', 'The name of a spec should not contain ' \\\n 'a slash.')\n end\n\n if name =~ /\\s/\n results.add_error('name', 'The name of a spec should not contain ' \\\n 'whitespace.')\n end\n\n if name[0, 1] == '.'\n results.add_error('name', 'The name of a spec should not begin' \\\n ' with a period.')\n end\n end",
"def test_only_name_argument\n \n output = `./cheers Abby`\n expected = <<EOS\n Give me an... A\n Give me a... B\n Give me a... B\n Give me a... Y\n Abby’s just GRAND!\n Try again with `./cheers.rb [Name] [MM/DD Birthday]\nEOS\n assert_equal expected, output\n end",
"def getname\n #getting user details \n begin \n print\" \\n Plz Enter your name:\"\n @name=gets.chomp\n if (@name=~ /^[A-Z a-z]+$/ and @name.length<=10) #check regular expression for correct name\n \n break #break loop if user enter corrcect name\n else \n \n puts\"Enter Valid name.......\"\n end \n\n \n end while (@name!=~ /^[-a-z]+$/) #@continue until user not enter correct name\n end",
"def name_validator\n puts \"Whats your characters name\"\n name = gets.strip\n until name[/\\d/].nil? do #uses regular expressions to see if the name has anything other then letters\n puts \"Your name must only have letters input again\"\n name = gets.strip\n end\n return name\nend",
"def is_valid_name(str)\n\tnames_arr = str.split(\" \")\n if names_arr.length < 2\n return false\n end\n\n \tnames_arr.each do |name|\n if check_case(name)\n return true\n \n else\n return false\n end\n end \nend",
"def test_username_with_invalid_examples\n person = @valid_person\n invalid_usernames = %w{rails/rocks web2.0 javscript:something ME}\n invalid_usernames.each do |username|\n person.username = username\n assert !person.valid?, \"#{username} shouldn't pass validation, but does\"\n end\n end",
"def valid_name?(name)\n !!(name =~ NAME_REGEX)\n end",
"def hand_out_gift(name)\n $names ||= [] # conditional assignment, global variable\n if $names.include?(name.strip)\n \traise ArgumentError.new('Child already got a gift from Santa')\n else \n \t$names << name.strip\n end\n #names.include?(name) ? names << name : raise Argument Error.new(\"#{name} has gotten his gift from Santa\") # => didn't work\nend",
"def show_me(name)\n !!name.match(/\\A[A-Z][a-z]+(-[A-Z][a-z]+)*\\z/)\nend",
"def name_filter\n self.gsub(/[^a-zA-Z\\s\\-\\(\\)]/, '')\n end",
"def username_is_allowed #same as 'validates_exclusion_of' method\n if FORBIDDEN_USERNAMES.include?(username) # checking to see if the username is in FORBIDDEN_USERNAMES\n errors.add(:username, \"has been restricted from use.\") # if the username is in FORBIDDEN_USERNAMES, it will add an error to the errors array\n end\n end",
"def ask_name\n begin\n connection.puts \"What's your name? (10 alphanum/spaces only, please.)\"\n # Only grab 10 characters.\n name = connection.gets.chomp[0..10]\n end while !only_chars? name\n name\n end",
"def name_is_valid\n errors.add(:name,\"Invalid string for name.\") unless name_is_valid?\n end",
"def username_is_acceptable\n errors.add(:username, \"^That username is unacceptable\") unless User.verify_username_is_acceptable(self.username)\n end",
"def normalize_input\n self.name = name.downcase\n end",
"def parse_name\n\tname = ARGV.shift\n\tunless %w(jo caro wir).include?(name)\n\t\tname = 'jo' \n\t\tputs \"assuming jo...\"\n\tend\n\treturn name\nend",
"def is_valid_name(name)\n name_arr = name.split(\" \")\n if (name_arr.length > 1)\n name_arr.each do |word|\n if !(word[0] == word[0].upcase && word[1..-1] == word[1..-1].downcase)\n return false\n end\n end\n else\n return false\n end\n true\nend",
"def is_valid_name(str)\n\tnames = str.split(\" \")\n \tif names.length < 2\n return false\n end\n \n \tnames.each do | name |\n if(name[0] != name[0].upcase || name[1..-1] != name[1..-1].downcase)\n return false\n end\n end\n return true\nend",
"def validate_username_reserved\n return unless username_reserved?\n\n errors.add(:username, :exclusion)\n end",
"def allow_name_change?\n true\n end",
"def valid_name?(name)\n name =~ /^[^\\/?*:;{}\\\\]+$/\n end",
"def get_name\n ask(\"give me a name to submit to local arena\") { |q|\n q.validate = /\\w+/\n }\nend",
"def name?(name)\n name = name&.strip\n !(name.blank? || name.match?(%r{(N[/\\\\]+A|UNKNOWN)}i))\n end",
"def validateName(name)\n if (name == nil)\n return false\n end\n \n return true # TODO This is wrong. Finish this function.\nend",
"def name_is_valid\n errors.add(:name,'Invalid empty string for name.') unless name_is_valid?\n end",
"def request_user_name\n puts \"Please enter your name: \"\n name = gets.chomp\n end",
"def process_name\n\t\tlower_case_name = params[:input].downcase\n\t\tif lower_case_name == \"alex\" \n\t\t\t@name = \"Howdy\"\n\t\telsif lower_case_name == \"fitz\"\n\t\t\t@name = \"nice\"\n\t\telse\n\t\t\t@name = \"What are you staring at\"\n\t\tend\n\t\tRails.logger.info \"Lower case name was: \" + lower_case_name\t\t\t\t\n\tend",
"def role_name_must_be_whitelisted\n unless role_name.present? &&\n Employable::RoleStories.role_names.include?(role_name.to_sym)\n role_names_to_sentence = Employable::RoleStories.role_names.to_sentence(\n two_words_connector: ' or ',\n last_word_connector: ', or '\n )\n errors.add(:role_name, \"must be one of \\\"#{role_names_to_sentence}\\\"\")\n end\n end",
"def name_invalid\n errors.add(:name, :unknown)\n end",
"def prompt_name\n puts \"Please input a name:\"\n # split name on spaces\n name_parts = gets.chomp.split\n\n if name_parts.count != 2\n raise \"Uh-oh, finnicky parsing!\"\n end\n\n name_parts\nend",
"def pick_username(username)\n name = username\n blacklist = Set.new\n\n while user_exists?(name)\n blacklist << name\n new_name = LoginUserManager.pick_username(name, blacklist)\n\n if blacklist.include?(new_name)\n raise RangeError, \"Misbehaved login policy chose blacklisted name #{new_name}\"\n else\n name = new_name\n end\n end\n\n name\n end",
"def is_valid_name(name)\n return false if name.split.length < 2\n name == format_name(name)\nend",
"def allowNameService()\n banner(\"Allow Name Service\")\n nameServers = getNameServers()\n @NameServersName = \"NameServers\"\n declareSet(@NameServersName, nameServers)\n permit(@NameServersName, @allAgentsName, \"AllowNameService-I\")\n permit(@allAgentsName, @NameServersName, \"AllowNameService-II\")\n end",
"def named_filter; end",
"def validate_name?\n # if you create user from admin interface(or as a team member), then \"name\" param is provided, it is present or blank - not nil\n !name.nil?\n end",
"def name_is_valid?(user, name)\n\t\tuser.respond_to? \"#{name}s_administrating\" and (this_is_offering?(name) || this_is_multisession?(name))\n\tend",
"def new_name(data)\n data.strip!\n if data.nil?\n ask_new_name\n return\n end\n\n data.capitalize!\n if $manager.player_exist? data\n output \"A character with that name already exists, please choose another.\"\n ask_new_name\n return\n elsif data.length > 20 or data.length < 3\n output \"Please choose a name less than 20 letters long but longer than 2 letters.\"\n ask_new_name\n return\n elsif data !~ /^[A-Z][a-z]+$/\n output \"Only letters a to z, please.\"\n ask_new_name\n return\n end\n\n @new_name = data\n ask_sex\n end",
"def sanitize_name(str)\n str.gsub(' ','_').downcase.gsub(\"&\", \"and\")\n end",
"def match?(name); end",
"def safe_name\n name.gsub(/(^[0-9]*|[^0-9a-z])/i, '')\n end",
"def isValidUserName?(userName)\n\t\tuserName =~ /^[a-z_][a-z0-9_-]*$/\n\tend",
"def set_name\n\t\tresponse = false\n\t\twhile not response\n\t\t\tputs \"What is your name?\"\n\t\t\tresponse = gets.chomp.downcase.capitalize!\n\t\t\t# entry_ok?(response) # Need to implement is_alpha check \n\t\tend\n\t\tresponse\n\tend",
"def exclude_name(name)\n @rest_call.append_headers(\"X-Nuage-FilterType\", \"predicate\")\n @rest_call.append_headers(\"X-Nuage-Filter\", \"name ISNOT '#{name}'\")\n end",
"def greet1\n print 'Enter your name : '\n name = gets.to_s.chomp\n if name == 'Alice' || name == 'Bob'\n puts 'Hello #{name}'\n else\n puts 'Hello'\n end\nend",
"def name=(name)\n raise ArgumentError.new('El nombre deberia conteniar al menos dos palabras') unless name =~ /\\w+\\s+\\w+.*$/\n @name = name\n end",
"def name_is_valid?(user, name)\n\t\t\tuser.respond_to? \"#{name}s_membership\" and this_is_act?(name)\n\t\tend",
"def validate_name(value)\n return false if(value.to_s.length >= MAX_NAME_LENGTH)\n return true\n end",
"def req_name\n\t\tputs \"What is your name?\"\n\t\t@name = gets.chomp\n\tend",
"def enter_name(name)\n return @player_name = 'Anonymus' if name.empty?\n\n @player_name = name[0...18]\n end",
"def initialize(name)\n if name == \"\"\n @name = \"User\"\n else\n @name = name[0].upcase + name[1..-1].downcase\n end\n end",
"def valid_name?(nm)\n\t\treturn false unless (nm =~ VALID_NAME)\n\t\ttrue\n\tend",
"def match_author_exact(name, reject = false)\n name = name.downcase || \"\"\n proc = Proc.new { |entry|\n author = entry.author.downcase || \"\"\n author.include?(name)\n }\n reject ? self.entries.reject(&proc) : self.entries.find_all(&proc)\n end",
"def valid_user_name(login, name)\n valid = false\n imperfect = false\n email = email(name, login, false)\n if email\n valid, imperfect = true, false\n else\n email = email(name, login, false, true)\n valid, imperfect = true, true if email\n end\n [valid, imperfect]\n end",
"def validate_class_name(name)\n only_basic_type(name) || name.gsub(/-/, \"_\").camelcase\n end",
"def is_valid_name(str)\r\n\twords = str.split(\" \")\r\n \tif words.length < 2\r\n return false\r\n end\r\n \twords.each do |word|\r\n if !capitalized(word)\r\n return false\r\n end\r\n end\r\n return true\r\nend",
"def name_checker(player_name)\n\tputs \"hi #{player_name}\"\nend",
"def playerNameValidator\n puts \"\\\"What's your name?\\\"\"\n playerName = gets.chomp.capitalize\n until (playerName.length > 1) && (playerName.is_a?String)\n puts \"\\\"I'm sorry, I didn't hear you well. What's your name?\\\"\"\n playerName = gets.chomp.capitalize\n end \n return playerName\nend",
"def username_is_allowed\n\t\tif FORBIDDEN_USERNAMES.include?(username)\n\t\t\terrors.add(:username, \"has been restricted from use.\")\n\t\tend\n\tend",
"def name_is_valid?\n return false unless not_nil_and_string(self.name)\n return self.name.length > 0\n end",
"def name_is_valid?\n return false unless not_nil_and_string(self.name)\n return self.name.length > 0\n end",
"def scoped_name_is(name)\n name = SqlHelper::escapeWildcards(name)\n where do\n first_name.op('||', ' ').op('||', last_name).like(name) | \n first_name.op('||', last_name).like(name) \n end\n end",
"def is_named? n\n n && n.downcase == @name\n end",
"def filter_argument; end",
"def greet(name,owner)\n return \"Hello boss\" if name.eql? owner\n return \"Hello guest\" \nend",
"def cleanse_name\n return if self.name.nil?\n self.name = self.name.strip\n self.name = nil if self.name.length == 0\n end",
"def sanitize_name(name)\n name.gsub!(' ', '_')\n name.downcase!\n name.gsub!('-', '_')\n name.gsub!('\\'', '_')\n name\n end",
"def username_is_email\n errors.add(:userName,'is not in email format') unless userName=~ /^([^@\\s]+)@((?:[-a-z0-9]+\\.)+[a-z]{2,})$/i\n end",
"def valid_name(input)\n while true\n if input =~ /^(\\w){2,}$/\n return input.downcase\n else\n puts \"Try again! Only use letters, numbers, or underscore\"\n input = gets.chomp\n end\n end\nend",
"def _sanitize_name(name)\n name.to_s.tr_s('^a-zA-Z0-9', '_')\n end",
"def exempt?\n if @a_name.include?(\"book\") || @a_name.include?(\"chocolate\") || @a_name.include?(\"headache\")\n true\n else \n false\n end\n end",
"def sanitize_name\n self.name = Tag.sanitize_name(self.name)\n end",
"def greet(name)\n puts \"hi #{name}!\"\n if name == \"nico\" || name == \"nicolas\"\n puts \"that's a great name \\n\"\n end\nend",
"def are_you_playing_banjo(name)\n name[0] =~ /[Rr]/ ? \"#{name} plays banjo\" : \"#{name} does not play banjo\"\nend",
"def test_no_alice\n skip\n names = [\"chuck\", \"charlene\", \"cory\", \"chris\", \"carl\"]\n # write code here\n refute has_alice\n end",
"def name=(value)\n if value == \"\"\n raise \"Name cannot be blank!\"\n elsif value.is_a? Integer\n raise \"Name cannot contain numbers!\"\n else\n if value.is_a? String\n @name = value\n end\n end\n end",
"def possible_name_params\n params.require(:possible_name).permit(:user_id, :name, :first_lastname, :second_lastname)\n end",
"def name_parameterized\n parameterize(@name)\n end"
]
Class method version of Gorilla::Unitnormalize, to handle, e.g., Enumerable, Numeric, and Range objects.
def normalize input, &block
case input
when Range
normalize(input.min, &block)..normalize(input.max, &block)
when Enumerable
input.map { |unit| normalize unit, &block }
when Numeric
normalize Unit.new(input), &block
else # Unit, etc.
input.normalize(&block)
end
end
Instantiates a new unit for the class. Assumes the base unit if one is defined. ==== Example Gorilla::Unit.new 1 => (1) Gorilla::Time.new 1 => (1 second) Gorilla::Time.new 1, :minute => (1 minute)
def initialize amount, unit = self.class.base_unit
if unit && self.class.rules[unit].nil?
raise TypeError, "no such unit #{self.class}:#{unit}"
elsif unit.nil? && !instance_of?(Unit)
raise ArgumentError, "unit can't be nil for #{self.class}"
end
@amount, @unit = (amount.to_r if amount), unit
end
Converts an instance to a new unit. ==== Example Gorilla::Weight.new(1, :pound).convert_to(:ounce) => (16 ounces)
def convert_to other_unit
return dup if unit == other_unit
unless self.class.rules.key? other_unit
raise TypeError, "no such unit #{self.class}:#{other_unit}"
end
if self.class.rules[unit][:rules]
amount = self.class.follow_rules normalized_amount, unit, other_unit
return self.class.new amount, other_unit
else
amount = normalized_amount
end
new = self.class.new amount
new.unit = other_unit
new
end
Retrieve all CPEs and their associated variants. The 'live' field in the output indicates whether any advisory has been shipped for that CPE and variant. This API does not require authentication. :apiurl: /api/v1/security/cpes :apimethod: GET :apiresponseexample: file:publican_docs/Developer_Guide/api_examples/cpes.json
def cpes
@variants = Variant.all.group_by{|variant| variant.cpe || ''}.sort_by{|cpe,v| cpe}
end
def say_bye
if @names.nil?
puts "..."
elsif @names.respond_to?("join")
# join the list elements
puts "Goodbye #{@names.join(", ")}. Come back soon!"
else
puts "Goodbye #{@names}. Come back soon!"
end
end
If Pro user passes validations (email, password, etc.), then call Stripe and tell it to set up a subscription upon charging the customer's card. Stripe responds back with customer data. Store customer.id as the customer token and save the user.
def save_with_subscription
if valid?
customer = Stripe::Customer.create(description: email, plan: plan_id, card: stripe_card_token)
self.stripe_customer_token = customer.id
save!
end
end
[
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n if current_user.admin?\n # Role management\n # don't allow :destroy, :edit, :create\n # - destroy adds a 'delete' button that\n # - could be clicked accidentally\n # - would be very infrequently used (if ever)\n # - implications of edit are unclear for associated actions\n # - create is meaningless without associating actions which happens in code.\n can [:read, :add_user, :remove_user], Role\n end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role if current_user.admin?\n\n can [:fa_overview], ActiveFedora::Base\n can [:advanced], ActiveFedora::Base\n can [:streets], ActiveFedora::Base\n can [:pdf_page], ActiveFedora::Base\n can [:pdf_page_metadata], ActiveFedora::Base\n can [:bookreader], ActiveFedora::Base\n can [:imageviewer], ActiveFedora::Base\n can [:streetsviewer], ActiveFedora::Base\n can [:fa_series], ActiveFedora::Base\n can [:audio_transcriptonly], ActiveFedora::Base\n can [:video_transcriptonly], ActiveFedora::Base\n end",
"def custom_permissions\n discover_permissions\n export_sets_permissions\n batches_permissions\n preservation_events_permissions\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def custom_permissions\n if current_user.admin?\n can :manage, :all\n end\n end",
"def custom_permissions\n can [:file_status, :stage, :unstage], FileSet\n\n if current_user.ingest_from_external_sources?\n end\n\n if current_user.manage_users?\n can [:show, :add_user, :remove_user, :index], Role\n end\n\n if current_user.manage_roles?\n can [:create, :show, :index, :edit, :update, :destroy], Role\n end\n\n if current_user.run_fixity_checks?\n can [:fixity], FileSet\n end\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n # Admin user can create works of all work types\n can :create, curation_concerns_models\n end\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n end\n\n# if current_user.contentadmin?\n# can [:create, :destroy], GwWork\n# can [:create, :destroy], GwEtd\n# end\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\nif current_user.admin?\n\t can [:create, :show, :add_user, :remove_user, :index], Role\n\t end\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n\n\n\n end",
"def custom_permissions\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n can [:create], Collection\n can [:discover], Hydra::AccessControls::Embargo\n can [:discover], Hydra::AccessControls::Lease\n can [:create], [ CurationConcerns.config.curation_concerns ]\n can [:destroy], ActiveFedora::Base\n can [:permissions], [ CurationConcerns.config.curation_concerns ]\n end\n\n # Limits deleting objects to a the admin user\n #\n #if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n #end\n\n if current_user.has_role?('collection.manager')\n # can [:create, :show, :index, :edit, :update, :destroy], Collection\n can [:create], Collection\n end\n\n if current_user.has_role?('collection.depositor') or current_user.has_group_role?('collection.depositor')\n # can [:create, :show, :index, :edit, :update, :destroy], [ CurationConcerns.configuration.curation_concerns ]\n can [:create], [ CurationConcerns.config.curation_concerns ]\n # can [:show], Collection\n end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def custom_permissions\n alias_action :show, :manifest, to: :read\n alias_action :color_pdf, :pdf, :edit, :browse_everything_files, :structure, :file_manager, to: :modify\n roles.each do |role|\n send \"#{role}_permissions\" if current_user.send \"#{role}?\"\n end\n end",
"def custom_permissions\n alias_action :show, :manifest, to: :read\n alias_action :color_pdf, :pdf, :edit, :browse_everything_files, :structure, :file_manager, to: :modify\n roles.each do |role|\n send \"#{role}_permissions\" if current_user.send \"#{role}?\"\n end\n end",
"def custom_permissions # rubocop:disable Metrics/CyclomaticComplexity\n can :read, ApplicationPresenter, &:can_read?\n can :read, UsersPresenter, &:can_read?\n can :read, UserPresenter, &:can_read?\n can :read, RolesPresenter, &:can_read?\n can :read, RolePresenter, &:can_read?\n\n can :read, Press\n\n grant_press_analyst_abiltites if press_analyst?\n grant_press_editor_abilities if press_editor?\n grant_press_admin_abilities if platform_admin? || press_admin?\n grant_platform_admin_abilities if platform_admin?\n end",
"def load_permissions\n authorize! :manage, :all\n end",
"def custom_permissions\n #Collection Manager Permissions\n #Higher power than edit user...[Dont want edit users to be able to DELETE a COLLECTION??, (Delete a DO?)]\n if current_user.applicable_policy?(SETTING_POLICY_COLLECTION_MANAGER)\n #Marked as being able to :manage_collection\n can :manage_collection_flag, :all\n can :create, [DRI::Batch, DRI::GenericFile]\n end\n\n\n #Admin Permissions\n if current_user.applicable_policy?(SETTING_POLICY_ADMIN)\n can :admin_flag, :all\n #Disabled for now..\n can :manage, :all\n end\n\n #Create_do flag (alias for :edit collection)\n can :create_do, String do |pid|\n test_create(pid)\n end\n\n can :create_do, DRI::Batch do |collection|\n test_create(collection)\n end\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n\n if user_groups.include? ['all_project_writers']\n can [:create], PulStore::Base\n can [:create], PulStore::Lae::Box\n can [:create], PulStore::Lae::Folder\n can [:create], Pulstore::Lae::HardDrive\n end\n\n if user_groups.include? ['lae_project_writers']\n can [:create], PulStore::Lae::Box\n can [:create], PulStore::Lae::Folder\n can [:create], Pulstore::Lae::HardDrive\n end \n\n if user_groups.include? ['all_project_writers']\n can [:destroy], PulStore::Base\n end\n\n if user_groups.include? ['lae_project_readers', 'all_project_readers' ]\n can [:show], PulStore::Base\n end\n end",
"def custom_permissions\n if admin?\n can [:confirm_delete], ActiveFedora::Base\n can [:allow_downloads, :prevent_downloads], AdminSet\n\n can :manage, Spotlight::HomePage\n can :manage, Spotlight::Exhibit\n end\n\n can :read, Spotlight::HomePage\n can :read, Spotlight::Exhibit\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def paranoid_permissions\n true\n end",
"def custom_permissions\n if user_groups.include?(\"admin\")\n can :manage, :all\n end\n end",
"def standard_authorized_user_rights\n public_access + protected_access \n end",
"def custom_permissions\n can [:create], Account\n end",
"def custom_permissions\n can [:create], Account\n end",
"def load_permissions \n @current_permissions = current_user.role.permissions.collect{|i| [i.subject_class, i.action]} \n end",
"def set_permissions\n self.permissions ||= \"guest\"\n end",
"def smart?; self.permission_level = 2; end",
"def permission_set\n if attributes[\"InheritedSecurity\"]\n supersite.permission_set\n else\n PermissionSet.new(self)\n end\n end",
"def write_permission_check(*args)\n # Don't prevent writes if creating a new object (anyone should be able to do this)\n return unless self.exist?\n\n if LinkedData.settings.enable_security\n user = nil\n options_hash = {}\n args.each {|e| options_hash.merge!(e) if e.is_a?(Hash)}\n user = options_hash[:user]\n\n # Allow a passed option to short-cut the security process\n return if options_hash[:override_security]\n\n user ||= Thread.current[:remote_user]\n\n reference_object = self\n\n # If we have a modified object, we should do the security check\n # on the original. This allows a user to change the ownsership of\n # an object without having to add the owner and have the new owner\n # remove the original owner.\n reference_object = self.class.find(self.id).first if self.modified?\n\n # Allow everyone to write\n return if reference_object.access_for_all?\n\n # Load attributes needed by security\n if reference_object.access_control_load?\n # Only load ones that aren't loaded so we don't overwrite changes\n not_loaded = []\n reference_object.access_control_load_attrs.each do |attr|\n not_loaded << attr unless reference_object.loaded_attributes.include?(attr)\n end\n reference_object.bring(*not_loaded) unless not_loaded.empty?\n end\n\n writable = reference_object.writable?(user)\n raise LinkedData::Security::WriteAccessDeniedError, \"Write access denied: #{reference_object.id}\" unless writable\n end\n end",
"def user_permissions\n if user_signed_in? && (current_user.is_logistics? || current_user.is_clerical? || current_user.is_vendor? || current_user.is_customer?)\n authorize! :edit, Element\n end\n end",
"def load_permissions\n @current_permissions = current_user.role.permissions.collect{|i| [i.subject_class, i.action]}\n end",
"def load_permissions\n \n @current_permissions = current_user.role.permissions.collect{|i| [i.subject_class, i.action]}\n end",
"def has_permission?\n return true if administrator?\n \n # Load the Model based on the controller name\n klass = self.controller_name.classify.constantize\n \n # Load the possible parent requested\n @parents = (klass.has_parent?) ? get_parents_from_request_params(klass, params) : nil\n \n # Load the resource requested\n if params[:id]\n if [\"index\", \"destroy\", \"update\"].include?(params[:action]) && klass.respond_to?(:in_set)\n @resource = klass.in_set(params[:id])\n @resource = @resource.first if @resource.size == 1\n else\n @resource = klass.find(params[:id])\n end\n end\n \n # Let's let the Model decide what is acceptable\n # NOTE: It is still the concrete controller's job to filter inaccessible resources (accessed via the index)!\n # This presumably happens in the with_parent named scope\n \n authorized = case params[:action]\n when \"edit\", \"update\"\n if !@resource.is_a?(Array)\n return @resource.updatable_by?(current_user, @parents) # this is 'returned' to authorized\n end\n \n verify_set_accessablility(@resource, :updatable_by?) do |unauthorized_ids|\n permission_denied(\n :status => :conflict,\n :message => \"#{unauthorized_ids.to_a.join(',')} is not available for update.\"\n ) if unauthorized_ids.size > 0\n end\n true # if it gets past verification, authorized is true\n \n when \"destroy\" \n if !@resource.is_a?(Array)\n return @resource.deletable_by?(current_user, @parents)\n end\n \n verify_set_accessablility(@resource, :deletable_by?) do |unauthorized_ids|\n permission_denied(\n :status => :conflict,\n :message => \"#{unauthorized_ids.to_a.join(',')} is not available for deletion.\"\n ) if unauthorized_ids.size > 0\n end\n true # if it gets past verification, authorized is true\n \n when \"index\" then klass.indexable_by?(current_user, @parents)\n when \"new\", \"create\" then klass.creatable_by?(current_user, @parents)\n when \"show\" then @resource.readable_by?(current_user, @parents)\n else check_non_restful_route(current_user, klass, @resource, @parents)\n end\n \n permission_denied unless authorized\n \n #rescue NoMethodError => e\n # Misconfiguration: A RESTful_ACL specific method is missing.\n #raise_error(klass, e)\n #rescue\n # Failsafe: If any funny business is going on, log and redirect\n #routing_error\n #end\n end",
"def permits_write_access_for(user)\n end",
"def set_default_permissions!\n # Always allow to read the id\n let :read, :id\n # These shouldn't change after the first save.\n let :write, [ :id, :created_at ], :if => :new?\n # These can always change.\n let :write, :updated_at\n end",
"def permitted?(model_name, requested_flags = 0)\n return false if self.kind != Kind::ROLE\n return true if admin?\n\n p = self.model_permissions.find_by_model(model_name)\n if requested_flags == 0\n p\n else\n p && p.permitted?(requested_flags)\n end\n end",
"def my_permissions\n @my_permissions ||= self.roles.map {|r| r.permissions.map {|p| p.name}}.flatten.freeze\n end",
"def permissions_policy(&block); end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n\n # TODO: This area looks like it needs to be refactored.\n\n if current_user.admin?\n editor_abilities\n upload_abilities\n publish_abilities\n roles_abilities\n hard_delete_abilities\n import_admin_abilities\n user_abilities\n group_abilities\n can [:create, :destroy, :update], FeaturedWork\n can [:manage], Hydra::Admin::Collection\n\n can :create, TinymceAsset\n can [:create, :update], ContentBlock\n can :read, ContentBlock\n can :characterize, GenericFile\n end\n\n\n if current_user.manager?\n upload_abilities\n publish_abilities\n roles_abilities\n import_user_abilities\n can [:manage], Hydra::Admin::Collection do |admin_set|\n # Can manage admin sets within their assigned unit.\n current_user.osul_groups.include? admin_set.unit_group\n end\n can [:manage], Osul::Group do |group|\n # Can manage the groups the user is in or the groups of the units a user is assigned to.\n current_user.osul_groups.include? group or current_user.osul_groups.include? group.unit\n end\n can [:create], Osul::Group\n can [:create, :destroy, :update], FeaturedWork\n end\n\n if current_user.data_entry?\n upload_abilities\n publish_abilities\n no_admin_set_abilities\n end\n\n if current_user.data_entry_student?\n upload_abilities\n no_admin_set_abilities\n end\n\n unless current_user.public?\n can :view_full, GenericFile\n end\n\n if current_user.role.nil?\n no_file_abilities\n no_admin_set_abilities\n end\n end",
"def build_permissions(perms, other)\n perms.permits! :read\n perms.permits! :write if self == other\n end",
"def permissions\n @resource_permissions\n end",
"def admin_permissions\n can [:manage], :all\n end",
"def admin_permissions\n can [:manage], :all\n end",
"def mass_assignment_authorizer(role = :default)\n if accessible == :all\n self.class.protected_attributes\n else\n super + (accessible || [])\n end\n end",
"def set_perms\n self.perms = Access.for_user(self)\n end",
"def permissions\n attribute_prop(5)\n end",
"def deny_all_access\n @permissions = 0\n end",
"def user_permission\n has_controller_permission?('user')\n end",
"def permits_read_acccess_for(user)\n end",
"def enforce_delete_permissions\n enforce_edit_permissions\n end",
"def permission\n Ricer::Irc::Permission.by_permission(self.permissions, authenticated?)\n end",
"def setable_permissions\n setable_permissions = Erp::AccessControl.permissions - Erp::AccessControl.public_permissions\n setable_permissions -= Erp::AccessControl.members_only_permissions if builtin == BUILTIN_NON_MEMBER\n setable_permissions -= Erp::AccessControl.loggedin_only_permissions if builtin == BUILTIN_ANONYMOUS\n setable_permissions\n end",
"def project_permissions\n user.project_permissions(rule.project)\n end",
"def standard_authorized_user_rights\n Lockdown::System.public_access + Lockdown::System.protected_access \n end",
"def permissions = {}",
"def make_permission_protected(name)\n permission(name).is_protected\n end",
"def permissions( force_reload = false )\n\n # Two levels of joins here, so can't use has_many :through\n if force_reload\n @permissions = nil \n @permissions_by_class_and_op = {}\n end\n\n cond_str = 'role_id in ' + self.class.role_assigned_cond( '?' )\n if !instance_variable_defined?(\"@permissions\") || @permissions.nil?\n @permissions ||= Permission.where([cond_str, self]).to_a\n end\n\n return @permissions\n end",
"def define_global_privileges\n can :read, Project, public_can_view?: true\n can :index, Project\n can :read, Group\n end",
"def permissions\n User.do_find_permissions session_id: kb_session_id\n end",
"def role\n permission_type\n end",
"def permitted_to! (privilege, options = {} )\n options = {\n :user => Authorization.current_user,\n :object => self\n }.merge(options)\n\nlogger.debug \"Checking for: #{self.class.name}\"\n\n Authorization::Engine.instance.permit!(privilege,\n {:user => options[:user],\n :object => options[:object]})\n end",
"def can_change( record, type = '*' )\n name, type = get_name_and_type_from_param( record, type )\n self.permissions['allowed'] << [ name, type ]\n end",
"def access_rights_for_permission(perm)\n sym = Lockdown.get_symbol(perm)\n\n permissions[sym]\n rescue \n raise SecurityError, \"Permission requested is not defined: #{sym}\"\n end",
"def permissions\n Roles.type_map[role_type].permissions\n end",
"def require_other_permission\n respond_to_permission_error\n end",
"def permissions=(value)\n @permissions = value\n end",
"def can?(permission)\n permissions.include?(permission.to_s) || super_admin?\n end",
"def add_user_permission(u)\n\t\t\n\tend",
"def permission_for (collection)\n permission = Permission.find_or_create_by_user_id_and_collection_id(self.id, collection.id)\n end",
"def apply_superuser_permissions(permission_types)\n []\n end",
"def model_actions(perms)\n ActiveRecord::Base.descendants.each do |m|\n next unless m.respond_to?(:permission_definition)\n next if m.permission_definition.nil? || m.permission_definition == {}\n perms << PermissionsGenerator.new(m)\n end\n return perms\nend",
"def permissions\n Rails.cache.fetch(\"permissions_#{self.id}\", expire_in: 1.month) do\n self.roles.map(&:permissions).flatten\n end\n end",
"def overall_permissions(thing)\n global_permissions.merge!(permissions_for(thing))\n end",
"def required_permission\n #\n # return the permission record if we have the Permission model\n #\n @required_permission ||= defined?(Permission) ? wulin_permits_required_permission : OpenStruct.new(name: [controller_name, action_name].join(\"#\"))\n end",
"def set_acl_statement\n super\n end",
"def custom_permissions\n\n campus = \"bakersfield\" if current_user.email.include?(\"bakersfield.edu\")\n campus = \"chancellor\" if current_user.email.include?(\"calstate.edu\")\n campus = \"channel\" if current_user.email.include?(\"ci.edu\")\n campus = \"chico\" if current_user.email.include?(\"chico.edu\")\n campus = \"dominguez\" if current_user.email.include?(\"dh.edu\")\n campus = \"eastbay\" if current_user.email.include?(\"eb.edu\")\n campus = \"fresno\" if current_user.email.include?(\"fresno.edu\")\n campus = \"fullerton\" if current_user.email.include?(\"fullerton.edu\")\n campus = \"humboldt\" if current_user.email.include?(\"humboldt.edu\")\n campus = \"longbeach\" if current_user.email.include?(\"lb.edu\")\n campus = \"losangeles\" if current_user.email.include?(\"la.edu\")\n campus = \"maritime\" if current_user.email.include?(\"maritime.edu\")\n campus = \"mlml\" if current_user.email.include?(\"mlml.edu\")\n campus = \"northridge\" if current_user.email.include?(\"northridge.edu\")\n campus = \"pomona\" if current_user.email.include?(\"bronco.edu\")\n campus = \"sacramento\" if current_user.email.include?(\"sacramento.edu\")\n campus = \"sanfrancisco\" if current_user.email.include?(\"sf.edu\")\n campus = \"sanmarcos\" if current_user.email.include?(\"sanmarcos.edu\")\n campus = \"sonoma\" if current_user.email.include?(\"sonoma.edu\")\n campus = \"stanislaus\" if current_user.email.include?(\"stanislaus.edu\")\n\n user_groups.push(campus)\n\n # admin\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def permission_mapping\n super.merge(\n {\n 'index_role_screen' => 'index',\n 'index_role_field' => 'index',\n 'index_user_screen' => 'index',\n 'index_user_field' => 'index',\n 'fetch_row' => 'index'\n }\n )\n end",
"def readonly_user\n super\n end",
"def custom_permissions_read(_notebook, _user, _use_admin=false)\n true\n end",
"def user_permissions\n if current_user.id == params[:id].to_i\n @user = User.find(params[:id])\n else\n flash[:danger] = 'Unauthorized action.'\n redirect_to edit_user_path(current_user) \n end\n end",
"def permitted?; end",
"def permission_proxy\n @authorizable_permission_proxy ||= Authorizable::Proxy.new(self)\n end",
"def default(user)\n puts \"Rights: default\"\n # can :read, :all # doesn't do that ! We will authorize each actions\n can :read, [Doc, Gallery, Image, Place]\n can :manage, User, :id => user.id\n cannot :destroy, User, :id => user.id\n\n can :read, ForumCategory, [\"role <= ?\", user.role] do |forum_category|\n forum_category.role <= user.role\n end\n\n can :read, Forum, [\"role <= ?\", user.role] do |forum|\n if (forum.role <= user.role)\n can :read, Topic\n can :read, Message\n true\n else\n false\n end\n end\n\n # can read users profiles\n can :read, User\n\n # special actions\n can :mark_all_read, Forum\n end",
"def authorize_admin!\n authorize! :manage, :all\n end",
"def enforce_access_controls(opts={})\n controller_action = params[:action].to_s\n delegate_method = \"enforce_#{controller_action}_permissions\"\n if self.respond_to?(delegate_method.to_sym, true)\n self.send(delegate_method.to_sym)\n else\n true\n end\n end",
"def permissions\n read_attribute(:permissions) || {}\n end",
"def authorize (permission_name)\n self.allowances.detect {|a| a.permission.name == permission_name.to_s}\n end",
"def check_permissions\n authorize! :create, Employee\n end",
"def add_permissions\n [\"License\", \"Archive\", \"Contract\"].each do |doc|\n klass = doc.constantize\n doc_id = \"#{doc.downcase}_id\".to_sym\n permissions = self.send(\"#{doc.downcase.pluralize.singularize}_permissions\".to_sym)\n klass.find(:all).each { |record|\n permissions.create doc_id => record.id, :ycrole_id => self.id,\n :can_read => false, :can_write => false\n }\n end\n end",
"def effective_permissions\n source = self\n\n while source.inherit && source.forum.parent\n source = source.forum.parent.forum_permissions.find_by(group: group)\n end\n\n source = group if source.inherit\n\n source\n end",
"def set_access(*args)\n options = args.extract_options!\n options[:object] ||= Array(@_controller).first.to_s.singularize.to_sym if @_controller.present?\n permissions.add(*args, options)\n end",
"def restore_permissions; end",
"def restore_permissions; end",
"def effective_roles_authorization_level(controller, role, resource)\n authorization_method = EffectiveResources.authorization_method\n\n raise('expected an authorization method') unless (authorization_method.respond_to?(:call) || authorization_method.kind_of?(Symbol))\n return :unknown unless (controller.current_user rescue nil).respond_to?(:roles=)\n\n # Store the current ability (cancan support) and roles\n current_ability = controller.instance_variable_get(:@current_ability)\n current_user = controller.instance_variable_get(:@current_user)\n current_user_roles = controller.current_user.roles\n\n # Set up the user, so the check is done with the desired permission level\n controller.instance_variable_set(:@current_ability, nil)\n\n level = nil\n\n case role\n when :signed_in\n controller.current_user.roles = []\n when :public\n controller.instance_variable_set(:@current_user, nil)\n\n if defined?(EffectiveLogging)\n EffectiveLogging.supressed { (controller.request.env['warden'].set_user(false) rescue nil) }\n else\n (controller.request.env['warden'].set_user(false) rescue nil)\n end\n else\n controller.current_user.roles = [role]\n end\n\n # Find the actual authorization level\n level = effective_roles_item_authorization_level(controller, role, resource, authorization_method)\n\n # Restore the existing current_user stuff\n if role == :public\n ActiveRecord::Base.transaction do\n if defined?(EffectiveLogging)\n EffectiveLogging.supressed { (controller.request.env['warden'].set_user(current_user) rescue nil) }\n else\n (controller.request.env['warden'].set_user(current_user) rescue nil)\n end\n\n raise ActiveRecord::Rollback\n end\n end\n\n controller.instance_variable_set(:@current_ability, current_ability)\n controller.instance_variable_set(:@current_user, current_user)\n controller.current_user.roles = current_user_roles\n\n level\n end",
"def can?(*args)\n permissions.can?(*args)\n end",
"def authorize_inherited_resource!\n authorize! :show, parent if parent?\n authorize! authorizable_action, authorize_resource? ? resource : resource_class\n end",
"def check_write_access(obj)\n return obj unless LinkedData.settings.enable_security\n if obj.is_a?(LinkedData::Models::Base) && obj.write_restricted?\n writable = obj.writable?(env[\"REMOTE_USER\"])\n error 403, \"Access denied for this resource\" unless writable\n end\n end",
"def filter_access!\n treat_as get_current_role\n end",
"def can_do_member_scoped_actions\n can :show, :all\n can :edit, :all\n can :destroy, :all\n can :history, :all\n can :show_in_app, :all\n can :clone, :all\n # can :nested_set, :all\n can :nestable, :all\n can :change_state, :all\n end",
"def role_permissions=(value)\n @role_permissions = value\n end",
"def permissions\n return @permissions\n end",
"def build_permissions(perms, other)\n perms.permits! :read\n\n if self == other\n perms.permits! :write\n elsif other.admin?\n perms.permits! :write\n end\n end",
"def everyone(read, write)\n apply(PUBLIC, read, write)\n permissions[PUBLIC]\n end"
]
def destroy
@stay_time.destroy
respond_to do |format|
format.html { redirect_to stay_times_url, notice: 'Stay time was successfully destroyed.' }
format.json { head :no_content }
end
end
def grouped_open_hours
open_hours = []
start_day = nil
end_day = nil
current_period = nil
standard_hours.sort.each_with_index do |o, i|
if not o.open?
period = "Stengt"
else
period = I18n.l(o.open_time, format: :time) + " - " + I18n.l(o.close_time, format: :time)
end
# Track day
if start_day == nil
start_day = o.day
current_period = period
end
# Previous group ended, add it
if period != current_period
day = I18n.t("days.#{start_day}")
if end_day != nil
day += " - " + I18n.t("days.#{end_day}")
end
# Hverdager custom string
if start_day == "monday" and end_day == "friday"
day = "Hverdager"
end
open_hours.append([day, current_period])
current_period = period
start_day = o.day
end_day = nil
end
# Update period end
if start_day != o.day
end_day = o.day
end
# Last day closes period
if i >= standard_hours.count - 1
day = I18n.t("days.#{start_day}")
if end_day != nil
day += " - " + I18n.t("days.#{o.day}")
end
open_hours.append([day, current_period])
end
end
open_hours
end
right now this only gets one user out of the params, but recipients can be modified to support multiple users conversation subject params are hardcoded in the view right now but this setup will take arbitrary input
subject is hardcoded in messages/new.html.erb but we can replace the hidden with a normal field if we want if someone really wants to modify the request they can set their own subject but whatever
def admin_message
redirect_to root_path unless admin_user?
end
def destroy
@graphium_city.destroy
respond_to do |format|
format.html { redirect_to graphium_cities_url, notice: 'City was successfully destroyed.' }
format.json { head :no_content }
end
end
=begin This is a comment block multiple lines doctest: First doctest >> "hello!" => "hello!" doctest: I have another method here >> hello => "hello" doctest: I pass david to hello and get "Hello David!" >> hello "David" => "hello David!" doctest: If I forget to capitalize the name it will capitalize for me >> hello 'david' => "hello David!" doctest: I can even ask a question by add "?" >> hello "Victor", "?" => "hello Victor?" =end This is also
def hello name = "", punctuation = "!"
"hello #{name.capitalize}#{punctuation}"
end
Link to kata: Description: Fix the function I created this function to add five to any number that was passed in to it and return the new value. It doesn't throw any errors but it returns the wrong number. Can you help me fix the function? Answer:
def destroy
@productor.destroy
respond_to do |format|
format.html { redirect_to productors_url, notice: 'Productor was successfully destroyed.' }
format.json { head :no_content }
end
end
Obligations This pulls down the submitted returns and gives us a periodKey (which we use to pull individual returns) The aim is to store all returns in a single table
def obligations
self.class.get(url, { headers: @headers, query: @query })
end
Comparison operator for sorting, if the distance and num_dims_used accessor is set on both entities before calling this then it is sorted by rating else it is sorted alphabetically.
def <=>(ent)
return self.name <=> ent.name unless num_dims_used and ent.num_dims_used
return 1 if num_dims_used == 0 and ent.num_dims_used > 0
return -1 if num_dims_used > 0 and ent.num_dims_used == 0
return 0 if num_dims_used == 0 and ent.num_dims_used == 0
ent.percent <=> self.percent
end
def rating_for(dim)
# If it's a boolean then this entity either has it or doesn't
# Retirn 0|1 in the range of 1|5
if dim.bool?
fv = FactValue.get_value(Fact.find_by_name(dim.name), self)
return fv.value * 4 + 1 if fv
else
cr = CurrentRating.find_by_entity_id_and_opinion_id(self, dim.valuable)
return cr.rating if cr
end
nil
end
def followed_by?(other_user) reverse_followships.find_by_follower_id(other_user.id) end def unfollowed!(other_user) reverse_followships.find_by_follower_id(other_user.id).destroy end
def has_role?(role)
case role
when :admin then admin?
when :member then true
else false
end
end
This method is to ascertain whether the value given is an integer and if not, continue down the array
def find_int(obj)
if obj.respond_to?(:each)
# This is an array, not the object type sought.
obj.each do |x|
find_int(x)
end
else
# This is an integer or other object, return it.
@holding_array << obj
end
end
From the page 482 The full list of operating system errors on your particular platform is available as the constants of Errno. Any userdefined exception in this module (including subclasses of existing exceptions) must also define an Errno constant.
def test_Errno_Introduction2
assert_equal([:NOERROR, :EPERM, :ENOENT, :ESRCH, :EINTR],
Errno.constants[0..4])
end
scenarios if item is present: best: O(1), avg: O(N/2), worst: O(N) if item is NOT present best: O(1), avg: O(N/2), worst: O(N)
def sorted_sequential_search(array, value)
i = 0
while i < array.length
return i if array[i] == value
return false if array[i] > value
i += 1
end
false
end
def binary_search_with_while(array, value)
from = 0
to = array.size - 1
while from <= to
mid = (from + to) / 2
if array[mid] > value
to = mid - 1
elsif array[mid] < value
from = mid + 1
else
return mid
end
end
false
end
[
"def guess(guess)\n \t@guess = guess\n\n \tguess_response\n end",
"def game_guess\n if path == \"/game\" && verb == \"POST\"\n number = client.read\n game.guess(number)\n redirect(client)\n end\n end",
"def make_guess\n guess = input_guess\n check_guess(guess)\n render_code(guess)\n render_pegs(@black_pegs, @white_pegs)\n end",
"def getguess guess\r\n\t\t\t\t\t@spin_flag = false\r\n\t\t\t\t if guess.length == 1\r\n\t\t\t\t if check_repeated_choice guess\r\n\t\t\t\t @message = \"Already guessed this letter!\"\r\n\t\t\t\t if @console\r\n\t\t\t\t\t\t\t\t@output.puts \"#{@message}\"\r\n\t\t\t\t\t\t\t\tword_input = take_user_word_input\r\n\t\t\t\t\t\t\t\tvalid = false\r\n\t\t\t\t\t\t\t while !valid do\r\n\t\t if validate_input word_input\r\n\t\t valid = true\r\n\t\t else\r\n\t\t @output.puts \"Invalid input\"\r\n\t\t word_input = take_user_word_input\r\n\t\t end\r\n\t\t\t\t\t\t\t end\r\n\t\t\t\t\t\t\t\tif check_enter word_input\r\n\t\t\t\t\t\t\t\t\t\t@break_flag = true\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t getguess word_input\r\n\t\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t@spin_flag = true\r\n\t\t\t\t end\r\n\t\t\t\t else\r\n\t\t\t\t \t@message=\"Guess a letter from the word/phrase.\"\r\n\t\t\t\t @guess_counter+=1\r\n\t\t\t\t check_guess guess\r\n\t\t\t\t set_guess_analysis guess\r\n\t\t\t\t end\r\n\t\t\t\t success = check_phrase @resulta.join(',').gsub(\",\",\"\")\r\n\t\t\t\t return success ? true : false\r\n\t\t\t\telse\r\n\t\t\t\t\t if check_phrase guess\r\n\t\t\t\t\t\t phrase = @secretword.chars\r\n\t\t\t\t\t\t i = 0\r\n\t\t\t\t\t\t while i < phrase.length do\r\n\t\t\t\t\t\t\t\t\t\t@resulta[i] = phrase[i]\r\n\t\t\t\t\t\t\t\t\t\ti += 1\r\n\t\t\t\t\t\t end\r\n\t\t\t\t\t\t return true\r\n\t\t\t\t\t else\r\n\t\t\t\t\t\t @num_guessed = 0\r\n\t\t\t\t\t\t incrementturn\r\n\t\t\t\t\t\t @guess_counter+=1\r\n\t\t\t\t\t\t set_guess_analysis guess\r\n\t\t\t\t\t\t return false\r\n\t\t\t\t\t end\r\n\t\t\t\tend\r\n\t\t\t\tend",
"def play_game_with_user_as_codebreaker\n @display.welcome_message_for_user_as_codebreaker\n generate_secret_code\n collect_first_guess_and_provide_feedback\n let_the_user_provide_successive_guesses_and_provide_feedback\n end",
"def guessed\n\n end",
"def guessing_for_the_win(letter)\n\t\tif repeat_guess(letter)\n\t\telsif guess_correct(letter)\n\t\telse wrong_guess(letter)\n\t\tend \n\n\t\tif @secret_word == @display\n\t\t\tcongrats\n\t\telsif @number_of_guesses > 0 \n\n\t\t\tp \"Keep guessing\"\n\t\telse\n\t\t\tfailure\n\t\tend\n\tend",
"def guess(name)\n choose(name)\n click_button(\"Guess\")\n end",
"def guess(guess,event)\n case @status\n when :new, :finished\n 'You need to start a game first: `!rfk start`'\n when :running\n if guess == @kitten\n # We currently get a warning trying to send a message and add a reaction\n # [WARN : ct-3 @ 2018-02-26 17:49:52.182] Locking RL mutex (key: [:channels_cid_messages_mid_reactions_emoji_me, 417679731291324417]) for 1.0 seconds preemptively\n #event.message.react('😸') # Smiley Cat\n @status=:finished\n \"#{event.message.author.mention} Woo you found kitten\"\n elsif @guesses.include?(guess)\n \"#{event.message.author.mention} someone already guessed `#{guess}`, the kitten doesn't move during a game\"\n else\n @guesses << guess\n \"#{event.message.author.mention} You found `#{@nki[guess]}` but that's not a kitten!\"\n end\n else\n puts \"We got a guess of #{guess} but not in a known state of #{@state}\"\n \"Wibble not sure what's happening here\"\n end\n end",
"def ask_for_guess\n @guess_count += 1\n @guess = get_code(\"Please enter your guess in the format 'color color color color'(to list available color options enter 'options'):\")\n end",
"def play_game\r\n\r\n #Call on the generate_number method in order to get a random number\r\n number = generate_number\r\n $noOfGuesses = 0 \r\n\r\n #Loop until the player inputs a valid answer\r\n loop do\r\n \r\n Console_Screen.cls #Clear the display area\r\n \r\n \r\n\r\n if $noOfGuesses > $maxGameGuesses then\r\n print \"You exceeded the allowed number of guesses of \" + $maxGameGuesses.to_s + \".\"\r\n print \"\\nYou lose! Please try again.\"\r\n print \"\\n\\nPress enter to continue.\"\r\n Console_Screen.pause \r\n break\r\n end\r\n\r\n if $cheatMode == true then\r\n print \"\\nShh.... the answer is \" + number.to_s \r\n end\r\n\r\n #Prompt the player to make a guess\r\n print \"\\n\\nEnter your guess and press the Enter key: \"\r\n \r\n \r\n reply = STDIN.gets #Collect the player's answer\r\n reply.chop! #Remove the end of line character\r\n\r\n reply = reply.to_i\r\n\r\n if reply < 1 || reply > $maxChallengeRange then\r\n Console_Screen.cls\r\n print \"\\nInvalid entry. Please enter a number between 1 and \" + $maxChallengeRange.to_s\r\n print \"\\n\\nPlease press enter to continue.\"\r\n Console_Screen.pause\r\n redo #Redo the current iteration of the loop\r\n end\r\n \r\n $noOfGuesses = $noOfGuesses + 1\r\n \r\n #Analyze the player's guess to determine if it is correct\r\n if reply == number then #The player's guess was correct\r\n Console_Screen.cls #Clear the display area\r\n print \"You have guessed the number! Press enter to continue.\"\r\n Console_Screen.pause #Pause the game\r\n break #Exit loop\r\n elsif reply < number then #The player's guess was too low\r\n Console_Screen.cls #Clear the display area\r\n print \"Your guess is too low! Press Enter to continue.\\n\\n\"\r\n Console_Screen.pause #Pause the game\r\n elsif reply > number then #The player's guess was too high\r\n Console_Screen.cls #Clear the display area\r\n print \"Your guess is too high! Press Enter to continue.\\n\\n\"\r\n Console_Screen.pause #Pause the game\r\n end\r\n\r\n \r\n \r\n end\r\n\r\n end",
"def guess\n puts \"Write down a guess.\"\n @guess_code.make_seq\n @code_seq = guess_code.sequence\n end",
"def respond_to_guess(letter)\n letter = letter.clone.downcase\n\n if @incorrect_letters.include?(letter) || @progress.include?(letter) || @progress.include?(letter.upcase)\n puts \"You already guessed that letter!\"\n puts \"\"\n elsif @word.include?(letter) || @word.include?(letter.upcase)\n update_progress(letter)\n unless @progress.include?(\"_\")\n @round_finished = true\n @guessed = true\n end\n else\n @incorrect_letters << letter\n @round_finished = true if @incorrect_letters.size == 6\n end\n print_hangman\n end",
"def congrats\n\t\tp \"Congrats on Guessing the Word\"\n\tend",
"def solicit_guess\n\t\tputs \"\\nPlease input a letter!\"\n\t\tguess = gets.chomp.downcase\n\t\tif guess.downcase == \"save\"\n\t\t\t$save = true\n\t\telse\t\n\t\t\tuntil !(@guess_tracker.include?(guess)) && (guess.length == 1) && (guess <= 'z' && guess >= 'a')\n\t\t\t\tputs \"Unacceptable input (maybe you already guessed that?), please try again!\"\n\t\t\t\tguess = gets.chomp.downcase\n\t\t\tend\n\t\tend\n\t\tguess\n\tend",
"def guess_code\n puts \"\\nI have 12 turns to guess the color code that you have set.\\nLet's see whether I can do it or not\"\n catch(:guessed) do\n (1..12).each do |turn|\n sleep(rand(1..8))\n print \"\\nMy guess #{turn}: \"\n guess = @role.random_code\n puts guess\n response = validate_guess(guess.split(''), get_code.split(''))\n puts \"Response: #{response}\"\n validate_response(response, turn)\n end\n end \n end",
"def guess!(letter)\n end",
"def computer_guess_turn\n feedback_engine\n sleep 2.5\n puts \"The computer is thinking...\"\n computer_change_guess\n puts \"Guess Board: #{@guess_board.state}\"\n end",
"def give_feedback\n print 'Matches: '\n puts 'Black ' * @secret.exact_matches(last_guess) + \\\n 'White ' * @secret.near_matches(last_guess)\n end",
"def play_game(value)\r\n\r\n #Call on the generate_number method in order to get a random number\r\n number = generate_number \r\n\r\n\tif value == \"c\"\r\n\t\tConsole_Screen.cls\r\n\t\tputs \"\\n\\nCHEAT MODE: secret number is \" + number.to_s \r\n\t\tConsole_Screen.cls\r\n\tend\r\n\t\r\n #Loop until the player inputs a valid answer\r\n loop do\r\n \r\n Console_Screen.cls #Clear the display area\r\n \r\n #Prompt the player to make a guess\r\n print \"\\nEnter your guess and press the Enter key: \"\r\n \r\n reply = STDIN.gets #Collect the player's answer\r\n reply.chop! #Remove the end of line character\r\n reply = reply.to_i #Convert the player's guess to an integer\r\n \r\n\t #Increment Guesses Variable\r\n\t $noOfGuesses += 1\r\n\t\r\n #Validate the player's input only allowing guesses between 1 and 100\r\n if reply < 1 or reply > 1000 then\r\n\t \r\n\t\tConsole_Screen.cls #clear screen\r\n\t\t\r\n\t\tputs \"\\nInvalid input was entered!\"\r\n\t\tprint \"\\n\\Only use numbers from 1 to 1000 for guesses. Press enter to continue.\" \r\n\t\t\r\n\t\tConsole_Screen.pause\r\n\t \r\n redo #Redo the current iteration of the loop\r\n end\r\n \r\n #Analyze the player's guess to determine if it is correct\r\n if reply == number then #The player's guess was correct\r\n Console_Screen.cls #Clear the display area\r\n print \"You have guessed the number! Press enter to continue.\"\r\n Console_Screen.pause #Pause the game\r\n break #Exit loop\r\n elsif reply < number then #The player's guess was too low\r\n Console_Screen.cls #Clear the display area\r\n print \"Your guess is too low! Press Enter to continue.\"\r\n Console_Screen.pause #Pause the game\r\n elsif reply > number then #The player's guess was too high\r\n Console_Screen.cls #Clear the display area\r\n print \"Your guess is too high! Press Enter to continue.\"\r\n Console_Screen.pause #Pause the game\r\n end\r\n \r\n\t\tif $noOfGuesses >= 10\t\t#Max guess attemps (10)\r\n\t\tConsole_Screen.cls \t#clear screen\r\n\t\t\tprint \"Your \" + $noOfGuesses.to_s + \" guesses are at max allowable attempts. Press enter to continue.\"\r\n\t\t\tConsole_Screen.pause\t#pause the game\r\n\t\t\tbreak\t#break loop\r\n\t\tend\r\n end\r\n\r\n end",
"def guess\n # takes human input and stores guess\n puts 'Pick a letter'\n self.human_guess = gets.chomp\n end",
"def guess(guess)\n \t@guess = guess\n \treturn :correct if solved?\n \t@guess > @answer ? :high : :low\n end",
"def make_guess\n\tputs \"#{ @name } is thinking...\"\n\tif @first_guess==[]\n\t return make_first_guess\n\telse\n\t # update the last guess, get a random sample from the set of available codes\n\t sleep 1\n\t @last_guess = @set_of_codes.sample \n\t return @last_guess\n\tend\n end",
"def play_as_codebreaker\n # answer = colors.sample(4)\n loop do\n display.tables(hint.table,decode.table)\n puts \"Please enter your guess #{colors.join(' | ')}:\"\n player.input = gets.split.map(&:capitalize)\n if player.valid_input?\n if player.win?(answer)\n puts \"You won! #{display_answer}\"\n exit\n elsif player.lose?\n puts \"You lost! #{display_answer}\"\n exit\n else\n complete_turn\n end\n else\n puts \"Not a valid input!\"\n end\n end\n end",
"def turn()\n\tguess = \"\"\n\tif @human_is_guessing == true\n\t\tputs \"Enter your guess for the secret code\"\n\t\tguess = gets.chomp\n\t\twhile guess.length != 4 || (guess =~ /[^0-5]/)\n\t\t\tputs \" Please enter guess again. Remember it must be 4 numbers and only consist of values 0-5.\"\n\t\t\tguess = gets.chomp\n\t\tend\n\telse #computer is guessing\n\t\t#random guess from array of viable solutions.\n\t\tguess = @solutions.delete_at(rand(@solutions.length)).join.to_s\n\t\t\tputs \" I guess \" + guess\n\t\tend\n\t\tset_guess(guess)\n\t\t@score = compare_guess(guess)\n\t\tputs \"You have correctly guessed \" + @colors_correct.to_s + \" out of 4 digits in the code\" + \" and have \" + @placed_correct.to_s + \" in the right place.\"\n\t\t@solutions.delete_if {|x| compare_guess(x.join.to_s, @guess) != @score }\n\t\t@turns += 1\n\tend",
"def guess_progress(user_guess)\n @letter_found = false\n check_letter(user_guess)\n\n @secret_array.each_index do |i|\n if !@letter\n puts \"Invalid input. Please input a letter\"\n @letter_found = true\n break\n elsif @secret_array[i] == user_guess \n @display_array[i] = \" #{user_guess} \"\n @letter_found = true\n end\n end\n\n puts \"Sorry. '#{user_guess}' is not in the secret word\" if !@letter_found\n\n if !check_finish\n increment_guess(user_guess)\n end \n\n @display_array\n @is_over\n end",
"def ask_guess\n guess = gets.chomp.downcase\n check_guess_is_valid?(guess) ? guess : ask_guess\n end",
"def check_guess guess\r\n\t\t\t\t @resultb.push(guess)\r\n\t\t\t\t phrase = @secretword.chars\r\n\t\t\t\t i = 0\r\n\t\t\t\t @num_guessed = 0\r\n\t\t\t\t while i < phrase.length do\r\n\t\t\t\t\t\t\t\tif phrase[i] == guess\r\n\t\t\t\t\t\t\t\t @resulta[i] = guess\r\n\t\t\t\t\t\t\t\t @num_guessed += 1\r\n\t\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\t\t\ti += 1\r\n\t\t\t\t end\r\n\t\t\t\t\t\t\t\tif @num_guessed > 0\r\n\t\t\t\t\t\t\t\t@score += (@reward.to_i * @num_guessed)\r\n\t\t\t\t\t\t\t else\r\n\t\t\t\t\t\t\t incrementturn\r\n\t\t\t\t\t\t\t\tend\r\n\t\t end",
"def turn\n\t\t\t@turns += 1\n\t\t\t@guess_letter = gets[0].downcase\n\t\t\tshow_matches\n\t\t\tcheck_win\n\t\tend",
"def incorrect_guess(guess)\n end",
"def correct_guess(guess)\n end",
"def give_feedback(guess)\n guess.split('').each_with_index do |val, index|\n if val == @code[index]\n print 'M'\n elsif @code.split('').include?(val)\n print 'O'\n else\n print 'X'\n end\n end\n puts\n end",
"def show_guess\n @guess\n end",
"def guess_hidden_word\n puts (\"Enter your guess: \")\n end",
"def start\n \"You're playing with #{deck.count} cards.\"\n puts (\"-\"*60).cyan\n deck.cards.each do |card|\n puts \"This is card number #{current + 1} out of #{deck.count}.\"\n puts \"Question: #{current_card.question}\"\n response = gets.chomp\n record_guess(response)\n puts \"#{guesses.last.feedback}\"\n next_card\n end\n puts \"****** Game over! ******\"\n puts \"You had #{number_correct} correct answers out of #{deck.count} for a score of #{percent_correct}%\"\n end",
"def running(turn, time_to_guess, last_guess, last_word, last_feedback)\n system('cls')\n puts '***************************************************************'\n puts '* Word Mastermind *'\n puts '***************************************************************'\n puts '* Turn Number: ' + turn.to_s + ' Turns To Guess: '+time_to_guess.to_s+' *'\n puts '***************************************************************'\n puts ''\n puts ' REMEMBER: Your Word can only have 5 letters, and can only'\n puts ' contain one of each character!'\n puts ''\n puts '|X| = Not in word |O| = In the word and the correct place'\n puts '|-| = In the word but in the incorrect place '\n puts ''\n puts ' Your Last Guess Was: ' + last_word\n puts ''\n puts ' ' + \"#{last_guess}\"\n puts ' ' + \"#{last_feedback}\"\n puts ''\n puts ''\n puts 'What will you guess this turn?'\n puts ''\n print 'Guess: '\n end",
"def guess_without_choosing_anyone\n click_button(\"Guess\")\n end",
"def guess_code\n puts \"\\nYou'll have 12 turns to guess the color code set by me.\\nNot So Good Luck jk\\nOptions: r,b,y,g,o,w,v\"\n catch(:guessed) do\n guess = ''\n (1..12).each do |turn|\n print \"\\nGuess #{turn}: \"\n #print \"#{get_code} \"\n guess = gets.chomp!.downcase\n response = ''\n gc = get_code.split('')\n g = guess.split('')\n for i in 0..3 do \n if g[i]==gc[i]\n response += 'X'\n elsif gc.include?(g[i]) \n response += 'O'\n end\n end\n puts \"Response: #{response.split('').shuffle.join('')}\"\n if response=='XXXX'\n puts \"\\nCongratulations! I Lost\\nThe code was #{get_code}\"\n throw :guessed\n elsif response!='XXXX' and turn==12\n puts \"\\nBoohoo! I won\\nTHe code was #{get_code}\"\n throw :guessed\n end\n end\n end\n end",
"def play\n puts \"I have generated a beginner sequence with four elements made up of: (r)ed,\n (g)reen, (b)lue, and (y)ellow. Use (q)uit at any time to end the game.\n What's your guess?\"\n mastermind = Game.new\n mastermind.game_solution\n amount_of_guesses = 0\n guess = gets.chomp\n user_guess = []\n user_guess << guess.chars\n amount_of_guesses += 1\n mastermind.check_for_correct_letters(user_guess)\n mastermind.check_for_correct_indexes(user_guess, mastermind.solution)\n until guess == \"q\"\n if guess == \"c\"\n puts \"The solution is #{mastermind.solution}\"\n break\n elsif guess.length > 4\n puts \"Your guess was too long.\"\n elsif guess.length < 4\n puts \"Your guess was too short.\"\n elsif guess != mastermind.solution\n puts \"You had #{mastermind.correct_letters} correct colors with #{mastermind.correct_indexes}\n in the correct position.\"\n break\n elsif guess == mastermind.solution.to_s\n \"You won! You guessed #{guess}. You had #{mastermind.correct_letters} correct\n colors in #{mastermind.correct_indexes} correct positions.\n You guessed #{amount_of_guesses.to_s} times.\"\n break\n else\n puts \"Goodbye, quitter.\"\n end\n end\nend",
"def gets_user_guess\n @guess = gets.strip.downcase\n generate_new_card\n end",
"def guess(guess)\r\n\t\t# Make sure the guess is either a letter or the whole word\r\n\t\tif guess.length != 1 && guess.length != @win_word.length\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tp \"Guess a letter, or the complete word!\"\r\n\t\t# check for repeated guesses\r\n\t\telsif @past_guesses.include? guess\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tp @hint\r\n\t\t\tp \"You guessed that already!\"\r\n\t\t# check if they guessed the entire word correctly\r\n\t\telsif guess == @win_word\r\n\t\t\twin\r\n\t\t# if the letter is not in the word\r\n\t\telsif !@win_word.include? guess\r\n\t\t\t# Add guess to arrayof past guesses\r\n\t\t\t@past_guesses << guess\r\n\t\t\tif @remaining_guesses == 1\r\n\t\t\t\tlose\r\n\t\t\telse\r\n\t\t\tguesses_remaining\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tp @hint\r\n\t\t\tp \"Sorry, try again!\"\r\n\t\t\tend\r\n\t\t# if the letter is in the word\r\n\t\telsif @win_word.include? guess\r\n\t\t\t# Add guess to arrayof past guesses\r\n\t\t\t@past_guesses << guess\r\n\t\t\tguesses_remaining\r\n\t\t\tp @remaining_guesses.to_s + \" guesses left\"\r\n\t\t\tupdate_hint(guess)\r\n\t\t\tif @hint_str == @win_word\r\n\t\t\t\twin\r\n\t\t\telse\r\n\t\t\t\tp \"Nice guess!\"\r\n\t\t\tend\r\n\t\telse\r\n\t\t\tp \"Error\"\r\n\t\tend\r\n\r\n\tend",
"def prompt_for_guess\n puts (\"1. Enter a vowel.\")\n\tputs (\"2. Enter a consonant.\")\n\tputs (\"3. Guess the entire word.\")\n\tputs (\"(Enter your letter choice now. If you enter more than a letter than its your own fault.)\")\n end",
"def read_guess\n print \"Pretty please enter your guess: \"\n gets.to_i\nend",
"def ask_question\n @game_id = params[:game_id]\n @current_game = Game.find(@game_id)\n @bonus = params[:bonus]\n unless @current_game.players_turn?(current_user.id)\n back_to_index and return\n end\n\n if @current_game.normal_round?\n subject_title = params[:subject]\n @subject = subject_title\n @questions = Question.questions_by_user_experience(current_user.experience_level, @subject)\n @question = @questions.sample\n elsif @current_game.challenge_round?\n @challenge = Challenge::get_ongoing_challenge_by_game(@current_game.id)\n if @challenge\n @question = Question.find(@challenge.get_question_id_by_counter)\n @subject = @question.subject_title\n elsif @challenge.nil?\n wager = params[:wager]\n prize = params[:prize]\n if wager && prize\n @challenge = Challenge.create_challenge(@current_game.id, current_user.id, @current_game.opponent_id(current_user.id), wager, prize)\n else\n redirect_to game_challenge_path(:game_id => @current_game.id)\n end\n end\n end\n if @question\n respond_to do |format|\n format.html\n format.xml { render :xml => @question }\n end\n end\n end",
"def guess(board)\n print \"Make a guess: \"\n gets.chomp\n end",
"def one_round_human_codebreaker\n show_round(@round)\n obtain_human_input\n codebreaker_guess\n print_colorized_array(@guess)\n update_feedback\n codemaker_feedback\n print_colorized_array(@feedback)\n end",
"def handle_response(guess, indices)\n\t\tindices.each do |index|\n \t\t\t@board[index] = guess\n \t\tend\n \t\tcandidate_words(guess, indices)\n\tend",
"def make_guess\n puts \"Make a guess:\"\n @current_guess = gets.chomp\n unless good_guess?\n puts \"That is an invalid guess, please try again!\"\n @current_guess = gets.chomp\n end\n puts\n guesses << current_guess unless current_guess == \"save\" || current_guess == secret_word\n end",
"def test\n\t\t#load a QA pair into current\n\t\t@qa_pairs = @qa_pairs.shuffle\n\t\ttemp = @qa_pairs.pop\n\t\t@current_question = temp[0]\n\t\t@current_answer = temp[1]\n\t\t#ask question\n\t\tputs \"Question: #{@current_question[0]}\"\n\t\t#prompt and assess guess\n\t\tis_correct = false\n\t\twhile is_correct == false do\n\t\t\tguess = []\n\t\t\tputs \"Please type your answer:\"\n\t\t\tguess << gets.chomp\n\t\t\tif guess[0] == \"EXIT\"\n\t\t\t\t@shutdown = true\n\t\t\t\tputs @shutdown_msg\n\t\t\t\tis_correct = true\n\t\t\telsif guess[0] == \"SKIP\"\n\t\t\t\t@qa_pairs << temp\n\t\t\t\tputs @skip_msg\n\t\t\t\tis_correct = true\n\t\t\telsif self.assess(guess)\n\t\t\t\tputs @correct_msg\n\t\t\t\tis_correct = true\n\t\t\telse\n\t\t\t\tputs @incorrect_msg\n\t\t\t\tputs \"...\"\n\t\t\tend\n\t\tend\n\t\tputs \"--------------------\"\n\t\treturn nil\n\tend",
"def store_and_redirect(guess)\n @guesses << guess\n game_response(guess)\n #redirect\n end",
"def enter_guess\n\t\t@guess = nil\n\t\tuntil valid_guess?(@guess)\n\t\t\tputs \"Please enter your guess (A-Z) now, or type 'save' to save (and quit):\"\n\t\t\t@guess = gets.chomp.upcase\t\t\n\t\tend\n\tend",
"def run\n\t\t# initialize board with length\n\t\tlength = checker.pick_secret_word # picks a word, returns length\n\t\t@board = Board.new(length)\n\t\tguesser.receive_secret_length(@board)\n\t\t\n\t\tuntil @misses > MAX_MISSES\n\t\t\t\n\t\t\t# return letter \n\t\t\tguess = guesser.make_guess\n\t\t\t\n\t\t\t# rescue human putting in wrong indices\n\t\t\tbegin\n\t\t\t\t# return array of hits given guess\n\t\t\t\thits_arr = checker.check_guess(guess) \n\t\t\t\t# update @board if there was a hit; else, increment misses\n\t\t\t\thits_arr.empty? ? @misses +=1 : update_board(hits_arr, guess) \n\t\t\trescue Exception => e\n\t\t\t\tputs e.message\n\t\t\t\tretry\n\t\t\tend\n\t\t\t\n\t\t\t# break if the board is over\n\t\t\twon if @board.filled?\n\t\n\t\t\t# if not over, pass updated board to guesser \n\t\t\tguesser.handle_guess_response(@board)\n\t\t\t\n\t\t\t# render new board\n\t\t\t@board.render\n\t\tend\n\t\t\n\t\t# Guesser lost\n\t\tputs \"The guesser lost!\"\n\t\tchecker.reveal_secret\n\t\t\n\tend",
"def introduce_the_game\n @irc_server.puts \"Welcome to hangman!\"\n @irc_server.puts \"To get started, enter a word to be guessed\"\n end",
"def get_feedback\n @title_page = 'Feedback'\n\n params.each { |question, answer| $game.quiz.user_answer << answer.to_i }\n\n $game.player.score = ($game.quiz.number_corrects * 100) / $game.quiz.question_answer.length\n @feedback = $game.player.score\n\n @questions = $game.quiz.questions\n @user_answer = $game.quiz.user_answer\n\n erb :feedback, layout: :template\nend",
"def update\n respond_to do |format|\n if @round.make_guess(params[\"round\"][\"guessed_letter\"])\n update_current_player\n format.html { redirect_to game_round_path(@game, @round) }\n format.json { render :show, status: :created, location: @round }\n else\n format.html { redirect_to game_round_path(@game, @round), notice: 'Invalid guess' }\n format.json { render :show, status: :created, location: @round }\n end\n end\n end",
"def guess_params\n params.require(:guess).permit(:response, :card_id, :round_id)\n end",
"def create\n @guess = Guess.new(params[:guess])\n\n respond_to do |format|\n if @guess.save\n format.html { redirect_to(@guess, :notice => 'Guess was successfully created.') }\n format.xml { render :xml => @guess, :status => :created, :location => @guess }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @guess.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def getGuess\n puts \"It is your turn.\"\n puts \"Which person do you want to suggest?\"\n guessSuspect = getUserInputFromArray(@suspects)\n puts \"Which location do you want to suggest?\"\n guessLocation = getUserInputFromArray(@locations)\n puts \"Which weapon do you want to suggest?\"\n guessWeapon = getUserInputFromArray(@weapons)\n\n puts \"Is this an accusation (Y/[N])?\"\n accuse = nil\n while accuse == nil\n input = gets.chomp.to_s\n if input == \"Y\" or input == \"y\"\n accuse = true\n elsif input == \"N\" or input == \"n\"\n accuse = false\n else\n accuse = nil\n puts \"Invalid input, please try again.\"\n end\n end\n return Guess.new(guessSuspect, guessLocation, guessWeapon, accuse)\n end",
"def generate_random_guesses\n position1 = validate_ai_input\n guess1 = @board.reveal(position1)\n @board.render\n position2 = validate_ai_input\n guess2 = @board.reveal(position2)\n @board.render\n result = is_match?(guess1, guess2)\n if !result\n write_to_ai_memory(guess1.value, position1, guess2.value, position2)\n end\n end",
"def player_guess\n puts \"Turn #{@turn} - Put your guess in below:\"\n begin\n guess = gets.chomp\n guess_code = Code.new(guess.upcase)\n rescue StandardError => e\n puts e\n retry\n end\n guess_code\n end",
"def run_guessing_game\n\n player_guess = ''\n\n until player_guess == 'exit'\n welcome\n player_guess = get_player_guess\n check_guess(player_guess)\n end\nend",
"def set_guess\n @guess = Guess.find(params[:id])\n end",
"def guess_params\n params.require(:guess).permit(:member_id, :game_id, :faction_id, :result)\n end",
"def create\n # create the guess object based on the params passed form the form, i.e the text of the guess, the user_id and the card_id\n # we are able to find the @card and the @round becuase we passed their id's as hidden fields in the form that was submitted\n @guess = Guess.create(guess_params)\n # find the card the guess is associated with\n @card = Card.find(guess_params[:card_id]);\n # find the round the guess is associated with\n @round = Round.find(guess_params[:round_id])\n\n respond_to do |format|\n # calling the card instance method 'check_guess' and passing it the @guess object\n # this method will compare the guess to the card's answer and return true if correct, false if incorrect\n # you can find this check_guess method in models/card.rb\n result = @card.check_guess(@guess)\n \n # if the result of the guess was true, that means it was correct\n if result == true\n # the guess was correct, so update the \"correct\" attribute on the guess to true (it was false by default)\n @guess.update_attributes(correct: true)\n # delete the card_id that was answered correctly from our array of cards_not_answered, which is stored in the session\n # if we delete the card_id of the card that was answered, it will no longer be showin in the game\n session[:cards_not_answered].delete(@card.id)\n\n # this is checking if there aren't any cards left in the cards_not_answered\n # if its greater than 0, then there are still cars left to anser\n if session[:cards_not_answered].length > 0\n # randomly select a card_id from the cards_not_answered array\n next_card_id = session[:cards_not_answered].sample\n # redirect to play that card, using the variable next_card_id that we just made\n # this is redirecting to the /cards/:id/play/:round_id route, which will trigger the play_card method. the play_card method will render the view with the new card's question and a submit form to anser it\n format.html {redirect_to \"/cards/#{next_card_id}/play/#{@round.id}\"}\n else\n # if there aren't any cards left in the cards_not_answered array then the game must be over - we have answered all the cards\n # in this case, we should redirect to the results route which will show our results\n format.html {redirect_to \"/rounds/#{@round.id}/results\"}\n end\n else\n # down here is the block for if the guess was not correct\n # if the guess was incorrect, we simply pick a new card_id from the cards_not_answered array that is stored in the session\n next_card_id = session[:cards_not_answered].sample\n # with that next_card_id we can redirect to /cards/:id/play/:round_id route, which will trigger the play_card method which will render the view with the next card's question and a submit form to answer\n format.html {redirect_to \"/cards/#{next_card_id}/play/#{@round.id}\"} \n end\n end\n end",
"def process_guess(guess)\n\t\t\tunless @secret.include? guess\n\t\t\t\tputs \"Bad guess...\"\n\t\t\t\t@bad_guesses << guess\n\t\t\t\t@guesses -= 1\n\t\t\t\t@drawing[@bad_guess_count+1] = @drawing_animation[@bad_guess_count]\n\t\t\t\t@bad_guess_count += 1\n\t\t\tend\n\n\t\t\twhile @secret.include? guess\n\t\t\t\t@fill_in_word[@secret.index(guess) * 2] = guess\n\t\t\t\t@secret[@secret.index guess] = \" \"\n\t\t\tend\n\t\tend",
"def guessing_game\n answer = rand(1..10)\n print \"What is your guess?\"\n guess = gets.chomp\n if\n guess.to_i > answer\n puts \"Your guess is too high.\"\n elsif\n guess.to_i < answer\n puts \"Your guess is too low.\"\n else\n puts \"Your guess is correct.\"\n end\n \n print \"What is your guess?\"\n guess = gets.chomp\n if\n guess.to_i > answer\n puts \"Your guess is too high.\"\n elsif\n guess.to_i < answer\n puts \"Your guess is too low.\"\n else\n puts \"Your guess is correct.\"\n end\n \n print \"What is your guess?\"\n guess = gets.chomp\n if\n guess.to_i > answer\n puts \"Your guess is too high.\"\n elsif\n guess.to_i < answer\n puts \"Your guess is too low.\"\n else\n puts \"Your guess is correct.\"\n end\n \n puts \"The answer was\"\n puts answer\nend",
"def guess(input)\n @last_guess = input\n compare(input)\n @turns += 1\n end",
"def guess(input)\n @last_guess = input\n compare(input)\n @turns += 1\n end",
"def get_guess\n\t\t# There are turns left...\n\t\tif @turn < 9\n\t\t\tshow_board\n\t\t\tputs \"Enter your letter guess...\"\n\t\t\tletter = gets.chomp.downcase\n\t\t\tvalidate_letter(letter)\n\t\t# No turns left, show losing message and delete game if it was previously saved\n\t\telse\n\t\t\tputs\n\t\t\tshow_board\n\t\t\tputs \"Dangit, you ran out of turns!\"\n\t\t\tputs \"The word was #{@word.join}...\"\n\t\t\tif @running_saved_game != nil\n\t\t\t\tover_write_data\n\t\t\tend\n\t\t\tgo_again\n\t\tend\n\tend",
"def hit\n @printer = []\n @printer << \"You Hit.\"\n deal_player\n pl_total\n if session[:player].bust? || session[:player].hand_total == 21\n @action = :end\n run_dealer\n else\n @action = :choice\n end\n chat\n end",
"def results(guess)\n if guess == @number\n puts 'Congratulations you guessed the right number!'\n else\n puts \"Correct answer was #{@number}. You ran out of guesses.\"\n end\n end",
"def play_game\r\n\r\n word = select_word #Call on the method that retrieves a random word\r\n\r\n Console_Screen.cls #Clear the display area\r\n\r\n consonants = get_consonants #Call on the method that prompts the player\r\n #to enter a list of consonants\r\n\r\n Console_Screen.cls #Clear the display area\r\n\r\n #Call on the method that prompts the player to enter a vowel\r\n vowel = get_vowel\r\n\r\n #Remove blank spaces from the word to create a short version of the word\r\n shortWord = word.gsub(\" \", \"\")\r\n\r\n #Call the method that processes player guesses\r\n prompt_for_guess(shortWord, word, consonants, vowel)\r\n\r\n Console_Screen.cls #Clear the display area\r\n\r\n end",
"def give_hint()\n \n sleep(2)\n puts \"hint...\"\n sleep(1)\n\n correct_colors = []\n correct_place = 0\n\n #count matching colors\n $computer[\"code\"].map { |value| if $player[\"code\"].include?(value)\n if !correct_colors.include?(value)\n correct_colors.push(value) \n end\n end }\n\n #update object\n $computer[\"correct_colors\"] = correct_colors\n\n #report matching colors \n if correct_colors.length() > 0\n puts \"#{correct_colors.length()} of the colors that the computer chose are accurate...\"\n end \n \n #count matching placement of matching colors\n correct_colors.map { |value| $computer[\"code\"].index(value) == $player[\"code\"].index(value) }.map { |value| if value == true\n correct_place += 1\n end}\n\n #update object\n $computer[\"correct_place\"] = correct_place\n\n puts \"... and #{correct_place} in the correct place\" \n \n sleep(3)\n\n end",
"def set_guess\n @guess = Guess.find(params[:id])\n end",
"def set_guess\n @guess = Guess.find(params[:id])\n end",
"def set_guess\n @guess = Guess.find(params[:id])\n end",
"def getGuess\n\t\tputs \"It's Player #{@myIndex}'s turn.\"\n\n\t\t#if this players last guess was not correct\n\t\tif (!@isCorrect)\n\t\t\t#just grab some unseen values\n\t\t\tguessPerson = @suspectsNotSeen[0]\n\t\t\tguessPlace = @locationsNotSeen[0]\n\t\t\tguessWeapon = @weaponsNotSeen[0]\n\n\t\t\t#check if you only have 3 options\n\t\t\tif(@suspectsNotSeen.length == 1 && @locationsNotSeen.length == 1 && @weaponsNotSeen.length == 1)\n\t\t\t\t@theGuess = Guess.new(guessPerson, guessPlace, guessWeapon, true)\n\t\t\telse \n\t\t\t\t@theGuess = Guess.new(guessPerson, guessPlace, guessWeapon, false)\n\t\t\tend\n\n\t\t\t@theGuess\n\t\t#if it was \n\t\telse\n\t\t\tputs \"Player #{@playerIndex} makes an Accusation: #{@theGuess.toString}!\"\n\t\t\t#take the last guess, change it to an accusation, and return it\n\t\t\t@theGuess.changeToAccusation\n\t\t\t@theGuess\n\t\tend\n\tend",
"def feedback\n end",
"def play_game \n\n @number_guesses = 0\n @start_time = Time.now\n puts \"I have generated a secret code, a sequence of four colors: (R)ed, (G)reen, (B)lue, and (Y)ellow\"\n\n game_over = false \n\n until game_over \n \n guess = get_guess\n\n exit_game if guess.upcase == \"Q\" \n guess = @secret_code if guess.upcase == \"C\" # provide option to cheat\n\n if validate_guess(guess)\n @number_guesses += 1\n # add_guess_to_history(guess_report(guess))\n display_history(guess)\n\n if guess.upcase == @secret_code\n game_over = true \n end_game\n else\n puts \"Please guess again.\" \n end\n end\n end\n end",
"def guess_params\n params.require(:guess).permit(:text, :card_id, :round_id)\n end",
"def start_guess\r\n\t\tuntil @is_over == true\r\n\t#player enters 1 letter string\r\n\r\n\t\t\tputs \"guess a letter you've already guessed #{@used}. #{@tries-@guess_count} attempts remain\"\r\n\t\t\tputs @blanks.join\r\n\t\t\tletter = gets.chomp\r\n\t#if letter is not in guessed box take a turn away\r\n\t\t\tif @used.include?(letter) == false\r\n\t\t\t\t@guess_count += 1\r\n\t\t\t\tif @tries == @guess_count \r\n\t\t\t\t\t@is_over = true\r\n\t\t\t\tend\r\n\t\t#if letter is in the world replace the blank\r\n\t\t\t\tif @word.include?(letter)\r\n\t\t\t\t\twordindex = @word.index(letter)\r\n\t\t\t\t\t@blanks[wordindex] = letter\r\n\t\t\t\t\tif @blanks.include?(\"_ \") == false\r\n\t\t\t\t\t\t@is_over = true\r\n\t\t\t\t\tend\r\n\t\t#if letter is not in the world add to guessed box\r\n\t\t\t\telse\r\n\t\t\t\t\t@used << letter\r\n\t\t\t\tend\r\n\t#if letter is in guessed box don't consume a turn\r\n\t\t\telse\r\n\t\t\t\tputs \"you already tried that letter\"\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t#end:\r\n\t#if word is guessed correctly print congrants\r\n\t\tif @blanks.include?(\"_ \")\r\n\t\t\tputs \"haha try harder next time\"\r\n\t#if word is guessed wrong print taunt\r\n\t\telse\r\n\t\t\tputs \"well done! you guessed the word\"\r\n\t\tend\r\n\tend",
"def attempt\n # # if @guesses.defined\n # if (defined?(@guesses)).nil?\n # @guesses = Array.new\n # end\n #\n @first_number = params[\"first_number\"]\n @second_number = params[\"second_number\"]\n @third_number = params[\"third_number\"]\n\n\n if @first_number.to_i < @second_number.to_i && @second_number.to_i < @third_number.to_i\n @guesses=(@first_number + \", \" + @second_number + \", \" + @third_number + \" Yes!\")\n else\n @guesses=(@first_number + \", \" + @second_number + \", \" + @third_number + \" No.\")\n end\n\n render(\"sequence/all_guesses.html.erb\")\n end",
"def handle_betting\n puts \"Player #{@number}, See, fold, or raise?\"\n\n case (resp = gets.chomp)\n when /see/i\n :see\n when /fold/i\n :fold\n when /raise/i\n Integer(resp.split(' ')[1])\n else\n raise \"Unknown player response: #{resp}\"\n end\n end",
"def guess\n question_response = QuestionResponse.build_response_guess(current_user, params)\n if question_response.try :save\n # load item\n question = Question.find(params[:id_question])\n item = question.xmlnode.xpath(\"//question/item[@text='\" + params[:item].gsub(\"'\", \"\\\\'\") + \"']\").first\n\n json = GuessQuestion.response(question, item, params[:answer])\n render json: json\n else\n render json: { message: \"error\" }, status: :unprocessable_entity\n end\n end",
"def play\n 10.times do |i|\n \n# i is the chance number\n puts \"This is chance #{i+1} of 10\"\n \n# current guess is what player typed in\n current_guess = @player.guess_code\n \n# standing is based on method evaluate guess with paramater current guess from above\n standing = evaluate_guess(current_guess)\n \n# if correct for all 4\n if standing[:exact].length == 4\n# display to user\n puts \"You won!\"\n return\n else\n puts \"#{standing[:exact].length} Exact Matches\"\n puts \"#{standing[:near].length} Near Matches\"\n end\n end\n \n# if reached end of loop, that means guesses out & not all perfectly matched\n\n # If we make it this far, we have used up \n # all of our turns and lost.\n puts \"You lost!\"\n return\n end",
"def evaluate_players_letter()\n letter= @player1.give_letter()\n if @hiddenword1.determine_if_correct_letter_given(letter)\n p @hiddenword1.obscured_word\n @guessed_letters.push(letter)\n else\n @player1.lives-=1\n p \"Please try again\"\n p @guessed_letters\n p @hiddenword1.obscured_word\n end\n end",
"def play_game_with_user_as_codemaker\n @display.welcome_message_for_user_as_codemaker\n solve_the_secret_combination\n end",
"def display\n puts \" \"*35 + \"===MasterMind!=== right: guess position\"\n for col in 0..9\n print \" \"*40\n for row in 0..3\n print guess_history[col][row] + ' '\n end\n puts \" \"*15 + guess_result_history[col][0] + \" \" + guess_result_history[col][1]\n puts \"\\n\"\n end\n puts \" \"*20 + \"input 4 color initials for making your choice, 'h' for help, 'q' for quit this round\"\n end",
"def feedback()\n return $prompt # $prompt is conditionally populated by good_letter(), word_test() and wrong_letter()\nend",
"def one_round_human_codemaker\n show_round(@round)\n puts 'The machine is thinking...'\n sleep 1\n @guess = define_secret_code\n print_colorized_array(@guess)\n end",
"def play\n\t\twelcome\n\t\task_name\n\t\task_name2 \n\t\task_input\n\t\tturns\n\tend",
"def analyze\n @hits.times do\n @guesses << @last_guess unless @guesses.length == 4\n end\n end",
"def analyze\n @hits.times do\n @guesses << @last_guess unless @guesses.length == 4\n end\n end",
"def guess\n\t\tcollect_words_of_length\n\t\tputs \"Already guessed letters by computer: #{@guessed_letters}\"\n\t\t@guessing_letter = nil\n\t\twhile @guessing_letter == nil || invalid?(@guessing_letter)\n\t\t\t@guessing_letter = guessing_letter\n\t\tend\n\t\t@guessed_letters << @guessing_letter\n\t\t@guessing_letter\n\tend",
"def round\n show_guess\n show_lives\n show_bank\n puts ''\n set_letter(ask_letter)\n add_to_bank\n add_to_guess\n take_life unless check_choice\n end",
"def letter_guess\n letter = get_letter_player()\n check_letter_in_random_word(@guess_letter)\n if @correct_guess == false\n @failed_attempts += 1\n if @failed_attempts == 10\n @lose = true\n end\n end\n guess_word_status_string = @guess_word_status.join()\n if guess_word_status_string == @random_word\n @win = true\n end\n end",
"def get_guess\n puts \"#{@name}'s turn!\"\n print \"Enter 1 to guess a letter, or 2 to guess a word: \"\n choice = gets.chomp.downcase\n if choice == \"1\"\n print \"Guess a letter: \"\n guess = gets.chomp.downcase\n if valid_letter_guess?(guess)\n return guess\n else\n self.get_guess\n end\n elsif choice == \"2\"\n print \"Guess a word: \"\n guess = gets.chomp.downcase\n if valid_word_guess?(guess)\n return guess\n else\n self.get_guess\n end\n end\n end",
"def update_feedback(guess)\n\t\tguess.split('').each do |guess_letter|\n\t\t\t@feedback.each do |target|\n\t\t\t\tif target[0] == guess_letter\n\t\t\t\t\ttarget[1] = true\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tall_true_check = true\n\t\t@feedback.each do |x|\n\t\t\tif !x[1]\n\t\t\t\tall_true_check = false\n\t\t\tend\n\t\tend\n\t\tif all_true_check\n\t\t\t@win = true\n\t\t\t@is_over = true\n\t\tend\n\tend",
"def return_guess\n 5\n end",
"def respond_to_guess(guess)\n\t\t@guessed_letters << guess\n\t\t@secret_word.split(\"\").include?(guess)\t\n\tend",
"def game(name,max,tries)\n secret_number = rand(1..max)\n puts \"Make your first guess. Type in a number when you are ready and click enter.\"\n guess_previous = 999999\n guess = gets.to_i\n bad_counter = 0\n for i in 1..tries\n \tif guess == 0\n \t\tbad_guess(i,guess,secret_number,name,bad_counter,tries)\n \t\tbad_counter = bad_counter + 1\n \telsif guess == secret_number\n \t\thardergame = correct_guess(i,guess,secret_number,name)\n \t\treturn hardergame\n \telsif guess == guess_previous\n \t\tputs \"What are you thinking? You picked #{guess} before!\"\n \t\twrong_guess(i,guess,secret_number,name,tries)\t\n \telse \n \t\twrong_guess(i,guess,secret_number,name,tries)\t \t\t\n \tend\n \tguess_previous = guess\n \tguess = gets.to_i\n end\nend"
]
def destroy
@investment.destroy
respond_to do |format|
format.html { redirect_to investments_url, notice: 'Investment was successfully destroyed.' }
format.json { head :no_content }
end
end
Fetch the two first characters (interpreted as AI) from the remaining data and try to find record class. If no record class was found, fetch a third character and try again, and then finally a forth, as no AI currently have more then 4 characters.
def record
@record ||= process_ai_variants(2) ||
process_ai_variants(1) ||
process_ai_variants(1)
end
Following method needs to be updated if multi environment params passed.
def environments=(env_params)
env_params.each do |env_hash|
next unless env_hash[:features]
env_hash[:features].each do |feature_hash|
self.features.build(feature_hash)
end
end
end
Determines the public IP address of the running AWS instance
def determine_public_ip
# 169.254.169.254 is the address of the AWS instance metadata service
# See https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
`curl --silent -XGET http://169.254.169.254/latest/meta-data/public-ipv4`
end
Determines the external port of the running Docker container that's associated with the port given
def determine_public_port(local_port)
port = 0
count = 0
max_attempts = 30
# Give up after 30 seconds
while port == 0 && count < max_attempts do
hostname = ENV['HOSTNAME']
command = "curl --silent -XGET --unix-socket /var/run/docker.sock http://localhost/containers/#{hostname}/json"
result = Maze::Runner.run_command(command)
if result[1] == 0
begin
json_string = result[0][0].strip
json_result = JSON.parse(json_string)
port = json_result['NetworkSettings']['Ports']["#{local_port}/tcp"][0]['HostPort']
rescue StandardError
$logger.error "Unable to parse public port from: #{json_string}"
return 0
end
end
count += 1
sleep 1 if port == 0 && count < max_attempts
end
$logger.error "Failed to determine public port within #{max_attempts} attempts" if port == 0 && count == max_attempts
port
end