我正在尝试使用Puma Web服务器部署Rails应用程序.当尝试使用配置文件启动Puma服务器时,bundle exec puma -C config/puma.rb我收到一个错误,表明该地址已被使用.
有人知道如何解决这个问题吗?
bundle exec puma -C config/puma.rb
[23699] Puma starting in cluster mode...
[23699] * Version 2.11.3 (ruby 2.0.0-p353), codename: Intrepid Squirrel
[23699] * Min threads: 5, max threads: 5
[23699] * Environment: development
[23699] * Process workers: 2
[23699] * Preloading application
Jdbc-MySQL is only for use with JRuby
[23699] * Listening on tcp://0.0.0.0:3000
/.rvm/gems/ruby-2.0.0-p353/gems/puma-2.11.3/lib/puma/binder.rb:210:in `initialize': Address already in use - bind(2) (Errno::EADDRINUSE)
from /.rvm/gems/ruby-2.0.0-p353/gems/puma-2.11.3/lib/puma/binder.rb:210:in `new'
from /Users/lexi87/.rvm/gems/ruby-2.0.0-p353/gems/puma-2.11.3/lib/puma/binder.rb:210:in `add_tcp_listener'
from /.rvm/gems/ruby-2.0.0-p353/gems/puma-2.11.3/lib/puma/binder.rb:96:in `block …Run Code Online (Sandbox Code Playgroud) 我正在关注ruby.railstutorial.我运行命令"git push heroku master",它会吐出这个错误.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
我在我的rails app"/ Users/lexi87/rails_projects/first_app"里面.有解决方案吗
我使用paypal重复宝石设置PayPal.我需要帮助了解如何实施PayPal IPN.
任何帮助将不胜感激,因为这是我的项目的最后一步.我需要设置IPN,以便当用户从其PayPal帐户取消/暂停结算时,它将显示为从我的数据库中取消.
Paypal_payment.rb:
def initialize(subscription)
@subscription = subscription
end
def checkout_details
process :checkout_details
end
def checkout_url(options)
process(:checkout, options).checkout_url
end
def make_recurring
process :request_payment
process :create_recurring_profile, period: :monthly, frequency: 1, start_at: Time.zone.now
end
def suspend
process :suspend, :profile_id => @subscription.paypal_recurring_profile_token
end
def reactivate
process :reactivate, :profile_id => @subscription.paypal_recurring_profile_token
end
private
def process(action, options = {})
options = options.reverse_merge(
token: @subscription.paypal_payment_token,
payer_id: @subscription.paypal_customer_token,
description: @subscription.plan.name,
amount: @subscription.plan.price,
ipn_url: "http://mydomain.com/paypal/ipn",
currency: "USD"
)
response = PayPal::Recurring.new(options).send(action)
raise response.errors.inspect if response.errors.present?
response
end …Run Code Online (Sandbox Code Playgroud) 我正在关注Lynda ruby on rails教程.几次尝试失败后,我已经运行了代码"rake db:migrate".然后告诉我运行"rake db:migrate VERSION = 0".这再次给了我错误,这次我无法解决它.我昨晚和今天早上都试过无济于事.
请记住,在回答我是新手编码时,请以新手可以理解的方式解释.
lexi87$ rake db:migrate VERSION=0
== AlterUsers: reverting =====================================================
-- remove_index("admin_users", "username")
rake aborted!
An error has occurred, all later migrations canceled:
Index name 'index_admin_users_on_username' on table 'admin_users' does not exist
/Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/schema_statements.rb:587:in `index_name_for_remove'
/Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/schema_statements.rb:366:in `remove_index'
/Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.9/lib/active_record/migration.rb:466:in `block in method_missing'
/Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.9/lib/active_record/migration.rb:438:in `block in say_with_time'
/Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.9/lib/active_record/migration.rb:438:in `say_with_time'
/Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.9/lib/active_record/migration.rb:458:in `method_missing'
/Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.9/lib/active_record/migration.rb:334:in `method_missing'
/Users/lexi87/Sites/simple_cms/db/migrate/20130108015542_alter_users.rb:14:in `down'
/Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.9/lib/active_record/migration.rb:376:in `down'
/Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.9/lib/active_record/migration.rb:410:in `block (2 levels) in migrate'
/Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.9/lib/active_record/migration.rb:410:in `block in migrate'
/Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection'
/Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.9/lib/active_record/migration.rb:389:in `migrate'
/Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.9/lib/active_record/migration.rb:528:in `migrate'
/Users/lexi87/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.9/lib/active_record/migration.rb:720:in `block …Run Code Online (Sandbox Code Playgroud) 运行'heroku run rake'时出现此错误:
no such file to load -- faker
/app/lib/tasks/sample_data.rake:1:in `require'
/app/lib/tasks/sample_data.rake:1:in `<top (required)>'
Run Code Online (Sandbox Code Playgroud)
我有一个gem'faker','0.3.1'在group:development下,:test在Gemfile中.
我在sample_data.rake中要求'faker'
source 'https://rubygems.org'
gem 'rails', '3.2.11'
gem 'gravatar_image_tag', '0.1.0'
group :development, :test do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.8'
gem 'guard-spork', '1.2.0'
gem 'faker', '0.3.1'
gem 'spork', '0.8.4'
gem 'will_paginate', '3.0'
gem 'webrat', '0.7.1'
gem 'capybara', '1.1.2'
gem 'annotate', '2.5.0'
gem 'factory_girl_rails', '1.0'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', …Run Code Online (Sandbox Code Playgroud) 我想为用户提供一个"随机"选项,以便他们可以从数据库中选择以前创建的日期创意(在letsgos表中).有一个"让我们去......"部分,用户可以填写表格并提出他们想要继续的日期.将会有用户无法自己提出约会想法.因此,对于那些无法创建自己日期的用户,我想提供一个"随机"按钮,每次点击都会在表单中插入一个日期(来自数据库).letgos表中数据库中的日期具有content并tag分配给它们.当用户点击随机时,它应该使用内容和标记填充表单(每次随机点击应显示数据库中的新数据).我没有任何javascript经验,所以我不确定我是否正确地做到了这一点.
/views/letsgos/_form.html.erb:
<%= form_for(@letsgo) do |f| %>
<div class="field">
<%= f.text_area :content, placeholder: "Propose new date..." %>
</div>
<%= f.select :tag, options_for_select( [["Select One", ""], "Eat/Drink", "Listen/Watch", "Play", "Explore", "Other"]) %>
<a href="/letsgos/random" class="ajax">Click here for a Random letsgo</a>
<%= f.submit "Post" %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
/views/layouts/application.html.erb
<head>
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<script>
$(document).ready(function() {
$('.ajax').click(function() {
$.get(this.href, function(response) {
console.log(response);
$('body').html(response);
});
});
});
<script>
</head>
Run Code Online (Sandbox Code Playgroud)
letgo控制器:
def create
@letsgo = current_user.letsgos.build(letsgo_params)
if @letsgo.save
flash[:success] = "Date …Run Code Online (Sandbox Code Playgroud) 我有一个高级搜索表单,我想向用户提供一个保存选项的选项.我怎么能做到这一点?
用户应该能够填写高级搜索表单的选项,然后单击"保存此搜索"链接,该链接将存储他们的选项.有了这个,每个用户都将拥有自定义的默认搜索选项,因此每次访问时都不需要重新输入详细信息.
我认为这对未来很多人都有帮助.
搜索控制器:
def new
@search = Search.new
render layout: 'new_application'
end
def create
@search = Search.new(params[:search])
if @search.save
redirect_to @search
else
render 'new'
end
end
def show
@user = current_user
@search = Search.find(params[:id])
@users = @search.users
render 'users/index', layout: 'new_application'
end
def update
@search = Search.find(params[:id])
if @search.update_attributes(params[:search])
redirect_to @search
else
render 'new'
end
end
def index
if location = Location.find_by_zipcode(params[:search])
latitude = location.latitude * Math::PI / 180
longitude = location.longitude * Math::PI / 180
locations = Location.search( …Run Code Online (Sandbox Code Playgroud) 我正在寻找为paypal经常性宝石设置付款暂停(跟随铁轨演员).我不确定是否需要设置IPN,因为在gem的文档中没有提到它.我目前的代码不采取任何行动.
我在模型中定义了取消重复,但我不知道如何完成代码,因为我很难理解这一切是如何工作的.其他人已经问过这个问题,但没有答案.
如果有人有时间资产我,那就太棒了!
问题是如何暂停/取消用户定期付款.
Paypal_payment.rb:
def initialize(subscription)
@subscription = subscription
end
def checkout_details
process :checkout_details
end
def checkout_url(options)
process(:checkout, options).checkout_url
end
def make_recurring
process :request_payment
process :create_recurring_profile, period: :monthly, frequency: 1, start_at: Time.zone.now
end
def suspend
process :suspend, :profile_id => @subscription.paypal_recurring_profile_token
end
private
def process(action, options = {})
options = options.reverse_merge(
token: @subscription.paypal_payment_token,
payer_id: @subscription.paypal_customer_token,
description: @subscription.plan.name,
amount: @subscription.plan.price,
currency: "USD"
)
response = PayPal::Recurring.new(options).send(action)
raise response.errors.inspect if response.errors.present?
response
end
end
Run Code Online (Sandbox Code Playgroud)
订阅控制器:
def new
plan = Plan.find(params[:plan_id])
@subscription = …Run Code Online (Sandbox Code Playgroud) 我正在使用Stripe进行订阅,因此当用户取消订阅时(关闭自动续订),它会保持订阅有效,直到Stripe的结算周期结束.
该操作通过Stripe工作,但我如何设置以便cancelled我的数据库中的列具有相同的效果?目前,如果用户点击取消订阅链接,它会将其cancelled列标记为1.我希望它不会在结算期结束前标记为已取消,因此用户可以继续访问该网站,直到最后一个结算日(我已打开autorenwal)
我已阅读txdavidtx建议.他建议将所有用户标记为在结算周期结束时取消.那种方法不适合我想要完成的任务.
我订阅设置为autorenew.我需要cancel创建一个仅current_user在结算周期结束时标记为已取消的操作.
例如:
用户A在9月27日报名参加月度订阅.用户A决定在12月15日取消订阅.用户A的订阅还剩12天.用户A单击该cancel链接.用户A在其PayPal或Stripe帐户中已取消自动更新和订阅.在我的数据库中,他们的cancelled属性值在12天(12月27日)结束之前不会改变.
如果有人可以提供帮助那就太棒了.
订阅控制器:
def new
plan = Plan.find(params[:plan_id])
@subscription = plan.subscriptions.build
render layout: 'new_application'
if params[:PayerID]
@subscription.paypal_customer_token = params[:PayerID]
@subscription.paypal_payment_token = params[:token]
@subscription.email = @subscription.paypal.checkout_details.email
end
end
def create
@subscription = Subscription.new(params[:subscription])
if @subscription.save_with_payment
redirect_to @subscription, :notice => "Thank you for subscribing!"
else
render :new
end
end
def show
@subscription = Subscription.find(params[:id])
render layout: 'new_application'
end
def paypal_checkout
plan = Plan.find(params[:plan_id]) …Run Code Online (Sandbox Code Playgroud) 我正在关注ruby on rails教程,我在第8课注册失败.我在提交信息时收到模板丢失错误.
Missing template users/create, application/create with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in: * "/Users/lexi87/rails_projects/sample_app/app/views"
Run Code Online (Sandbox Code Playgroud)
我仔细检查了他为行打开的文件.没有什么不同.
Users_controllers.rb
class UsersController < ApplicationController
def show
@user = User.find(params[:id])
@title = @user.name
end
def new
@user = User.new
@title = "Sign up"
end
def create
@user = User.new(params[:user])
if @user.save
# Handle a successful save.
else
@title = "Sign up"
render = 'new'
end
end
end
Run Code Online (Sandbox Code Playgroud)
New.html.erb
<h1>Sign up</h1>
<%= form_for(@user) do |f| %>
<%= render 'shared/error_messages'%>
<div class="field">
<%= f.label …Run Code Online (Sandbox Code Playgroud)