小编Pav*_*bin的帖子

Rails Action Mailer:电子邮件中的图像

我正在尝试将图像粘贴到电子邮件中.问题是电子邮件内部没有图像

development.rb

  config.action_mailer.default_url_options = {
    :host => 'localhost:3000',
    :only_path => false
  }
  config.action_mailer.raise_delivery_errors = false
  config.action_mailer.asset_host = 'http://localhost:3000'
Run Code Online (Sandbox Code Playgroud)

查看文件:

<div class="image">
  <%= image_tag image_path('email-logo.png') %>
</div>
Run Code Online (Sandbox Code Playgroud)

我在哪里弄错了?请询问您是否需要更多信息.

ruby-on-rails actionmailer ruby-on-rails-4

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

rails,动作邮件不发送

我是Rails的初学者,我想在有人使用actionmailer注册后发送电子邮件.

我的日志说电子邮件正在发送,但gmail永远不会收到它

配置/初始化/为setup_mail.rb

ActionMailer::Base.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => 587,
  :domain               => "asciicasts.com",
  :user_name            => "asciicasts",
  :password             => "secret",
  :authentication       => "plain",
  :enable_starttls_auto => true
}
Run Code Online (Sandbox Code Playgroud)

邮寄/ user_mailer.rb

class UserMailer < ActionMailer::Base
  default :from => "eifion@asciicasts.com"

  def registration_confirmation(user)
    mail(:to => user.email, :subject => "Registered")
  end
end
Run Code Online (Sandbox Code Playgroud)

控制器/ users_controller.rb

...
def create
    @user = User.new(params[:user])
    if @user.save
      UserMailer.registration_confirmation(@user).deliver
      sign_in @user
      flash[:success] = "Welcome to the Sample App!"
      redirect_to @user
    else
      render 'new'
    end
  end
...
Run Code Online (Sandbox Code Playgroud)

谢谢!

email ruby-on-rails actionmailer

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

ReactJS:未捕获的ReferenceError:未定义require

我正在尝试在React JS中使用DRY.我试图在不同的文件中使用相同的HTML部分

部分:

var AdminMenu = React.createClass({
 getInitialState: function() {
   return {};
 },
 render: function() {
   return (
     <h1>Menu</h1>
   );
 }
});
Run Code Online (Sandbox Code Playgroud)

我在另一个文件中将它重新记录:

require('./scripts/adminMenu.js');

ReactDOM.render(
 <AdminMenu/>,
 document.getElementById('content')
);
Run Code Online (Sandbox Code Playgroud)

但我收到一个错误:

Uncaught ReferenceError: require is not defined
Run Code Online (Sandbox Code Playgroud)

这个脚本包含在html页面上,如: <script type="text/babel" src="scripts/admin.js"></script>

我正在使用webpack

javascript reactjs

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

ActiveAdmin:使用菜单标签和菜单父级

我想在菜单设置父自定义菜单标签active_admin一样

Parent label
  custom label 1
  custom label 2
  custom label 3
Run Code Online (Sandbox Code Playgroud)

问题是当我设置它时

ActiveAdmin.register Example do

  menu parent: 'Parent'
  menu label: 'Label 1'

end
Run Code Online (Sandbox Code Playgroud)

菜单父级不起作用.我该如何解决?

谢谢!

ruby-on-rails activeadmin ruby-on-rails-4

8
推荐指数
1
解决办法
3607
查看次数

Rails I18n-js:缺少翻译

我正在使用I18n-js gem来定位js文件.我已经在gem自述文件的帮助下安装了它并且它第一次工作.

问题是当我向我的translations.js文件中添加新的翻译时rake i18n:js:export,我的模板中没有显示rake任务翻译 - 仅限missing translation(开发和生产具有相同的情况),尽管translations.js内容包含所有新翻译.

的application.js

//= require i18n
//= require i18n/translations
Run Code Online (Sandbox Code Playgroud)

我错过了什么?如果您需要更多信息,请对其进行评论.谢谢

javascript ruby-on-rails rails-i18n ruby-on-rails-4

7
推荐指数
2
解决办法
2047
查看次数

Google OAuth:未配置访问权限

我正在尝试为我的应用设置Google Oauth身份验证.我创建了Google API项目并设置了重定向URI.当我使用链接进行身份验证时,我收到了回复:

