我spork --bootstrap在命令行上运行,我得到了错误-bash: spork: command not found
我知道我安装了spork因为当我跑步时bundle show spork我得到了/Library/Ruby/Gems/1.8/gems/spork-0.9.0.rc3
我甚至尝试将目录更改为Spork所在的位置并运行spork --bootstrap但我收到相同的错误消息.
我该怎么办?
我刚刚将我的RoR应用程序部署到Heroku,该应用程序可以在我的本地端口上运行,但是当我访问Heroku地址时,我得到:
App崩溃此应用程序暂时脱机.如果您是此应用的管理员,请检查您的heroku日志以获取回溯.
这可能是我在日志中发现的错误:
2011-02-25T17:08:25-08:00 heroku[router]: Error H10 (App crashed) -> GET afternoon-warrior-452.heroku.com/ dyno=none queue=0 wait=0ms service=0ms bytes=0
2011-02-25T17:08:25-08:00 heroku[router]: Error H10 (App crashed) -> GET afternoon-warrior-452.heroku.com/favicon.ico dyno=none queue=0 wait=0ms service=0ms bytes=0
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
所以我使用了Xcode和所有.现在,每当我打开文本文件时,它都会自动打开Xcode.我该如何撤消这个?
所以我正在实现一个上/下投票机制,我正在生成一个模型.到目前为止,我知道视频(将被投票的内容)有一个vote_count,而vote_count属于视频.但是,我还想在我的vote_count数据库中跟踪投票的用户.这是否意味着vote_count有很多用户,而用户属于vote_count?
我有一个has_one配置文件的用户模型,该配置文件属于该用户.该配置文件有一个type用于单表继承的列,可以是"artist"或"listener".我希望用户在新用户视图中注册时设置此项.因此我有以下形式的代码:
<%= f.fields_for :profile do |t| %>
<div class ="field">
<%= t.label :type, "Are you an artist or listener?" %><br />
<%= t.radio_button :type "artist" %>
<%= t.radio_button :type "listener" %>
</div>
<% end %>
Run Code Online (Sandbox Code Playgroud)
这在我的用户模型中:
accepts_nested_attributes_for :profile
Run Code Online (Sandbox Code Playgroud)
但我得到他的错误:
ArgumentError in Videos#index
Showing /rubyprograms/dreamstill/app/views/videos/_video.html.erb where line #3 raised:
No association found for name `profile'. Has it been defined yet?
Run Code Online (Sandbox Code Playgroud)
为什么会这样,我该如何解决?
另外我很困惑为什么错误会在我的视频部分中引出第3行,这根本就没有提到profile......
更新:
这是整个表格:
<%= form_for(@user) do |f| %>
<% if @user.errors.any? %>
<div id="errorExplanation">
<h2><%= pluralize(@user.errors.count, …Run Code Online (Sandbox Code Playgroud) 这是图像:
<%= image_tag comment.user.profile.photo.url(:tiny) %>
Run Code Online (Sandbox Code Playgroud)
这是链接路径:
comment.user.profile
Run Code Online (Sandbox Code Playgroud)
现在我该如何将这两者结合起来?
当我验证字符串的格式时,我会这样做:
validates :link, :uniqueness => true,
:format => { :with => (regular expression) }
Run Code Online (Sandbox Code Playgroud)
我希望该链接可以是此正则表达式的YouTube视频:
/^http:\/\/www\.youtube\.com\/watch\?v=([a-zA-Z0-9_-]*)/
或vimeo视频:
/^http:\/\/www\.vimeo\.com\/(\d+)/
如何在我的模型中设置此验证?
我有这个验证:
validates :url, :uniqueness => true,
:format => { :with => /^(http:\/\/)?(www\.)?youtube\.com\/watch\?v=([a-zA-Z0-9_-]*)/}
Run Code Online (Sandbox Code Playgroud)
我想让url匹配上面的正则表达式或另一个正则表达式.如何添加第二个正则表达式?
当我点击设计发送的确认电子邮件中的链接时,它似乎转到我的应用程序无法识别的路径.
网址看起来像这样:
http://glowing-flower-855.heroku.com/users/confirmation?confirmation_token=lIUuOINyxfTW3TBPPI
看起来是正确的,但它似乎转到我的500.html文件.
它与我的用户模型中的代码有关,它覆盖了Devise的confirm!方法:
def confirm!
UserMailer.welcome_message(self).deliver
super
end
Run Code Online (Sandbox Code Playgroud)
根据我的日志,这是错误:
2011-06-10T03:48:11+00:00 app[web.1]: ArgumentError (A sender (Return-Path, Sender or From) required to send a message):
2011-06-10T03:48:11+00:00 app[web.1]: app/models/user.rb:52:in `confirm!'
Run Code Online (Sandbox Code Playgroud)
这指向这一行: UserMailer.welcome_message(self).deliver
这是我的用户邮件程序类:
class UserMailer < ActionMailer::Base
def welcome_message(user)
@user = user
mail(:to => user.email, :subject => "Welcome to DreamStill")
end
end
Run Code Online (Sandbox Code Playgroud)