小编Haa*_*aaR的帖子

Rails3设计未定义的方法`confirmation_url'

我似乎为我的用户身份验证设置了Devise,并设置了:确认选项.

当我在浏览器中运行它时,一切似乎运行良好,我注册,转到我的rails s控制台中的服务器日志中显示的确认URL .

但是,当我尝试将以下内容添加到我的db/seed.rb时

User.create!(:username => 'haar', :email => 'haar@example.com', :password => 'password', :password_confirmation => 'password')
Run Code Online (Sandbox Code Playgroud)

并运行 rake db:setup --trace

我收到以下错误:

rake aborted!
undefined method `confirmation_url' for #<#<Class:0x1062f79a0>:0x1062f6618>
/Users/haar/Dropbox/Websites/TenOutOfTen/app/views/devise/mailer/confirmation_instructions.html.haml:4:in `_app_views_devise_mailer_confirmation_instructions_html_haml___1737567023_2199377480_0'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.8/lib/action_view/template.rb:135:in `send'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.8/lib/action_view/template.rb:135:in `render'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-3.0.8/lib/active_support/notifications.rb:54:in `instrument'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.8/lib/action_view/template.rb:127:in `render'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.8/lib/action_view/render/rendering.rb:59:in `_render_template'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-3.0.8/lib/active_support/notifications.rb:52:in `instrument'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-3.0.8/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-3.0.8/lib/active_support/notifications.rb:52:in `instrument'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.8/lib/action_view/render/rendering.rb:56:in `_render_template'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.8/lib/action_view/render/rendering.rb:26:in `render_without_haml'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/haml-3.1.3/lib/haml/helpers/action_view_mods.rb:13:in `render'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.8/lib/abstract_controller/rendering.rb:115:in `_render_template'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.8/lib/abstract_controller/rendering.rb:109:in `render_to_body'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.8/lib/abstract_controller/rendering.rb:102:in `render_to_string'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.8/lib/abstract_controller/rendering.rb:93:in `render'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/actionmailer-3.0.8/lib/action_mailer/deprecated_api.rb:111:in `render'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/actionmailer-3.0.8/lib/action_mailer/base.rb:735:in `collect_responses_and_parts_order'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/actionmailer-3.0.8/lib/action_mailer/base.rb:750:in `each'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/actionmailer-3.0.8/lib/action_mailer/base.rb:750:in `each_template'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/actionmailer-3.0.8/lib/action_mailer/base.rb:745:in `each'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/actionmailer-3.0.8/lib/action_mailer/base.rb:745:in `each_template'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/actionmailer-3.0.8/lib/action_mailer/base.rb:731:in `collect_responses_and_parts_order'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/actionmailer-3.0.8/lib/action_mailer/base.rb:673:in `mail'
/Users/haar/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.4.5/lib/devise/mailers/helpers.rb:21:in …
Run Code Online (Sandbox Code Playgroud)

ruby rake ruby-on-rails devise

28
推荐指数
2
解决办法
1万
查看次数

ZSH/Shell变量赋值/用法

我使用ZSH作为我的终端shell,虽然我已经编写了几个函数来自动执行特定任务,但我从来没有尝试过任何需要我目前所需功能的东西.

我最近使用Jekyll重新编写了一个博客,我希望自动生成博客文章,最后使用像scp这样的东西将新生成的文件上传到我的服务器.

我对ZSH中的变量绑定/用法略感困惑; 例如:

DATE= date +'20%y-%m-%d'
echo $DATE
Run Code Online (Sandbox Code Playgroud)

按照我的预期正确输出2011-08-23.

但是当我尝试:

DATE= date +'20%y-%m-%d'
FILE= "~/path/to/_posts/$DATE-$1.markdown"
echo $FILE
Run Code Online (Sandbox Code Playgroud)

它输出:

2011-08-23
blog.sh: line 4: ~/path/to/_posts/-.markdown: No such file or directory
Run Code Online (Sandbox Code Playgroud)

当运行我想要的博客标题时(忽略字符串需要被操纵以使其更友好的URL并且路径路径/不存在的事实)

