小编ben*_*itr的帖子

Heroku/devise - 缺少链接的主机!请提供:host参数或设置default_url_options [:host]

我想在heroku上推送我的应用程序.我还在开发中.我使用了可确认模块的设计.

当我尝试使用heroku控制台添加用户时出现此错误:

Missing host to link to! Please provide :host parameter or set default_url_options[:host]
Run Code Online (Sandbox Code Playgroud)

在测试和开发环境中,我有以下行:

environment/development.rb和environments/test.rb

config.action_mailer.default_url_options = { :host => 'localhost:3000' }
Run Code Online (Sandbox Code Playgroud)

我没有在生产环境中设置一些东西.

我试过推

config.action_mailer.default_url_options = { :host => 'mywebsitename.com' }
config.action_mailer.default_url_options = { :host => 'heroku.mywebsitename.com' }
Run Code Online (Sandbox Code Playgroud)

但它也不起作用..

我在网上看到它可能与ActionMailer有关,但我不知道我要配置什么.非常感谢你的想法!

编辑:

嗨,

为了在我推动heroku时不让我的应用程序崩溃,我把它放在我的env/test.rb和我的env/dev.rb(不在env.rb中,我认为这是因为它是rails 3应用程序)

config.action_mailer.default_url_options = { :host => 'yourapp.heroku.com' }
Run Code Online (Sandbox Code Playgroud)

但是当我尝试在heroku控制台中创建用户时:

User.create(:username => "test", :email => "test@test.com", :password => "test1234", :password_confirmation => "test1234", :confirmed_at => "2010-11-03 14:11:15.520128")
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误:

ActionView::Template::Error: Missing host to link to! Please provide :host parameter …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails actionmailer heroku devise

176
推荐指数
6
解决办法
9万
查看次数

Rails/Rspec使用http基本身份验证进行测试

这里我的应用程序控制器文件中的http基本身份验证(application_controller.rb)

before_filter :authenticate

protected

def authenticate
  authenticate_or_request_with_http_basic do |username, password|
    username == "username" && password == "password"  
  end
end
Run Code Online (Sandbox Code Playgroud)

和我的家庭控制器的索引操作的默认测试(spec/controllers/home_controller_spec.rb)

require 'spec_helper'

describe HomeController do

describe "GET 'index'" do
  it "should be successful" do
    get 'index'
    response.should be_success
  end
end
Run Code Online (Sandbox Code Playgroud)

由于身份验证方法,测试无法运行.我可以评论"before_filter:authenticate"来运行它们,但我想知道是否有办法让它们使用该方法.

谢谢!

rspec ruby-on-rails http-authentication

66
推荐指数
4
解决办法
3万
查看次数

设计/ Rails - 如何删除特定的Flash消息?(成功签署)

使用Devise,我想知道是否有办法删除特定的Flash消息?(成功签署).

我关心视图中的其他消息,所以它只适用于已登录和已签名的消息.我是否必须覆盖控制器或还有其他方法?

谢谢!

ruby-on-rails devise

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

Heroku - 如何撤消对heroku的推送?

在heroku上推送我的应用程序后,我的应用程序崩溃了.在获得heroku最后版本之前我不想制作一个git rebase(如果我这样做,我会得到快进错误......)

我很高兴知道是否有命令这样做(我没有在heroku doc上找到它)

谢谢!

heroku

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

如何在Factory Girl中创建/构建工厂的多个实例?

如何创建同一类的多个记录或多个工厂?

我试过了:

Factory.define :user do |user|
  user.email "someuser@somesite.com"
  user.password "somepassword"

  user.email "another_existing_user@somesite.com"
  user.password "somepassword"
end
Run Code Online (Sandbox Code Playgroud)

Factory.define :user do |user|
  user.email "someuser@somesite.com"
  user.password "somepassword"
end

Factory.define :user do |user|
  user.email "another_existing_user@somesite.com"
  user.password "somepassword"
end
Run Code Online (Sandbox Code Playgroud)

但它不起作用 - Attribute already defined: email.

ruby-on-rails factory-bot

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

Rails/Devise - 使用link_to自定义flash消息(devise.en.yml)

我想在devise.en.yml文件中自定义devise提供的以下flash msg:

devise:
   failure:
      unconfirmed: 'You have to confirm your account before continuing.'
Run Code Online (Sandbox Code Playgroud)

使用ruby代码以获取new_user_confirmation_path的链接.

换句话说,我希望我的flash消息显示如下:

'You have to confirm your account before continuing. Didn't receive confirmation instructions?'
Run Code Online (Sandbox Code Playgroud)

