很长一段时间以来,我一直在使用rails.现在我在ActionMailer中面临一个小问题.我想在用户注册时发送电子邮件以确认他的注册.我能够发送电子邮件中的发展模式,但如果作为没有在生产模式.
异常Errno :: ECONNREFUSED:连接被拒绝 -每次调用传递方法时,connect(2)都会出现.
我写了以下代码.
我的SMTP配置看起来:
config.action_mailer.default_url_options = {:host =>"localhost:3000"}
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
:openssl_verify_mode => OpenSSL::SSL::VERIFY_NONE,
:ssl => true,
:enable_starttls_auto => true, #this is the important stuff!
:address => 'smtp.xxxx.xxx',
:port => xxx,
:domain => 'xxxxxx',
:authentication => :plain,
:user_name => 'xxxxxxx@xxx.xxx',
:password => 'xxxxxxxxx'
}
Run Code Online (Sandbox Code Playgroud)
在控制器中,我写了以下内容:
def confirm_registration_in_c
@user = User.find_by_email(asdf123@gmail.com)
if @user
UserMailer.confirm_registration(@user).deliver
end
end
Run Code Online (Sandbox Code Playgroud)
在我的user_mailer.rb中:
class …Run Code Online (Sandbox Code Playgroud)
我一直面临将我的ruby on rails代码推送到AWS ElasticBeansTalk服务器的问题.我第一次能够初始化EB,提交并推送代码并尝试运行EB服务器.一切都很好,但经过一些提交,突然之间就会引发异常,如下所示.
remote: error: Unable to create application version: You cannot have more than 500 Application Versions. Either remove some Application Versions or request a limit increase.
Run Code Online (Sandbox Code Playgroud)
我无法找到该怎么做.
请问有人能帮我解决问题吗?
提前致谢.
ruby-on-rails amazon-web-services ruby-on-rails-3 amazon-elastic-beanstalk
我写了以下代码.当我运行此文件时,生成graph.dot文件而不是graph.jpg.我不明白为什么会这样.有没有人有任何想法?
我的代码如下:
require 'rgl/adjacency'
require 'rgl/dot'
dg=RGL::DirectedAdjacencyGraph[1,2,2,3,2,4,4,5,6,4,1,6]
dg.write_to_graphic_file('jpg')
我做了一个rails应用程序.我应该按如下方式实现has_many,belong_to关系Author和Location模型,并写下如下:
在模型中:
class Author < ActiveRecord::Base
belongs_to :location
end
class Location < ActiveRecord::Base
has_many :authors
accepts_nested_attributes_for :authors
end
Run Code Online (Sandbox Code Playgroud)
在location/new.html.erb中:
<%= form_for(@location) do |f| %>
<%= f.label :location_name %>
<%= f.text_field :location_name %>
<%= f.fields_for :authors do |a| %>
<%= a.label :name %>
<%= a.text_field :name %>
<% end %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
我的问题是,即使该位置可以有很多作者,它只为作者显示一个文本字段fields_for :authors,那么我如何根据用户的意愿为作者添加尽可能多的文本字段呢?
有人可以帮我吗?
几个月以来我一直在使用rails应用程序.现在我应该添加一个功能,显示欢迎信息的第一时间,当用户访问该网站的主页,而不是第二次,甚至用户重新加载相同的页面.
我怎样才能通过使用jQuery或Javascript实现这一目标?