即博客"博客标题",输出:

2011-08-23
blog.sh: line 4: ~/path/to/_posts/-blog title.markdown: No such file or directory
Run Code Online (Sandbox Code Playgroud)

为什么在打印$ FILE的调用之上打印$ DATE而不是$ FILE中包含的字符串?

unix macos bash shell zsh

9
推荐指数
2
解决办法
3万
查看次数

表单重新显示后,CarrierWave不保存上传

我有一个rails应用程序,最初使用Paperclip进行文件上传,但是,当我看到CarrierWave显然在表格重新显示时有一个"持久上传"类型功能时,我决定尝试一下.

在我看来,我有以下几点:

= f.input :attachment
= f.hidden_field :attachment_cache
Run Code Online (Sandbox Code Playgroud)

如果表单验证失败并重新显示,则正确缓存文件,但是当我更正验证错误并重新提交时,不会处理附件.

Started POST "/section/model" for 127.0.0.1 at 2012-03-20 08:51:56 +0000
  Processing by Client::WishesController#create as HTML
  Parameters: {"utf8"=>"?", "authenticity_token"=>"zkdPQBsAnsNzx555rkwZ5+clfnLaXg+NtL+GdFei188=", "model"=>{"title"=>"Sample", "content"=>"Sample content", "contact_name"=>"Mr Sample", "contact_email"=>"sample@example.com", "attachment_cache"=>"20120320-0851-42559-1644/SampleAttachment.pdf"}, "commit"=>"Create Wish"}
  Client Load (0.3ms)  SELECT `clients`.* FROM `clients` WHERE `clients`.`id` = 1 LIMIT 1
   (0.2ms)  BEGIN
  SQL (0.4ms)  INSERT INTO `models` (`attachment`, `client_id`, `contact_email`, `contact_name`, `content`, `created_at`, `status`, `title`, `updated_at`, `upload_content_type`, `upload_file_name`, `upload_file_size`, `upload_updated_at`) VALUES (NULL, 1, 'sample@example.com', 'Mr Sample', 'Sample content', '2012-03-20 08:51:56', 'Unresolved', 'Sample', …
Run Code Online (Sandbox Code Playgroud)

ruby upload ruby-on-rails carrierwave

7
推荐指数
1
解决办法
2820
查看次数

Rails Mailer 自定义动态内容

我最近加入了一个项目,每个客户都有自己的自定义 HTML 内容,用于发送给其客户的电子邮件。

它通过将内容插入带有自定义标签的字符串中来实现此目的,然后通过在邮件程序中设置 body 属性来发送,如下所示:

mail(:from         => from_email,
     :reply_to     => from_email,
     :to           => to_email,
     :subject      => subject,
     :body         => (html_text.empty?) ? plain_text : html_text,
     :content_type => (html_text.empty?) ? 'text/plain' : 'text/html',
    )
Run Code Online (Sandbox Code Playgroud)

要添加的一项功能是包含内嵌图像;但是 - 通过手动将 content_type 设置为“text/plain”或“text/html”,电子邮件无法正确呈现,并且图像也无法正确附加(整个电子邮件的 content_type 似乎很混乱): content_type 电子邮件混乱

删除此显式 content_type 后,图像会正确附加,但不会显示内联图像(使用附加图像将占位符替换为 image_tag),因为内容似乎不会被解释为 HTML,例如电子邮件的内容是:

Dolor eligendi doloremque et.
<img alt="Signature Image" src="cid:5225b25b53818_b4213fc5ce0349d0975f@localhost.mail" />
Run Code Online (Sandbox Code Playgroud)

如何让电子邮件将内容正确解释为 HTML,而不弄乱内嵌图像内容类型?

html email ruby-on-rails dynamic actionmailer

2
推荐指数
1
解决办法
2363
查看次数

标签 统计

ruby-on-rails ×3

ruby ×2

actionmailer ×1

bash ×1

carrierwave ×1

devise ×1

dynamic ×1

email ×1

html ×1

macos ×1

rake ×1

shell ×1

unix ×1

upload ×1

zsh ×1