我正在尝试ssh登录到我的远程服务器.但每当我尝试使用ssh命令登录终端时:
ssh root@{ip_address}
Run Code Online (Sandbox Code Playgroud)
我收到错误:
Connection closed by {ip_address}
Run Code Online (Sandbox Code Playgroud)
我检查了主机拒绝和主机允许,文件中没有任何内容.我不知道为什么会这样?
它发生在我改变我的工作站和密钥改变了.当我尝试ssh登录时,它要求添加密钥,我输入yes然后它关闭了连接.
有没有办法再次与ssh联系?
非常感谢您的帮助.
谢谢.
编辑:
输出ssh -v -v -v -v root @ {ip_address}是
OpenSSH_5.9p1 Debian-5ubuntu1.1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to {ip_address} [{ip_address}] port 22.
debug1: Connection established.
debug3: Incorrect RSA1 identifier
debug3: Could not load "/home/mona/.ssh/id_rsa" as a RSA1 public key
debug1: identity file /home/mona/.ssh/id_rsa type 1
debug1: Checking blacklist file …
Run Code Online (Sandbox Code Playgroud) 我使用https://github.com/plataformatec/devise/wiki/OmniAuth%3a-Overview整合了omniauth-facebook .但我得到的错误是:
Could not authenticate you from Facebook because "Invalid credentials".
Run Code Online (Sandbox Code Playgroud)
在日志中,得到这个:
Authentication failure! invalid_credentials: OAuth2::Error, : {"error":{"message":"This authorization code has been used.","type":"OAuthException","code":100}}
Run Code Online (Sandbox Code Playgroud)
我已经安装好了.当我点击Facebook登录链接时,它回来设计标志"www.mealnut.com/user/sign_in# = "并给出上述错误.我在https://github.com/plataformatec/devise/wiki/OmniAuth%3a-Overview上检查了"无效凭证"的解决方案,如上所述,我的应用程序是App Type = Web的标题集.不明白为什么它不起作用.
我的应用程序正在等待来自Facebook的评论.但我不认为这与此错误有关.以下是我为omniauth-facebook所做的事情:
Gemfile包含:
gem "omniauth", "~> 1.1.4"
gem 'omniauth-facebook', '1.4.1'
Run Code Online (Sandbox Code Playgroud)
在用户模型中,添加:
devise :omniauthable, :omniauth_providers => [:facebook]
attr_accessible :provider, :uid
def self.find_for_facebook_oauth(auth, signed_in_resource=nil)
user = User.where(:provider => auth.provider, :uid => auth.uid).first
unless user
user = User.create(name:auth.extra.raw_info.name,
provider:auth.provider,
uid:auth.uid,
email:auth.info.email,
password:Devise.friendly_token[0,20]
)
end
user
end
Run Code Online (Sandbox Code Playgroud)
devise.rb
require "omniauth-facebook"
config.omniauth :facebook, …
Run Code Online (Sandbox Code Playgroud) 我的问题有点类似于问题nested_form gem add works但删除失败...为什么?.
我有一个产品编辑页面,其中产品的子类别在product_sub_categories中链接.要将子类别分配给产品,我使用了product_sub_categories的嵌套属性.因此,产品可以有多个sub_categories.
在产品型号中,
has_many :product_sub_categories
has_many :sub_categories, :through => :product_sub_categories
accepts_nested_attributes_for :product_sub_categories, :allow_destroy => true
Run Code Online (Sandbox Code Playgroud)
并在产品编辑视图中:
<%= f.fields_for :product_sub_categories do |product_sub_category| %>
<%= product_sub_category.collection_select :sub_category_id, @sub_categories, :id, :sub_category, {:include_blank => 'Select a Sub Category'} %>
<%= product_sub_category.link_to_remove "Remove", :class => "subcatlink" %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
代码适用于添加子类别.但是当我删除子类别时失败了.日志给出:
"product_sub_categories_attributes"=>{"0"=>{"sub_category_id"=>"1", "_destroy"=>"false", "id"=>"9"}, "1"=>{"sub_category_id"=>"1", "_destroy"=>"1", "id"=>"17"}},
ProductSubCategory Load (0.2ms)[0m [1mSELECT `product_sub_categories`.* FROM `product_sub_categories` WHERE `product_sub_categories`.`product_id` = 8 AND `product_sub_categories`.`id` IN (9, 17)
Run Code Online (Sandbox Code Playgroud)
虽然,我点击删除,它只是传递_destroy ="1",但不会破坏子类别.
任何人都可以告诉解决方案吗?
更新:
非常抱歉我的愚蠢错误.我没有看到正确的代码.在我复制的模型中
accepts_nested_attributes_for :product_sub_categories …
Run Code Online (Sandbox Code Playgroud) nested-forms nested-attributes ruby-on-rails-3 ruby-on-rails-3.2
我正在我的 linode 服务器上运行“捆绑安装”。但无法安装 rubyracer 的原因。捆绑安装输出为:
Installing therubyracer (0.11.0)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb
checking for main() in -lpthread... yes
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/bin/ruby
--with-pthreadlib
--without-pthreadlib
--enable-debug
--disable-debug
/usr/local/lib/ruby/gems/1.9.1/gems/therubyracer-0.11.0/ext/v8/build.rb:50:in `build_with_rubygem_libv8': undefined local variable or method …
Run Code Online (Sandbox Code Playgroud) 我在rails应用程序中使用动作邮件发送电子邮件.但它只允许一个默认发件人.这是我的UserMailer类:
class UserMailer < ActionMailer::Base
default :from => "example@example.com"
def welcome_email(user, order)
@user = user
@order = order
mail(:to => user.email, :subject => "Your Order")
end
def signup_email(user)
@user = user
mail(:to => user.email, :subject => "Thank you.")
end
def invite_confirm(curuser,usemail,post)
@greeting = "Hi"
@user = curuser
@post = post
mail(:to => user.email, :subject => "Hello")
end
end
Run Code Online (Sandbox Code Playgroud)
我试过这个:
class UserMailer < ActionMailer::Base
def welcome_email(user, order)
@user = user
@order = order
mail(:to => user.email, :subject => "Your Order", :from …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用RestClient和mailgun发送邮件.
我在rails应用程序中安装了gem,并在config/application.rb中定义了"require'rest_client'".
然后发送邮件,我在我的消息控制器中写了这个:
RestClient.post "https://api:key-3ax6xnjp29jd6fds4gc373sgvjxteol0" "@api.mailgun.net/v2/samples.mailgun.org/messages", :from => "Excited User <me@samples.mailgun.org>", :to => "sergeyo@profista.com, serobnic@mail.ru", :subject => "Hello", :text => "Testing some Mailgun awesomness!"
Run Code Online (Sandbox Code Playgroud)
我已经使用mailgun创建了帐户,并使用了我帐户中提到的密钥和网址.
当我运行代码时,它会给出错误:
RestClient::ResourceNotFound (404 Resource Not Found):
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我解决这个问题吗?
我试图使用jquery的getJSON函数访问数据,但无法成功.
这是我的js文件:
$(document).ready(function(){
$("button").click(function(){
$.getJSON( "https://www.bitstamp.net/api/eur_usd/", function( data ) {
alert(data);
});
});
});
Run Code Online (Sandbox Code Playgroud)
能有人帮助我完成这项工作吗?
真的很感激.
我希望在发送电子邮件时在电子邮件中显示公司徽标。我想到了动作邮件程序基础,并且有支持邮件中图像的附件内联功能。
我是这样实现的:
在 user_mailer.rb 中
def welcome_email(user)
@user = user
@url = "http://mealnut.com"
attachments.inline['mealnut.png']
mail(:to => user.email, :subject => "Mealnut: New Order #{order.id}")
end
Run Code Online (Sandbox Code Playgroud)
在config/application.rb中:
config.action_mailer.default_url_options = { :host => "mealnut.com" }
Run Code Online (Sandbox Code Playgroud)
在welcome_email.html.web中
<div class="logo">
<%= image_tag attachments['mealnut.png'].url, :alt => 'Mealnut', :class => 'photo' %>
</div>
Run Code Online (Sandbox Code Playgroud)
但它给出了错误:
undefined method `url' for nil:NilClass
Run Code Online (Sandbox Code Playgroud)
出了什么问题吗?
我有文本字段,用户将编写食品的食谱.对于文本格式,我只需安装ckeditor.
在gemfile中添加了gem"ckeditor"并执行了这个:
rails generate ckeditor:install --orm=active_record --backend=paperclip
Run Code Online (Sandbox Code Playgroud)
如github.com/galetahub/ckeditor中所述.
然后我将我的食谱文本区域更新为:
<%= f.cktext_area :recipe, :size => 5, :id => "field-area5", :ckeditor => {:language => "us"} %>
Run Code Online (Sandbox Code Playgroud)
它正确显示所有格式化工具和格式文本.但是当我提交内容并显示输出时,
<%= @product.recipe %>
Run Code Online (Sandbox Code Playgroud)
它显示HTML标签而不是我格式化的方式.例如
<p><strong>Recipe</strong></p> <h1><span style="font-family:georgia,serif"><em>i dont know anything</em></span></h1>
Run Code Online (Sandbox Code Playgroud)
任何人都能帮助解决这个问题的原因吗?如何显示格式化内容?非常感谢您的帮助.
谢谢.
我在我的rails应用程序中使用CKeditor.我按照这个:https://github.com/galetahub/ckeditor来实现ckeditor.
所以我的gemfile包含:
gem "ckeditor"
Run Code Online (Sandbox Code Playgroud)
在我的路线中,我有:
mount Ckeditor::Engine => '/ckeditor'
Run Code Online (Sandbox Code Playgroud)
我还创建了ckeditor模型文件.
这是我的查看文件:
<%= m.cktext_area :message, :class => "message-body", :placeholder => "Your content", :ckeditor => {:toolbar => "MyToolbar"} %>
Run Code Online (Sandbox Code Playgroud)
而我在assets/javascripts/ckeditor中的config.js是:
CKEDITOR.editorConfig = function( config )
{
// Define changes to default configuration here. For example:
// config.language = 'fr';
// config.uiColor = '#AADC6E';
/* Filebrowser routes */
// The location of an external file browser, that should be launched when "Browse Server" button is pressed.
config.filebrowserBrowseUrl = "/ckeditor/attachment_files"; …
Run Code Online (Sandbox Code Playgroud) 我知道这非常非常简单,但是没有得到如何做。
end_time = Time.new(Date.today.year, Date.today.month, Date.today.day, 8, 00, 00).strftime("%H:%M:%S")
Run Code Online (Sandbox Code Playgroud)
但是在上面的代码中,我希望明天而不是今天,即“ +1天”。我该怎么做?
我试过了:
end_time = Time.new(Date.today.year, Date.today.month, Date.today.day, 8, 00, 00).strftime("%H:%M:%S") + 1.day
Run Code Online (Sandbox Code Playgroud)
要么
end_time = Time.new(Date.tomorrow.year, Date.tomorrow.month, Date.tomorrow.day, 8, 00, 00).strftime("%H:%M:%S")
Run Code Online (Sandbox Code Playgroud)
但是没用。有人可以回答吗?
我有两个字段,first_name和brand_name。用户在登录期间输入first_name。如果他是所有者,则输入brand_name。用户创建帐户时,默认情况下,brand_name等于first_name。用户可以稍后进行更改。
为此,我在User模型中编写了此方法,
def brand_name
first_name
end
Run Code Online (Sandbox Code Playgroud)
但是,尽管用户输入了不同的brand_name,但仍将brand_name设置为first_name。我尝试过这种方式:
def brand_name
if brand_name.nil?
first_name
else
brand_name
end
end
Run Code Online (Sandbox Code Playgroud)
但给出错误-SystemStackError:
stack level too deep
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?
actionmailer ×2
ckeditor ×2
activerecord ×1
datetime ×1
facebook ×1
getjson ×1
jquery ×1
mailgun ×1
nested-forms ×1
omniauth ×1
openssh ×1
rest-client ×1
ruby ×1
rubygems ×1
ssh ×1
therubyracer ×1