哪里'没有收到确认指示?' 是new_user_confirmation_path的链接.

我想知道我是否可以在不编辑用户控制器的情况下执行此操作,因为默认情况下Devise不提供它.

感谢您的回答!

ruby-on-rails devise

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

设计/黄瓜 - 添加确认用户的步骤

我是黄瓜新手,我发现以下片段来测试Devise登录功能.然而,似乎又失去了一步,我没有找到任何解决方案:

Given /^that a confirmed user exists$/ do
  pending # express the regexp above with the code you wish you had
end
Run Code Online (Sandbox Code Playgroud)

这里有以下代码:

功能/认证/ session.feature

Feature: Session handling
  In order to use the site
  As a registered user
  I need to be able to login and logout

Background: 
  Given that a confirmed user exists

Scenario Outline: Logging in
  Given I am on the login page
  When I fill in "user_email" with "<email>"
  And I fill in "user_password" with "<password>"
  And …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails cucumber devise factory-bot

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

Rails/Cucumber - 托管错误测试omniauth(提供者:facebook) - (URI :: InvalidComponentError)

我正面临一个错误,试图配置omniauth用于黄瓜的集成测试目的(我通过Devise设置Omniauth,因为wiki提供)

请看下面:

Scenario: Test                       # features/omniauth.feature:3
  Given I am signed in with facebook # features/step_definitions/omniauth_steps.rb:1
    bad component(expected host component): http://www.example.com (URI::InvalidComponentError)
    /Users/benoit/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/uri/generic.rb:395:in `check_host'
    /Users/benoit/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/uri/generic.rb:409:in `host='
    ./features/step_definitions/omniauth_steps.rb:2:in `/^I am signed in with facebook$/'
    features/omniauth.feature:4:in `Given I am signed in with facebook'
  Then I open the page               # features/step_definitions/debug_steps.rb:5
Run Code Online (Sandbox Code Playgroud)

这是我的文件:

omn​​iauth.feature

Feature: OmniAuth

  Scenario: Test
    Given I am signed in with facebook
    Then I open the page
Run Code Online (Sandbox Code Playgroud)

omn​​iauth_steps.rb

Given /^I am signed in with facebook$/ do
  visit "/auth/facebook"
end
Run Code Online (Sandbox Code Playgroud)

支持/ env.rb

OmniAuth.config.test_mode …
Run Code Online (Sandbox Code Playgroud)

facebook ruby-on-rails cucumber devise omniauth

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

设计/ Rails - 如何只允许管理员为其他人创建帐户?

我正在使用设计作为我的身份验证解决方案,现在我正在考虑授权.在我的项目中,我(管理员)是唯一有权为其他人创建帐户的人.

我想知道是否有办法做到这一点,没有太多的黑客攻击.实际上,如果Devise已经登录,则Devise不允许用户访问注册页面.

感谢您的建议!

authorization ruby-on-rails devise

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

Rails 3/Kaminari/JQuery - 加载更多按钮:显示结果的问题(它加载整个页面布局而不仅仅是局部布局)

从ajax和jquery结合rails开始,我试图在我的用户索引页面底部创建一个"加载更多"链接.我的用户索引页面应显示10个第一个用户,然后单击它加载用户div底部的下10个用户的链接等.我使用Kaminari进行分页.

我从以下代码开始:

User_controller.rb

def index
  @users = User.page(params[:page]).per(10)
end
Run Code Online (Sandbox Code Playgroud)

用户/ index.html.erb

<div id="users">
  <%= render :partial => @users %>
</div>
<%= link_to "Load more", "#", :class => "next" %>
Run Code Online (Sandbox Code Playgroud)

_user.html.erb

<div id="box">
  <%= link_to full_name(user), user %>
</div>
Run Code Online (Sandbox Code Playgroud)

的application.js

我发现这个片段(信用:这里)试图满足我的需要:

function loadMore(pageNo) {
  var url = '/users?page=';
  $.get(url + pageNo, function(response) {
    $("#users").append(response);
  });
}

$(document).ready(function() {
  var currPage = 1;
  $("a.next").click(function() {
    loadMore(++currPage);
  });
});
Run Code Online (Sandbox Code Playgroud)

我工作得很完美,除了它加载所有页面布局与下一个结果不仅我的_user部分中的框div我 如何管理这个?我是否必须创建一个index.js.erb(类似于:page.insert_html:bottom,:users,:partial => @users但是在jquery中,如果是这样,我该怎么办)?

谢谢你的帮助

jquery jrails ruby-on-rails-3 kaminari

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