{"errors"=>[{"domain"=>"usageLimits", "reason"=>"accessNotConfigured", "message"=>"Access Not Configured. Please use Google Developers Console to activate the API for your project."}], "code"=>403, "message"=>"Access Not Configured. Please use Google Developers Console to activate the API for your project."}: 
{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "accessNotConfigured",
    "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
   }
  ],
  "code": 403,
  "message": "Access Not Configured. Please use Google Developers Console to activate the API for …
Run Code Online (Sandbox Code Playgroud)

oauth google-api oauth-2.0 google-oauth

5
推荐指数
1
解决办法
1321
查看次数

Paranoia Gem - 加入已删除的项目

我正在使用 Paranoia gem,现在正在努力解决这个问题。我需要加入 has_many已删除的项目,但它只返回不删除。我的模型:

class Mailing < ActiveRecord::Base

  acts_as_paranoid

  has_many :mailing_fields
  has_many :fields, through: :mailing_fields

end

class MailingField < ActiveRecord::

  belongs_to :mailing
  belongs_to :field

end

class Field < ActiveRecord::Base

  has_many :mailing_fields, dependent: :destroy
  has_many :mailings, through: :mailing_fields

end
Run Code Online (Sandbox Code Playgroud)

我正在运行的查询应该返回mailings已删除的项目:

Field.joins(:mailings).where('mailings.id = ?', mailing_id)
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails ruby-paranoia

5
推荐指数
2
解决办法
2093
查看次数

苗条:漂亮又丑陋

文章,其中介绍了在轨性能的角度差的模板引擎,我觉得slim prettyslim ugly条款.你能解释一下这个区别吗?

ruby-on-rails slim-lang

4
推荐指数
1
解决办法
1198
查看次数

ActiveRecord :: Associations :: Collection to Array

我有一个集合:

<Vote id: nil, author_uid: 9326214>,
<Vote id: nil, author_uid: 5643421>,
<Vote id: nil, author_uid: 9753813>
Run Code Online (Sandbox Code Playgroud)

如何获取author_uid值的数组?

谢谢!

activerecord ruby-on-rails ruby-on-rails-4

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

红宝石:更改目录

当前目录是C:/Sites/todo,我想将其更改为C:/Sites/todo/app/assets. 问题是我需要指定目录,Dir.pwd("/app/assets")但出现错误,因为我应该写整个路径C:/Sites/todo/app/assets。如何使用/app/assets路径更改目录?

谢谢!

ruby

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

Rspec:让我们不行

我有一些Rspec测试,我在那里初始化变量let:

  describe 'methods' do

    let(:order)   { Order.new }
    let(:event_1) { FactoryGirl.create(:event) }
    let(:event_2) { FactoryGirl.create(:event) }

    context 'should checks if any event is paid' do
      order.events << event_1
      order.events << event_2
      order.events_paid?.should == true
    end

    context 'should write aasm state' do
      order.aasm_write_state('new')
      order.state.CanonicalName.should == 'new'
    end

  end
Run Code Online (Sandbox Code Playgroud)

但是我收到了一个错误 'method_missing': 'order' is not available on an example group (e.g. a 'describe' or 'context' block). It is only available from within individual examples (e.g. 'it' blocks) or from constructs that …

ruby rspec ruby-on-rails

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

Rails:自我加入

我正在尝试设计一个与自身有关系的模型

模型:

class Department < ActiveRecord::Base

  belongs_to :organization
  has_many   :positions
  has_many   :sub_departments, class: 'Department', foreign_key: 'parent_id'

end
Run Code Online (Sandbox Code Playgroud)

移民:

class CreateDepartments < ActiveRecord::Migration
  def change
    create_table :departments do |t|
      t.string     :name
      t.references :parent, index: true
      t.references :organization, index: true

      t.timestamps
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

当我打电话时,Department.first.sub_departments我得到一个错误:NoMethodError: undefined method 'relation_delegate_class' for "Department":String.我究竟做错了什么?

谢谢!

ruby ruby-on-rails ruby-on-rails-4

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

Ruby:从字符串中删除

我有URL http://localhost:3000/en/invest_offers?utf8=blahblahblah.我怎样才能获得?utf8=blahblahblah部分网址?谢谢!

ruby

0
推荐指数
1
解决办法
66
查看次数