Ruby on Rails
Sunday, December 27, 2015
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/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
Subscribe to:
Post Comments (Atom)
Blog Archive
- August 2024 (1)
- April 2024 (1)
- July 2023 (1)
- February 2023 (38)
- November 2021 (1)
- January 2021 (1)
- December 2020 (1)
- March 2020 (49)
- February 2020 (59)
- January 2020 (109)
- December 2019 (130)
- November 2019 (77)
- October 2019 (106)
- September 2019 (66)
- August 2019 (96)
- July 2019 (27)
- June 2019 (52)
- May 2019 (51)
- April 2019 (53)
- March 2019 (115)
- February 2019 (153)
- January 2019 (222)
- December 2018 (155)
- November 2018 (104)
- October 2018 (164)
- September 2018 (89)
- August 2018 (209)
- July 2018 (126)
- June 2018 (171)
- May 2018 (80)
- April 2018 (81)
- March 2018 (126)
- February 2018 (161)
- January 2018 (153)
- December 2017 (55)
- November 2017 (53)
- October 2017 (96)
- September 2017 (250)
- August 2017 (99)
- July 2017 (253)
- June 2017 (175)
- May 2017 (94)
- April 2017 (140)
- March 2017 (126)
- February 2017 (148)
- January 2017 (80)
- December 2016 (116)
- November 2016 (56)
- October 2016 (105)
- September 2016 (38)
- August 2016 (100)
- July 2016 (173)
- June 2016 (192)
- May 2016 (177)
- April 2016 (211)
- March 2016 (318)
- February 2016 (269)
- January 2016 (346)
- December 2015 (363)
- November 2015 (380)
- October 2015 (269)
- September 2015 (365)
- August 2015 (287)
- July 2015 (539)
- June 2015 (430)
- May 2015 (337)
- April 2015 (453)
- March 2015 (350)
- February 2015 (386)
- January 2015 (436)
- December 2014 (431)
- November 2014 (371)
- October 2014 (319)
- September 2014 (423)
- August 2014 (475)
- July 2014 (505)
- June 2014 (444)
- May 2014 (601)
- April 2014 (489)
- March 2014 (486)
- February 2014 (396)
- January 2014 (429)
- December 2013 (323)
- November 2013 (371)
- October 2013 (488)
- September 2013 (438)
- August 2013 (442)
- July 2013 (651)
- June 2013 (557)
- May 2013 (751)
- April 2013 (582)
- March 2013 (775)
- February 2013 (588)
- January 2013 (697)
- December 2012 (682)
- November 2012 (830)
- October 2012 (879)
- September 2012 (1091)
- August 2012 (851)
- July 2012 (872)
- June 2012 (874)
- May 2012 (845)
- April 2012 (979)
- March 2012 (1003)
- February 2012 (1272)
- January 2012 (1291)
- December 2011 (1184)
- November 2011 (1160)
- October 2011 (1107)
- September 2011 (1184)
- August 2011 (1451)
- July 2011 (1313)
- June 2011 (1174)
- May 2011 (1351)
- April 2011 (1364)
- March 2011 (1429)
- February 2011 (1332)
- January 2011 (1427)
- December 2010 (1464)
- November 2010 (1456)
- October 2010 (1460)
- September 2010 (1467)
- August 2010 (1496)
- July 2010 (1500)
- June 2010 (1411)
- May 2010 (1418)
- April 2010 (1054)
No comments:
Post a Comment