我正在努力完成一个项目.我正在使用用户模型.当我注册一切似乎没问题.但是当我尝试签署同一个成员时,我收到了这个错误.
我们很抱歉,但有些不对劲. heroku日志文件显示错误为:
BCrypt::Errors::InvalidHash (invalid hash):
app/controllers/sessions_controller.rb:8:in `create'
Run Code Online (Sandbox Code Playgroud)
my *sessions_controller*是:
class SessionsController < ApplicationController
def new
end
def create
user = User.find_by_email(params[:session][:email])
if user && user.authenticate(params[:session][:password])
sign_in user
redirect_to user
else
flash.now[:error] = 'Invalid email/password combination'
render 'new'
end
end
def destroy
sign_out
redirect_to root_path
end
end
Run Code Online (Sandbox Code Playgroud)
和用户模型是:
class User < ActiveRecord::Base
attr_accessible :email, :name, :nickname,:password, :password_confirmation
has_secure_password
before_save { |user| user.email = email.downcase }
before_save { |user| user.nickname = nickname.downcase }
before_save :create_remember_token
....validations......
private …Run Code Online (Sandbox Code Playgroud) 我正在尝试学习如何使用phpunit和laravel进行测试.使用phpunit命令启动测试时,我收到警告:
There was 1 failure:
1) Warning
No tests found in class "PostsTest".
FAILURES!
Tests: 2, Assertions: 1, Failures:
Run Code Online (Sandbox Code Playgroud)
我的测试类名和文件名匹配.我已经阅读了有关不匹配名称的其他问题.我的文件名是PostsTest.php和我的测试文件:
class PostsTest extends ApiTester {
public function it_fetches_posts()
{
$this->times(5)->makePost();
$this->getJson('api/v1/posts');
$this->assertResponseOk();
}
private function makePost($postFields=[])
{
$post = array_merge([
'title' => $this->fake->sentence,
'content' => $this->fake->paragragraph
], $postFields);
while($this->times --)Post::create($post);
}
}
Run Code Online (Sandbox Code Playgroud)
如果有必要,我的ApiTester:
use Faker\Factory as Faker;
class ApiTester extends TestCase {
protected $fake;
protected $times = 1;
function __construct($faker)
{
$this->fake = Faker::create();
}
} …Run Code Online (Sandbox Code Playgroud) 我正在使用计算机上的Lamp服务器.我开始使用Laravel php框架.在我的.htaccess中,如果我使用Options + FollowSymLinks,我会得到500错误.如果我注释掉,我必须在我的所有地址中使用index.php ..example:
/~ytsejam/blog/public/index.php/login
我使用Arch Linux.有办法解决吗?
编辑:我通过使用虚拟主机解决了这个问题.并从laravel文件夹中的application/config/application.php中删除index.php.
我正在尝试构建一个角度+ laravel休息应用程序.我可以获得我的数据库的视图.当我尝试添加新项目时.我500 error告诉我错配csrf令牌.我的表单布局是:
<form class="form-horizontal" ng-submit="addItem()">
<input type="text" ng-model="itemEntry" placeholder="Type and hit Enter to add item">
</form>
Run Code Online (Sandbox Code Playgroud)
这是我尝试将项添加到数据库的方式:
$scope.addItem = function(CSRF_TOKEN) {
$http.post('/shop', { text: $scope.itemEntry, csrf_token: CSRF_TOKEN} ).success(function(data, status) {
if(data) {
var last = _.last($scope.items);
_token = CSRF_TOKEN;
$scope.items.push({text: $scope.itemEntry, bought: false, id: (last.id + 1) });
$scope.itemEntry = '';
console.log($scope.items);
} else {
console.log('There was a problem. Status: ' + status + '; Data: ' + data);
}
}).error(function(data, status) {
console.log('status: ' + status); …Run Code Online (Sandbox Code Playgroud) 我试图在我的arch linux灯服务器中使用fuelcms.但我不能让htaccess工作.我的主文件夹是ytsejam/fuel_cms/..
这是我的.htaccess文件:
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
<Files .*>
Order deny, allow
Deny From All
</Files>
# Allow asset folders through
RewriteRule ^(fuel/modules/(.+)?/assets/(.+)) - [L]
# Protect application and system files from being viewed
RewriteRule ^(fuel/install/.+|fuel/crons/.+|fuel/data_backup/.+|fuel/codeigniter/.+|fuel/modules/.+|fuel/application/.+|\.git.+) - [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [L]
</IfModule>
Options -Indexes
Run Code Online (Sandbox Code Playgroud)
/ var/log/httpd/error_logs显示了这一点
/home/ytsejam/public_html/fuel_cms/.htaccess: order takes one argument, 'allow,deny', 'deny,allow', or 'mutual-failure'
Run Code Online (Sandbox Code Playgroud)
谁能帮我 ?
我是codeigniter的新手.我正在尝试使用mysql数据库编写应用程序.在我的网站中,我想使用菜单:
+Homepage
+About
+Services
+Education services
+neurofeedback
+biofeedback
Run Code Online (Sandbox Code Playgroud)
我需要一些信息来理解.我使用页面控制器作为主页面控制器:
<?php
class Pages extends CI_Controller {
public function view($page = 'home')
{$this->load->view('templates/header', $data);
$this->load->view('pages/'.$page, $data);
$this->load->view('templates/footer', $data);
Run Code Online (Sandbox Code Playgroud)
我的问题是:
1)菜单控制器必须在页面控制器内编码还是单独编码?
2)如何从数据库中创建菜单控制器?
3)如何与菜单ID和页面ID建立关系?
我做了很多研究,但我需要更多的了解.
谢谢您的帮助.
编辑:我已经按照你的说法使用了MY_Controller.
这是我的页面控制器:
class Home extends MY_Controller {
function __construct() {
parent::__construct();
}
public function view($page = 'home')
{
$this->load->helper('text');
$data['records']= $this->services_model->getAll();
if ( ! file_exists('application/views/pages/'.$page.'.php'))
{
// Whoops, we don't have a page for that!
show_404();
}
$data['title'] = ucfirst($page); // Capitalize the first letter
$this->load->view('pages/'.$page, $data);
} …Run Code Online (Sandbox Code Playgroud) 我正在学习务实的书架课程.我试着做一个会话计数器.我的商店控制器是
class StoreController < ApplicationController
def increment_counter
if session[:counter].nil?
session[:counter] = 0
end
session[:counter] += 1
end
def index
@count = increment_counter
@products = Product.all
@cart = current_cart
@time = Time.now
@shown_message = "You've been here #{@count} times" if increment_counter >5
end
end
Run Code Online (Sandbox Code Playgroud)
我的观点是
<h5><p><%= @shown_message %></p></h5>..
Run Code Online (Sandbox Code Playgroud)
直到5次它不起作用.但在它开始算作5,7,9,11之后..我的会话有什么问题[:counter]?