Am trying to create a login form using 'http://localhost/myproject/public/auth/login' but i keep getting that error.
Below is my routes.php :
Route::get('/', function () {
return view('welcome');
});
// Authentication routes...
Route::get('auth/login', 'Auth\AuthController#getLogin');
Route::post('auth/login', 'Auth\AuthController#postLogin');
Route::get('auth/logout', 'Auth\AuthController#getLogout');
// Registration routes...
Route::get('auth/register', 'Auth\AuthController#getRegister');
Route::post('auth/register', 'Auth\AuthController#postRegister');
I have also create resources\views\auth\login.blade.php file. Can anyone please help since i'm following Laravel 5.1 on this but can't quite know whats wrong.
Related
I occure a problem which I do not understand. Following code does not work:
AccountingEntity accountingEntity = AccountingEntity.get(params.id);
accountingEntity.setLifecycleStatusToArchived();
accountingEntity.save(flush:true);
Where the method setLivecylceStatusToArchived looks like:
void setLifecycleStatusToArchived() {
this.lifecycleStatus = AccountingEntity.LIFECYCLE_ARCHIVED; //predefined static variable
this.considerForRankingJob = false;
this.dateArchived = new Date();
}
Problem is, that the entity is not updated.
No validation erros when I use accountingEntity.validate() in advance.
However, this code works:
AccountingEntity accountingEntity = AccountingEntity.get(params.id);
accountingEntity.setDateArchived(new Date());
accountingEntity.setConsiderForRankingJob(false);
accountingEntity.setLifecycleStatus(AccountingEntity.LIFECYCLE_ARCHIVED);
accountingEntity.save(flush:true);
The code did not work any more after update from Grails 3.2.9 to 3.3.0.RC1 (Gorm 6.1.5) unless I followed all the steps in the guide (http://docs.grails.org/3.3.x/guide/upgrading.html) and the rest of the code is working properly (also database accesses etc.)
Has anybody an idea? What the problem could be?
Thanks in advance and best regards!
The short answer is dirty checking. When you are setting properties inside the instance method Grails doesn't know they are dirty.
See the following github issue for how to resolve the problem:
https://github.com/grails/grails-data-mapping/issues/961
you have 2 options:
call markDirty every time you change an internal field. This will be
better for performance or as per
http://gorm.grails.org/latest/hibernate/manual/index.html#upgradeNotes
use
hibernateDirtyChecking: true
I have two rules
Route::get('this-is-an-awesome-route', 'Ads#getIndex');
Route::controller('ads', 'Ads');
action('Ads#getIndex') renders
http://my-awesome-domain/ads
I want
http://my-awesome-domain/this-is-an-awesome-route
What's the problem ?
For some reason from Laravel 4.2 to Laravel 5 the logic changed a little bit. The line you wrote was working before, you just have to reverse everything as the router isn't processing your code the same way.
Tested and working solution
Route::controller('ads', 'Ads');
Route::get('this-is-an-awesome-route', 'Ads#getIndex');
The first route will be overwritten by the second one.
The second route is rewriting the first route declaration. Let's see:
// Ads#getIndex will be called
Route::get('this-is-an-awesome-route', 'Ads#getIndex');
// Ads#getIndex will be called too by native definition
Route::controller('ads', 'Ads');
Because of Route::controller('ads', 'Ads') is called as latest declaration it will overwrite the previous one. So, you have at least two ways to achieve this task
You could create a new function into Ads controller just to response to the first route:
Route::get('this-is-an-awesome-route', 'Ads#awesome');
Then:
public function awesome(){
// do stuff here
}
Rename the route name for your controller
Route::controller('ads', 'Ads', [
'getIndex' => 'ads.getHome',
]);
Now your Route::controller('ads', 'Ads'); will respond to getHome() instead getIndex() as per renamed route:
public function getHome(){
// do stuff for getIndex() definitions here
}
I have running in my Mac a Node.JS server, and, I access to it from other computer, the server doesn't crash, but, I don't know why, the application crashes when I access from my iPad. If I access from Safari, the server works, but, with Chrome for iPad, the app crash!
This is the error: TypeError: Cannot read property 'following' of null. Why this happens?
EDITED:
app.get('/home', middleware.yeses, function (req, res){
console.log(req.session.user + "\n\n");
UserModel.find({ user: req.session.user }, function (err, user){
console.log(user);
res.render('home.ejs', {
username: req.session.user,
avatar: user[0].avatar,
following: user[0].following.length,
followers: user[0].followers.length
});
});
});
EDITED:
I changed the console.log(user); to this console.log(user[0].following). And there's no problem. I don't know why, there's a problem with it in the locals.
This occurs because the JavaScript is throwing an exception. Somewhere in the code, the there is a variable that is assigned to null and the property following is being accessed on that variable. This operation raises an exception.
var obj = null;
obj.following; // exception thrown!
It's impossible to help you more. With the info and code you've provided (very little of either). But look for where you are accessing a following property and debug from there.
Update:
It appears user[0] is null. Why? No idea. That depends on other code you haven't posted. WHere is user declared and populated? Is it an array? Because that would be strange for a variable named user.
I'm currrently using the Twitterizer Framework to track many keywords (the limit is 400 from the Twitter API). Therefore, i try to follow some users (their timelines) but I get the Error "NotAcceptable".
Example Code A(this works):
StreamOptions options = new StreamOptions();
options.Track.Add("keyword 1");
options.Track.Add("keyword 2");
...
Example Code B(this works):
StreamOptions options = new StreamOptions();
options.Follow.Add("ID1");
options.Follow.Add("ID2");
...
Here I get the Error "NotAcceptable".
What I'm doing wrong?
Thanks!
this will be because of the type of stream you are starting. Right after the code you posted, you should have code to start your stream:
stream.StartPublicStream(...);
My guess is you actually have StartUserStream in error ...
If I don't provide the value in the URL for Codeigniter, it'll display a PHP Error was encountered saying it's missing argument for a function call. I do NOT want it displayed at all. If there's no argument in the URL, it should just reroute to its index function. How do I prevent that from happening?
For example, www.example.com/profile/id/45
anyone would guess and enter like this "www.example.com/profile/id"
that would generate the error. How do I prevent that? I tried, "if (!isset($id))" but it generated error before it reached to that condition.
just learned that the solution is simple:
function id($id=NULL)
{
if ($id===NULL)
{
redirect....
}
}
you can also use:
$this->uri->segment(2); // gets 'id'
$this->uri->segment(3); // gets '45'
then do a redirect, check out:
http://codeigniter.com/user_guide/helpers/url_helper.html
use default values for your function
function id($id=0){
if(there any record with $id being provided){
//do something
}else{
//id not provided,set to default values 0 and then
show_404();
}
}
no way there could be id = 0 so its automatically showerror without redirect, if user enter the url www.example.com/profile/id ,