This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
attr_accessible :email, :password, :password_confirmation, :first_name, :last_name, :zipcode | |
attr_accessor :password | |
before_save :encrypt_password | |
validates_confirmation_of :password | |
validates_presence_of :password, :on => :create | |
validates_presence_of :email | |
validates_uniqueness_of :email |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html lang="ru-RU"> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
<style> | |
body, .nested { | |
background: blue; | |
} | |
.container, .nested { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= semantic_form_for [:admin, @sale], html: { :class => "filter_form" } do |f| | |
= select "sale_", "id", Sale.all.collect{ |s| [s.title + " " + s.start_date.to_s, s.id] }, {include_blank: true}, class: "sale_dropdown" | |
= f.inputs "Sale Information" do | |
= f.input :sales_merchandiser_id, :as => :hidden, :value => proc{current_user.id} | |
= f.input :category_id, as: :hidden | |
= f.input :title | |
= f.input :featured_image, as: :file, label: "Sale Image" | |
= content_tag :li, class: "field_toggle" do | |
%span.show_overwrite_fields Overwrite Versions | |
%span.hide_overwrite_fields Cancel Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyAppName::Application.routes.draw do | |
# ... | |
namespace :admin do | |
resources :sales do | |
resources :consignment_items do | |
collection { post :search_items, to: 'sales#search_consignment_items' } | |
end | |
end | |
end | |
# ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Routing Error | |
No route matches {:action=>"new", :controller=>"messages"} | |
Try running rake routes for more information on available routes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
= semantic_form_for users_path, :method => 'get', :id => "users_search" do |f| | |
= f.input :search, params[:search] | |
= f.submit_tag | |
#... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once '../anet_php_sdk/AuthorizeNet.php'; // The SDK | |
$url = "http://YOURSITE.tld/post_result.php"; | |
$api_login_id = '######'; | |
$transaction_key = '#############'; | |
$md5_setting = '######'; // Your MD5 Setting | |
$amount = "5.99"; | |
AuthorizeNetDPM::directPostDemo($url, $api_login_id, $transaction_key, $amount, $md5_setting); | |
define("AUTHORIZENET_API_LOGIN_ID", $api_login_id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'prawn' | |
Prawn::Document.generate("testing.pdf") do | |
Dir.foreach(".") do |f| | |
text "#{f}" | |
content = File.foreach(f).map(&:line) unless f == "." || f == ".." | |
text "#{content}" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Failures: | |
1) User scopes .adult_purchases_enabled does not return users who are not at least 21 years old | |
Failure/Error: User.adult_purchases_enabled.should_not include(subject) | |
expected [#<User id: 338, first_name: "Romaine", last_name: "Mohr", address1: "87010 Derick Heights", address2: nil, city: "Welchton", state: "Arkansas", zip_code: "11561", avatar: nil, birth_date: "1993-08-06", email: "[email protected]", about: nil, created_at: "2013-08-06 13:31:54", updated_at: "2013-08-06 13:31:55", latitude: 40.5895, longitude: -73.6389, active: false>] not to include #<User id: 338, first_name: "Romaine", last_name: "Mohr", address1: "87010 Derick Heights", address2: nil, city: "Welchton", state: "Arkansas", zip_code: "11561", avatar: nil, birth_date: "1993-08-06 00:00:00", email: "[email protected]", about: nil, created_at: "2013-08-06 13:31:54", updated_at: "2013-08-06 13:31:55", latitude: 40.5895272, longitude: -73.6389038, active: false> | |
Diff: | |
@@ -1,2 +1,2 @@ | |
-[#<User id: 338, f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
# ... | |
# Old scope: scope :adult_purchases_enabled, -> { where(self.age >= 21) } | |
# Working scope: | |
scope :adult_purchases_enabled, -> { where('birth_date <= ?', Time.current.advance(years: -21)) } | |
# ... | |
# Public Methods | |
def age | |
(Time.now.utc().to_s(:number).to_i - self.birth_date.to_time.utc().to_s(:number).to_i)/10e9.to_i |
OlderNewer