我想在heroku上推送我的应用程序.我还在开发中.我使用了可确认模块的设计.
当我尝试使用heroku控制台添加用户时出现此错误:
Missing host to link to! Please provide :host parameter or set default_url_options[:host]
Run Code Online (Sandbox Code Playgroud)
在测试和开发环境中,我有以下行:
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) 这里我的应用程序控制器文件中的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"来运行它们,但我想知道是否有办法让它们使用该方法.
谢谢!
使用Devise,我想知道是否有办法删除特定的Flash消息?(成功签署).
我关心视图中的其他消息,所以它只适用于已登录和已签名的消息.我是否必须覆盖控制器或还有其他方法?
谢谢!
在heroku上推送我的应用程序后,我的应用程序崩溃了.在获得heroku最后版本之前我不想制作一个git rebase(如果我这样做,我会得到快进错误......)
我很高兴知道是否有命令这样做(我没有在heroku doc上找到它)
谢谢!
如何创建同一类的多个记录或多个工厂?
我试过了:
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
.
我想在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不提供它.
感谢您的回答!
我是黄瓜新手,我发现以下片段来测试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)
这里有以下代码:
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) 我正面临一个错误,试图配置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)
这是我的文件:
Feature: OmniAuth
Scenario: Test
Given I am signed in with facebook
Then I open the page
Run Code Online (Sandbox Code Playgroud)
Given /^I am signed in with facebook$/ do
visit "/auth/facebook"
end
Run Code Online (Sandbox Code Playgroud)
OmniAuth.config.test_mode …
Run Code Online (Sandbox Code Playgroud) 我正在使用设计作为我的身份验证解决方案,现在我正在考虑授权.在我的项目中,我(管理员)是唯一有权为其他人创建帐户的人.
我想知道是否有办法做到这一点,没有太多的黑客攻击.实际上,如果Devise已经登录,则Devise不允许用户访问注册页面.
感谢您的建议!
从ajax和jquery结合rails开始,我试图在我的用户索引页面底部创建一个"加载更多"链接.我的用户索引页面应显示10个第一个用户,然后单击它加载用户div底部的下10个用户的链接等.我使用Kaminari进行分页.
我从以下代码开始:
def index
@users = User.page(params[:page]).per(10)
end
Run Code Online (Sandbox Code Playgroud)
<div id="users">
<%= render :partial => @users %>
</div>
<%= link_to "Load more", "#", :class => "next" %>
Run Code Online (Sandbox Code Playgroud)
<div id="box">
<%= link_to full_name(user), user %>
</div>
Run Code Online (Sandbox Code Playgroud)
我发现这个片段(信用:这里)试图满足我的需要:
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中,如果是这样,我该怎么办)?
谢谢你的帮助