这个问题可能大家遇到的不多. 分析原因 问题出在 config/web.php 这个配置文件里面 'components' => [ ..... 'user' => [ 'identityClass' => 'app\models\User', 'enableAutoLogin' => true, ], ], 在这个文件里我们配置了user 所以默认他会使用我们配置过的user 但是我们自己建的model里面并没有声明它想要的 find() 方法 追踪代码可以发现经常用到这样一段代…
如果你执行 php artisan db:seed 发生如下错误 说是模型中不存在 静态方法 setContainer()方法,那么你应该检查下你的DatabaseSeeder.php 文件 中的 run()方法,看看你是不是call错了种子类文件…
因为要写一个系统,所以又重新下载了thinkphp,然后安装了一下.回忆起这个问题很容易让新手朋友费解.会出现如下报错:Call to undefined method app\index\controller\Index::fetch() 其实就是没找到fetch属性,其实默认是有这个属性的.只是你没有使用罢了. 需要先使用Controller然后继承. 如下所示: <?php namespace app\index\controller; use think\Controller; clas…
最近在使用Thinkphp6框架的时候,想做一个初始化来验证登录状态. 当没有Session::get(‘adminUid’)的时候就应该跳转到admin\adminLogin的方法中,和以前Tp5的框架一样,使用$this->error()的方法 结果就报错: Call to undefined method app\index\controller\Admin::error() 昨天的时候就觉得很苦恼很奇怪,明明之前使用的时候是完全没有问题的,现在怎么就不行了. 但现在使用Tp6框架的人还是…
Started GET "/mygroup/myproject/tree/master/MyDirectory" for 127.0.0.1 at 2014-10-22 22:42:42 +0200 Processing by Projects::TreeController#show as HTML Parameters: {"project_id"=>"mygroup/myproject", "id"=>&qu…
今天遇到了一个问题,在routes/web.php中配置了路由,但始终无法访问该路由,一直报404. Route::resource('gift_packs', 'GiftPacksController', ['only' => ['index', 'show', 'create', 'store', 'update', 'edit', 'destroy']]); Route::get('gift_packs/test', 'GiftPacksController@test')->name('…
在render中,即使有:action,那么也仅仅是取对应的view中的模板(html.erb)而已,所以这里即使浏览器中的url是/orders/xcreate,但是显示的界面是/app/views/orders/xshow的代码 def xcreate flash.now[:notice] = "bb" @order = Order.new(params[:order]) if @order.save flash[:notice] = "yes" render(…
在进行Rspec 编译测试: bundle exec rspec spec/requests/static_pages_spec.rb 提示错误: FF Failures: 1) Static pages Home page should have the content 'Sample App' Failure/Error: visit '/static_pages/home' NoMethodError: undefined method `visit' for #<RSpec::Core:…
首先搞清楚这句话,在 Ruby 中,方法分为 public.private 和 protected 三种,仅仅有 public 方法才干作为控制器的动作. 我的出错的代码例如以下: controlle class ArticlesController < ApplicationController def new end def create params.permit! @article = Article.new(params[:article]) @article.save redirec…
今天做项目时往Gemfile里加了各gem, 然后bundle update了一下, 然后悲剧了,出现了undefined method `environment' for nil:NilClass when importing Bootstrap into rails错误, 各种不理解. 然后查了一下, 找到了解决方案: https://stackoverflow.com/questions/22392862/undefined-method-environment-for-nilnilcla…