controller

laravel 5 only root route works

心不动则不痛 提交于 2019-12-05 16:30:14
问题 I am new to laravel. I am using Ubuntu 15.04. I installed Laravel Framework version 5.1.7 (LTS) using composer and a lamp server using $ sudo apt-get install lamp-server^ command (I didn't install Homestead). I am using PhpStorm 8.0.3 as IDE. I created three routes and a controller. The PagesController.php file looks like this: class PagesController extends Controller { public function index() { return 'Welcome to my homepage!'; } public function about() { return 'Learn a little about me.'; }

Best way (other than session) to store objects in Rails controller?

此生再无相见时 提交于 2019-12-05 15:40:02
I have a rails controller class Controllername < application def method1 obj = API_CALL session =obj.access_token redirect_to redirect_url #calls the API authorization end point #and redirects to action method2 end def method2 obj.call_after_sometime end end I am calling some API's in method1 getting a object and storing access token and secrets in a session. method1 finishes it's action. After sometime I am calling method2 , now the session(access token, secrets) is stored correctly. But, now inside method2 I need to call the API call_after_sometime using the OBJECT obj .But, now obj is

What is the best way to add a “confirm-option” to a delete form in Symfony2?

穿精又带淫゛_ 提交于 2019-12-05 15:20:16
If you create CRUD-code for an entity in Symfony2 using the console, you will end up with a very basic delete function. This function is lean and efficient, but does not provide an "are you sure?"-confirmation. If the entity to be deleted exists, it will be deleted immediately. Does anyone have suggestions for the easiest way to add user confirmation? Up until now I have been using: An extra controller function jQuery It seems a bit weird though that Symfony2 would have no built-in option for this. Anyone better ideas? You could also render the basic delete-field of your form with an

how to call service from controller in grails

守給你的承諾、 提交于 2019-12-05 15:14:34
I have a service class and i am trying to call the method of the service in my controller as below. class LogListController { def ListLogDetails = { println "We are inside List log Details-->"+params def logListHelperService logListHelperService.getFilePath(params) }} Exception Message: Cannot invoke method getFilePath() on null object what is my mistake there.. def logListHelperService must be declared outside of the ListLogDetails definition def logListHelperService def ListLogDetails = { println "We are inside List log Details-->"+params logListHelperService.getFilePath(params) } should

Controller Action Methods with different signatures

╄→尐↘猪︶ㄣ 提交于 2019-12-05 14:25:58
I am trying to get my URLs in files/id format. I am guessing I should have two Index methods in my controller, one with a parameter and one with not. But I get this error message in browser below. Anyway here is my controller methods: public ActionResult Index() { return Content("Index "); } public ActionResult Index(int id) { File file = fileRepository.GetFile(id); if (file == null) return Content("Not Found"); else return Content(file.FileID.ToString()); } Update: Done with adding a route. Thanks to Jeff R0MANARMY You can only overload Actions if they differ in arguments and in Verb, not

Rendering a view of controller action from around_action callback

◇◆丶佛笑我妖孽 提交于 2019-12-05 13:55:15
I'm rendering a js.erb partial which enables ajax functionality to like/dislike a restaurant dish. I recently came across the around_action callback and figured yield would help perform the controller action first and render the template second. Unfortunately I'm getting a 500 (Internal Server Error) due to the respond_to never getting called. The respond_to method works if I place it inside the controller action but not inside the callback. What am I doing wrong? class DishesController < ApplicationController before_action :set_dish_and_restaurant around_action :render_vote_partial def like

AS3 USB game controller support

做~自己de王妃 提交于 2019-12-05 13:03:56
How can I make a USB controller control my AS3 game. I'm using the keyboard right now and I have thought about mapping the keys but I have to use a plugin for that and I just want users to be able to buy a simple controller that doesn't need any driver downloads/configuration. They should be able to plugin the USB controller and play the game through Flash Player in a browser. One possibility... you can tell your users to download joy2key. http://electracode.com/4/joy2key/JoyToKey%20English%20Version.htm I admit that this is not a "real answer" to your question. But it is a stop-gap solution

codeigniter - using helper in controller doesn't work

廉价感情. 提交于 2019-12-05 12:49:45
I need to use a function in multiple controllers. So I though about using a custom helper, but it seems I can't get it to work. (It works in the view, but I need it in the controller) It gives me following Fatal Error: Fatal error: Call to undefined method Developers::checkIfLoggedIn() in /application/controllers/developers.php on line 12 Is it a smart move to use a helper to use a function in multiple controllers, or should I do it otherwise. Thanks in Advance, Mark EDIT: Controller file: if (!defined('BASEPATH')) exit('No direct script access allowed'); class Developers extends CI_Controller

Laravel 4 controller tests - ErrorException after too many $this->call() - why?

可紊 提交于 2019-12-05 12:34:53
I'd greatly appreciate some help regarding a Laravel 4 issue I'm experiencing. I'm testing controller routes, specifically a controller that is responsible for routing responses for a questionnaire. I'm testing scenarios such as: the user attempting to skip a question, the user requesting a question that doesn't exist... etc. The tests that I've written for all scenarios up until now work as expected using PHPunit. The test I'm currently writing involves several $this->call() or $this->client->request() executions and that's where things break down. If I execute $this->call() or $this->client-

Handling Exceptions that happen in a asp.net MVC Controller Constructor

纵然是瞬间 提交于 2019-12-05 11:22:17
What's the best way to handle exceptions that happen from within a controller's constructor? All I can think of to do is use Application_OnError() or put a try/catch in my ControllerFactory. Neither of these solutions seem ideal. Application_OnError is to broad - I have some non-mvc content in the site that has its own error handling. Using a try/catch block seems kinda hacky. If I'm serving different content type -html/text/json/rss.... I would like to be able to handle the exception from within the action method instead of having to write all kinds of conditions to determine what kind of