Hi all. i am trying to connect StipeConnect to my app.
I downloaded simple code example from
https://github.com/rfunduk/rails-stripe-connect-example
I update and install bundle, copy and change some session files, but receive an error:
NameError in Users#show
Showing /home/ppl/rps/09.25/app_simple_alpha/app/views/users/_connect.html.erb where line #18 raised:
uninitialized constant ActionView::CompiledTemplates::StripeStandalone
Extracted source (around line #18):
<small>Create a standalone Stripe account in</small>
<select class="country" name="country">
#error line <% StripeStandalone::COUNTRIES.each do |country| %>
<option value="<%= country[:code] %>">
<%= country[:name] %>
</option>
Trace of template inclusion: app/views/users/show.html.erb
Here is my files:
db/schema.rb
create_table "users", force: :cascade do |t|
t.string "name"
t.string "email"
t.datetime "created_at"
t.datetime "updated_at"
t.string "password_digest"
t.boolean "admin", default: false
t.boolean "email_confirmed", default: false
t.string "confirm_token"
t.string "activation_digest"
t.boolean "activated", default: false
t.datetime "activated_at"
t.string "remember_digest"
t.string "reset_digest"
t.datetime "reset_sent_at"
t.string "publishable_key"
t.string "secret_key"
t.string "stripe_user_id"
t.string "currency"
t.string "stripe_account_type"
t.text "stripe_account_status", default: "{}"
end
models/user.rb
class User < ActiveRecord::Base
attr_accessor :remember_token, :activation_token, :reset_token
before_save :downcase_email
before_create :create_activation_digest
validates :name, presence: true, length: { maximum: 50 }
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i
validates :email, presence: true, format: { with: VALID_EMAIL_REGEX },
uniqueness: { case_sensitive: false }
has_secure_password
validates :password, length: { minimum: 6 }, allow_nil: true
serialize :stripe_account_status, JSON
# General 'has a Stripe account' check
def connected?; !stripe_user_id.nil?; end
# Stripe account type checks
def managed?; stripe_account_type == 'managed'; end
def standalone?; stripe_account_type == 'standalone'; end
def oauth?; stripe_account_type == 'oauth'; end
def manager
case stripe_account_type
when 'managed' then StripeManaged.new(self)
when 'standalone' then StripeStandalone.new(self)
when 'oauth' then StripeOauth.new(self)
end
end
def can_accept_charges?
return true if oauth?
return true if managed? && stripe_account_status['charges_enabled']
return true if standalone? && stripe_account_status['charges_enabled']
return false
end
# Returns the hash digest of the given string.
def self.digest(string)
cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST :
BCrypt::Engine.cost
BCrypt::Password.create(string, cost: cost)
end
# Returns a random token.
def self.new_token
SecureRandom.urlsafe_base64
end
# Remembers a user in the database for use in persistent sessions.
def remember
self.remember_token = User.new_token
update_attribute(:remember_digest, User.digest(remember_token))
end
# Returns true if the given token matches the digest.
def authenticated?(remember_token)
return false if remember_digest.nil?
BCrypt::Password.new(remember_digest).is_password?(remember_token)
end
# Forgets a user.
def forget
update_attribute(:remember_digest, nil)
end
# Returns true if the given token matches the digest.
def authenticated?(attribute, token)
digest = send("#{attribute}_digest")
return false if digest.nil?
BCrypt::Password.new(digest).is_password?(token)
end
# Activates an account.
def activate
update_attribute(:activated, true)
update_attribute(:activated_at, Time.zone.now)
end
# Sends activation email.
def send_activation_email
UserMailer.account_activation(self).deliver_now
end
# Sets the password reset attributes.
def create_reset_digest
self.reset_token = User.new_token
update_attribute(:reset_digest, User.digest(reset_token))
update_attribute(:reset_sent_at, Time.zone.now)
end
# Sends password reset email.
def send_password_reset_email
UserMailer.password_reset(self).deliver_now
end
# Returns true if a password reset has expired.
def password_reset_expired?
reset_sent_at < 2.hours.ago
end
private
# Converts email to all lower-case.
def downcase_email
self.email = email.downcase
end
# Creates and assigns the activation token and digest.
def create_activation_digest
self.activation_token = User.new_token
self.activation_digest = User.digest(activation_token)
end
def create_remember_token
self.remember_token = User.encrypt(User.new_remember_token)
end
end
controllers/users_controller.rb
class UsersController < ApplicationController
before_action :logged_in_user, only: [:index, :edit, :update, :destroy]
before_action :correct_user, only: [:edit, :update]
before_action :admin_user, only: :destroy
before_action :require_user, except: %w{ new create }
require 'will_paginate/array'
def index
@users = User.all.paginate(page: params[:page])
end
def show
@user = User.find(params[:id])
@plans = Stripe::Plan.all
end
def new
@user = User.new#(params[:user])
end
def edit
@user = User.find(params[:id])
end
#def update
# @user = User.find(params[:id])
# if @user.update_attributes(user_params)
# flash[:success] = "Profile updated"
# redirect_to @user
# else
# render 'edit'
# end
I downloaded simple code example from
https://github.com/rfunduk/
I update and install bundle, copy and change some session files, but receive an error:
NameError in Users#show
Showing /home/ppl/rps/09.25/app_
uninitialized constant ActionView::CompiledTemplates:
Extracted source (around line #18):
<small>Create a standalone Stripe account in</small>
<select class="country" name="country">
#error line <% StripeStandalone::COUNTRIES.
<option value="<%= country[:code] %>">
<%= country[:name] %>
</option>
Trace of template inclusion: app/views/users/show.html.erb
Here is my files:
db/schema.rb
create_table "users", force: :cascade do |t|
t.string "name"
t.string "email"
t.datetime "created_at"
t.datetime "updated_at"
t.string "password_digest"
t.boolean "admin", default: false
t.boolean "email_confirmed", default: false
t.string "confirm_token"
t.string "activation_digest"
t.boolean "activated", default: false
t.datetime "activated_at"
t.string "remember_digest"
t.string "reset_digest"
t.datetime "reset_sent_at"
t.string "publishable_key"
t.string "secret_key"
t.string "stripe_user_id"
t.string "currency"
t.string "stripe_account_type"
t.text "stripe_account_status", default: "{}"
end
models/user.rb
class User < ActiveRecord::Base
attr_accessor :remember_token, :activation_token, :reset_token
before_save :downcase_email
before_create :create_activation_digest
validates :name, presence: true, length: { maximum: 50 }
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-
validates :email, presence: true, format: { with: VALID_EMAIL_REGEX },
uniqueness: { case_sensitive: false }
has_secure_password
validates :password, length: { minimum: 6 }, allow_nil: true
serialize :stripe_account_status, JSON
# General 'has a Stripe account' check
def connected?; !stripe_user_id.nil?; end
# Stripe account type checks
def managed?; stripe_account_type == 'managed'; end
def standalone?; stripe_account_type == 'standalone'; end
def oauth?; stripe_account_type == 'oauth'; end
def manager
case stripe_account_type
when 'managed' then StripeManaged.new(self)
when 'standalone' then StripeStandalone.new(self)
when 'oauth' then StripeOauth.new(self)
end
end
def can_accept_charges?
return true if oauth?
return true if managed? && stripe_account_status['
return true if standalone? && stripe_account_status['
return false
end
# Returns the hash digest of the given string.
def self.digest(string)
cost = ActiveModel::SecurePassword.
BCrypt::Password.create(
end
# Returns a random token.
def self.new_token
SecureRandom.urlsafe_base64
end
# Remembers a user in the database for use in persistent sessions.
def remember
self.remember_token = User.new_token
update_attribute(:remember_
end
# Returns true if the given token matches the digest.
def authenticated?(remember_token)
return false if remember_digest.nil?
BCrypt::Password.new(remember_
end
# Forgets a user.
def forget
update_attribute(:remember_
end
# Returns true if the given token matches the digest.
def authenticated?(attribute, token)
digest = send("#{attribute}_digest")
return false if digest.nil?
BCrypt::Password.new(digest).
end
# Activates an account.
def activate
update_attribute(:activated,
update_attribute(:activated_
end
# Sends activation email.
def send_activation_email
UserMailer.account_activation(
end
# Sets the password reset attributes.
def create_reset_digest
self.reset_token = User.new_token
update_attribute(:reset_
update_attribute(:reset_sent_
end
# Sends password reset email.
def send_password_reset_email
UserMailer.password_reset(
end
# Returns true if a password reset has expired.
def password_reset_expired?
reset_sent_at < 2.hours.ago
end
private
# Converts email to all lower-case.
def downcase_email
self.email = email.downcase
end
# Creates and assigns the activation token and digest.
def create_activation_digest
self.activation_token = User.new_token
self.activation_digest = User.digest(activation_token)
end
def create_remember_token
self.remember_token = User.encrypt(User.new_
end
end
controllers/users_controller.
class UsersController < ApplicationController
before_action :logged_in_user, only: [:index, :edit, :update, :destroy]
before_action :correct_user, only: [:edit, :update]
before_action :admin_user, only: :destroy
before_action :require_user, except: %w{ new create }
require 'will_paginate/array'
def index
@users = User.all.paginate(page: params[:page])
end
def show
@user = User.find(params[:id])
@plans = Stripe::Plan.all
end
def new
@user = User.new#(params[:user])
end
def edit
@user = User.find(params[:id])
end
#def update
# @user = User.find(params[:id])
# if @user.update_attributes(user_
# flash[:success] = "Profile updated"
# redirect_to @user
# else
# render 'edit'
# end
No comments:
Post a Comment