我一直得到(显然很常见的)错误R14,不知道什么时候开始但是在安装Papertrail插件后注意到了.在看到其他人提到它之后我也加了oink.我已经尝试过其他人在其他SO问题中尝试过的所有问题,但我似乎无法找到问题/内存泄漏.
Error R14 (Memory quota exceeded)
heroku/web.1: Process running mem=587M(114.7%)
Run Code Online (Sandbox Code Playgroud)
当我看到这个,暂时修复它,我运行heroku restart了一段时间,但我想永久解决这个问题.
从我在Papertrail中看到的,该应用程序只是一遍又一遍地加载相同的页面(主页)(而不是用户流量):
app/web.1: Completed 200 OK in 436ms (Views: 45.5ms | ActiveRecord: 386.2ms)
app/web.1: May 25 18:14:52 5d2105e1-d799-4496-a2af-3785e78998db rails[9]: Oink Action: static_pages#home
app/web.1: May 25 18:14:52 5d2105e1-d799-4496-a2af-3785e78998db rails[9]: Memory usage: 378860 | PID: 19
app/web.1: May 25 18:14:52 5d2105e1-d799-4496-a2af-3785e78998db rails[9]: Oink Log Entry Complete
heroku/web.1: source=web.1 dyno=heroku.25566769.9d9a3da0-db4c-4b51-bc53-b69be9e43cb7 sample#memory_total=209.86MB sample#memory_rss=209.83MB sample#memory_cache=0.02MB sample#memory_swap=0.00MB sample#memory_pgpgin=59278pages sample#memory_pgpgout=5555pages
Run Code Online (Sandbox Code Playgroud)
2分钟后:
heroku/web.1: source=web.1 dyno=heroku.25566769.9d9a3da0-db4c-4b51-bc53-b69be9e43cb7 sample#memory_total=293.73MB sample#memory_rss=291.94MB sample#memory_cache=0.02MB sample#memory_swap=1.77MB sample#memory_pgpgin=80890pages sample#memory_pgpgout=6147pages …Run Code Online (Sandbox Code Playgroud) 我制作了一个设计用户模型并添加了其他字段.当我创建和帐户一切正常,只有电子邮件,pw和pw conf.
然后,我想允许用户转到编辑页面并填写可选的附加字段.但是,当他们提交时,一切都保存为零.
class RegistrationsController < Devise::RegistrationsController
before_action :configure_permitted_parameters, if: :devise_controller?
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_in){ |u| u.permit(:email, :password) }
devise_parameter_sanitizer.for(:sign_up){ |u| u.permit(:name, :username, :about, :email, :password, :password_confirmation)}
devise_parameter_sanitizer.for(:account_update){ |u| u.permit(:name, :username, :about, :email, :password, :password_confirmation) }
end
def update
self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
if resource.update_with_password(user_params)
if is_navigational_format?
flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ? :update_needs_confirmation : :updated
set_flash_message :notice, flash_key
end
sign_in resource_name, resource, :bypass => true
respond_with resource, :location => after_update_path_for(resource)
else
clean_up_passwords resource
respond_with resource
end
end
def user_params
params.require(:user).permit(:email, :password, :current_password, …Run Code Online (Sandbox Code Playgroud) 我正在使用Nokogiri来拉动<h1>和<title>标签,但我无法获得这些:
<meta name="description" content="I design and develop websites and applications.">
<meta name="keywords" content="web designer,web developer">
Run Code Online (Sandbox Code Playgroud)
我有这个代码:
url = 'https://en.wikipedia.org/wiki/Emma_Watson'
page = Nokogiri::HTML(open(url))
puts page.css('title')[0].text puts page.css('h1')[0].text
puts page.css('description')
puts META DESCRIPTION
puts META KEYWORDS
Run Code Online (Sandbox Code Playgroud)
我查看了文档但没有找到任何内容.我会用正则表达式做这个吗?
谢谢.
我正在尝试为我的Ruby on Rails 4应用程序制作一个站点地图.我会使用像这样的dynamic_sitemaps的gem,但是我不能和Heroku一起使用所以我环顾四周找到了这个教程:http://meghagulati.com/2013/12/05/sitemap-xml-on-heroku-with- ruby-on-rails /制作我自己的(稍加更改)但是当我访问myapp.com/sitemap.xml时我收到此错误,希望有人可以帮我找到错误.
ActionController::UnknownFormat in SitemapsController#index
ActionController::UnknownFormat Extracted source (around line #7): respond_to do |format|
#app/controllers/sitemaps_controller.rb
class SitemapsController < ApplicationController
def index
@static_pages = [root_url]
@movies = Movie.all
respond_to do |format|
format.xml
end
@series = Series.all
respond_to do |format|
format.xml
end
end
end
#app/views/sitemaps/index.xml.builder
base_url = "http://#{request.host_with_port}"
xml.instruct! :xml, :version=>'1.0'
xml.tag! 'urlset', 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9' do
xml.url{
xml.loc("http://myapp.com")
xml.changefreq("weekly")
xml.priority(1.0)
}
xml.url{
xml.loc("http://myapp.com/movies")
xml.changefreq("daily")
xml.priority(0.9)
}
xml.url{ …Run Code Online (Sandbox Code Playgroud) 我创建了一个新的Rails 5应用程序rails new appname --api,看起来很棒!我想将它用作React前端的后端,并及时使用Chrome应用程序.现在我想创建一个API.
我使用了以下宝石
我按照他们的Github上的指示进行设置:http://www.developingandrails.com/2015/02/api-authentication-with-devisetokenauth.html
现在,当我运行应用程序时,我得到:
Started GET "/" for 14.144.15.10 at 2016-07-17 17:21:46 +0000
ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
OmniAuth::NoSessionError (You must provide a session to use OmniAuth.):
Run Code Online (Sandbox Code Playgroud)
我在Github和StackOverflow上寻找答案,但似乎没有人有解决方案.
唯一似乎"解决"问题的是添加这个:
# config/application.rb
config.middleware.use Rack::Session::Cookie
Run Code Online (Sandbox Code Playgroud)
但是这个"解决方案"在控制台中给了我这个错误:
SECURITY WARNING: No secret option provided to Rack::Session::Cookie.
This poses a security threat. It is strongly recommended that you
provide a secret to prevent exploits that may be …Run Code Online (Sandbox Code Playgroud) 我希望用户能够轻松找到一个系列,所以想要设置方面.我已按照seachkick的指示进行操作,一切正常,但是当我设置Facets时,我得到以下作为返回.我想让它像他们的文档一样.希望有人能提供帮助.
我在myapp.com/movies中得到这个
{
"name"=> {
"_type"=> "terms",
"missing"=> 0,
"total"=> 1,
"other"=> 0,
"terms"=> [
{
"term"=> "Bloop",
"count"=> 1
}
]
},
"imdb"=> {
"_type"=> "terms",
"missing"=> 0,
"total"=> 1,
"other"=> 0,
"terms"=> [
{
"term" => "http://www.bloop.com",
"count" => 1
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
#app/views/movies/index.html.erb
<%= p @series.facets %>
Run Code Online (Sandbox Code Playgroud)
#app/controllers/movies_controller.rb
def index
query = params[:query].presence || "*"
@movies = Movie.search(query, page: params[:page],
suggest: true,
per_page: 20,
facets: [:name, :imdb])
end
Run Code Online (Sandbox Code Playgroud)
#db/schema.rb
create_table "movies", force: …Run Code Online (Sandbox Code Playgroud) 我最近将我的Ruby on Rails 4应用程序从Heroku移到了Linode.一切都已正确设置,但我需要用文件填充我的数据库,我们称之为movies.sql
我对postgresql命令和VPS不太熟悉,因此无法完成此操作.我上传到Dropbox,因为我看到很多SO帖子,你可以使用S3/Dropbox.
我看到了这样的不同命令(不确定如何在我的情况下去做):
psql -U postgres -d testdb -f /home/you/file.sql
psql -f file.sql dbname
psql -U username -d myDataBase -a -f myInsertFile
那么在我的情况下哪个是正确的,以及当我在Linode中SSH时如何运行?谢谢
ruby ×6
heroku ×2
devise ×1
html-parsing ×1
jwt ×1
linode ×1
memory-leaks ×1
nokogiri ×1
omniauth ×1
postgresql ×1
searchkick ×1
sitemap ×1
sql ×1
vps ×1