草庐IT

php - 拉维尔 : Method [show] does not exist

coder 2023-06-15 原文

当尝试访问这个 URL 'users/login' 时我得到了那个错误,这是我的代码:

查看 users/login.blade.php :

<head>Sign in : </head>
<body>
{{ HTML::ul($errors->all()) }}
<?php echo Form::open(array('url' => 'users')); 

echo '<div class="form-group">';
    echo Form::label('username', 'User Name');
    echo Form::text('ausername', null, array('class' => 'form-control'));
echo '</div>';

echo '<div class="form-group">';
    echo Form::label('Password', 'Password');
    echo Form::password('apassword', null, array('class' => 'form-control'));
echo '</div>';

echo Form::submit('Sign in', array('class' => 'btn btn-primary'));

echo Form::close();
?>
</body>

Controller Usercontroller.php

<?php

class UserController extends BaseController {


    public function index()
    {
        $users = User::all();
        return View::make('users.index')
            ->with('users', $users);
    }


    public function create()
    {
        return View::make('users.create');
    }


    public function store()
    {
        $rules = array(
            'username'   => 'required|alpha_dash',
            'password'   => 'required|confirmed',
            'name'       => 'required|regex:/^[a-zA-Z][a-zA-Z ]*$/',
            'email'      => 'required|email|unique:users',
            'country'    => 'required'
        );
        $validator = Validator::make(Input::all(), $rules);

        if ($validator->fails()) {
            return Redirect::to('users/create')
                ->withErrors($validator)
                ->withInput(Input::except('password'));
        } else {
            $user = new User;
            $user->username = Input::get('username');
            $user->password = Hash::make(Input::get('password'));
            $user->name = Input::get('name');
            $user->email = Input::get('email');
            $user->country = Input::get('country');
            $user->save();
            // redirect
            Session::flash('message', 'Successfully created user!');
            return Redirect::to('users');
            }
    }


    public function login()
    {
        $reflector = new ReflectionClass("UserController");
        $fn = $reflector->getFileName();
        dd($fn);
        return View::make('users.login');   
    }


    public function authen()
    {
        if (Auth::attempt(array('username' => Input::get('ausername'), 'password' => Input::get('apassword'))))
        {
            return Redirect::intended('users');
        }   
    }


}

和我的 routes.php

<?php
Route::resource('users','UserController');
Route::get('users/login', 'UserController@login');
Route::get('/', function()
{
    return View::make('hello');
});

是不是路由问题,谢谢帮助

最佳答案

我遇到过和你一样的问题。问题以重新排列资源代码结束,即

Route::get('masterprices/data', 'MasterPriceController@data');
Route::get( 'masterprices/upload', 'MasterPriceController@upload');
Route::post('masterprices/upload', 'MasterPriceController@do_upload');
Route::get('masterprices/{masterprices}/multipledelete', 'MasterPriceController@multipledelete');
Route::resource('masterprices', 'MasterPriceController');

它检查其他可能的处理程序,如果没有,它将到达最后一行,这是处理索引页面的资源。

关于php - 拉维尔 : Method [show] does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22943570/

有关php - 拉维尔 : Method [show] does not exist的更多相关文章

  1. ruby - 难道Lua没有和Ruby的method_missing相媲美的东西吗? - 2

    我好像记得Lua有类似Ruby的method_missing的东西。还是我记错了? 最佳答案 表的metatable的__index和__newindex可以用于与Ruby的method_missing相同的效果。 关于ruby-难道Lua没有和Ruby的method_missing相媲美的东西吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/7732154/

  2. ruby-on-rails - Rails 中的 NoMethodError::MailersController#preview undefined method `activation_token=' for nil:NilClass - 2

    似乎无法为此找到有效的答案。我正在阅读Rails教程的第10章第10.1.2节,但似乎无法使邮件程序预览正常工作。我发现处理错误的所有答案都与教程的不同部分相关,我假设我犯的错误正盯着我的脸。我已经完成并将教程中的代码复制/粘贴到相关文件中,但到目前为止,我还看不出我输入的内容与教程中的内容有什么区别。到目前为止,建议是在函数定义中添加或删除参数user,但这并没有解决问题。触发错误的url是http://localhost:3000/rails/mailers/user_mailer/account_activation.http://localhost:3000/rails/mai

  3. ruby - 怎么来的(a_method || :other) returns :other only when assigning to a var called a_method? - 2

    给定以下方法:defsome_method:valueend以下语句按我的预期工作:some_method||:other#=>:valuex=some_method||:other#=>:value但是下面语句的行为让我感到困惑:some_method=some_method||:other#=>:other它按预期创建了一个名为some_method的局部变量,随后对some_method的调用返回该局部变量的值。但为什么它分配:other而不是:value呢?我知道这可能不是一件明智的事情,并且可以看出它可能有多么模棱两可,但我认为应该在考虑作业之前评估作业的右侧...我已经在R

  4. ruby - 使用 rbenv 和 ruby​​-build 构建 ruby​​ 失败,出现 undefined symbol : SSLv2_method - 2

    我正在尝试在配备ARMv7处理器的SynologyDS215j上安装ruby​​2.2.4或2.3.0。我用了optware-ng安装gcc、make、openssl、openssl-dev和zlib。我根据README中的说明安装了rbenv(版本1.0.0-19-g29b4da7)和ruby​​-build插件。.这些是随optware-ng安装的软件包及其版本binutils-2.25.1-1gcc-5.3.0-6gconv-modules-2.21-3glibc-opt-2.21-4libc-dev-2.21-1libgmp-6.0.0a-1libmpc-1.0.2-1libm

  5. ruby - "undefined method"用于 rails 模型 - 2

    我正在使用带有Rails的Devise,我想添加一个方法“getAllComments”,所以我这样写:classUser在我的Controller中:defdashboard@user=current_user@comments=@user.getAllComments();end当我访问我的url时,我得到了undefinedmethod`getAllComments'for#我做错了什么?谢谢 最佳答案 因为getAllComments是一个类方法,而您正试图将其作为实例方法访问。您要么需要访问它:User.getAllCom

  6. ruby - 从另一个私有(private)方法中使用 self.xxx() 调用私有(private)方法 xxx,导致错误 "private method ` xxx' called” - 2

    我正在尝试获得良好的Ruby编码风格。为防止意外调用具有相同名称的局部变量,我总是在适当的地方使用self.。但是现在我偶然发现了这个:classMyClass上面的代码导致错误privatemethodsanitize_namecalled但是当删除self.并仅使用sanitize_name时,它会起作用。这是为什么? 最佳答案 发生这种情况是因为无法使用显式接收器调用私有(private)方法,并且说self.sanitize_name是显式指定应该接收sanitize_name的对象(self),而不是依赖于隐式接收器(也是

  7. ruby 代码 : why put colon in front of variable name (inside initialize method) - 2

    我遇到了一些Ruby代码,我试图理解为什么变量在initialize方法声明中的名称末尾有冒号。冒号有什么原因吗?attr_reader:var1,:var2definitialize(var1:,var2:)@var1=var1@var2=var2end 最佳答案 那些是关键字参数。您可以按名称而非位置使用它们。例如ThatClass.new(var1:42,var2:"foo")或ThatClass.new(var2:"foo",var1:42)Anarticleaboutkeywordargumentsbythoughtbot

  8. ruby-on-rails - 如何找出拦截 'method_missing' 的内容 - 2

    使用Ruby1.8.6/Rails2.3.2我注意到在我的任何ActiveRecord模型类上调用的任何方法都返回nil而不是NoMethodError。除了烦人之外,这还破坏了动态查找器(find_by_name、find_by_id等),因为即使存在记录,它们也总是返回nil。不从ActiveRecord::Base派生的标准类不受影响。有没有办法追踪在ActiveRecord::Base之前拦截method_missing的是什么?更新:切换到1.8.7后,我发现(感谢@MichaelKohl)will_paginate插件首先处理method_missing。但是will_pa

  9. ruby-on-rails - Ruby "Undefined Method"用于类方法 - 2

    Ruby初学者努力简单地将这个@@people散列的值打印到控制台classPerson#haveafirst_nameandlast_nameattributewithpublicaccessorsattr_accessor:first_nameattr_accessor:last_name#haveaclassattributecalled`people`thatholdsanarrayofobjects@@people=[]#havean`initialize`methodtoinitializeeachinstancedefinitialize(first_name,last_

  10. ruby-on-rails - define_method 在调用方法之前不使用变量? - 2

    我无法从for循环中获取变量。似乎i(var)是稍后计算的,而不是我完全需要的类定义。ree-1.8.7-2010.02>classPatree-1.8.7-2010.02?>foriin39..47ree-1.8.7-2010.02?>define_method("a#{i}".to_sym)doree-1.8.7-2010.02>putsiree-1.8.7-2010.02?>endree-1.8.7-2010.02?>endree-1.8.7-2010.02?>end#=>39..47ree-1.8.7-2010.02>p=Pat.new#=>#ree-1.8.7-2010.02

随机推荐