controller

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

依然范特西╮ 提交于 2019-12-07 11:06:41
问题 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

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

谁说胖子不能爱 提交于 2019-12-07 10:54:40
问题 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,

Rendering a view of controller action from around_action callback

风流意气都作罢 提交于 2019-12-07 10:27:01
问题 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 <

how to call service from controller in grails

空扰寡人 提交于 2019-12-07 09:13:30
问题 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.. 回答1: def logListHelperService must be declared outside of the ListLogDetails definition def logListHelperService def ListLogDetails

codeigniter - using helper in controller doesn't work

久未见 提交于 2019-12-07 09:00:52
问题 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

CodeIgniter only allow access to certain controllers when logged in

爷,独闯天下 提交于 2019-12-07 08:59:03
问题 I have some CodeIgniter controllers which should only be accessed by users who have logged in (i.e. where $this->session->userdata('username') is not null). If a non-authenticated person attempts to access said controllers they should receive: header('location: /auth/login'); There has got to be a better way to do this than to put a if (!$this->session->userdata('username')) header('location: /auth/login'); else { [rest of function] } in front of every function in the controller... I know DX

Using Postal Library From the Business Layer

喜欢而已 提交于 2019-12-07 07:47:38
问题 I have a website built using ASP.NET MVC3 which is layered as follows: ProjectName.Shared (model + service contracts) ProjectName.Infrastructure ProjectName.Data ProjectName.Data.Sql ProjectName.Managers (Business layer) ProjectName.Services (WCF services) ProjectName.UI.Main (ASP.NET MVC3 application) This is actually the structure I recently came up with after some refactoring. Unfortunately, there isn't complete separation between the UI and my business layer so this area could use some

Should a view be dependent on its controller? (ASP.NET MVC)

那年仲夏 提交于 2019-12-07 07:29:13
问题 Have a question about the design/usage of asp.net mvc here. In the html helper class, you can get to the current controller by Html.ViewContext.Controller. Moreover, you can get to the request, route collection and much more from the html helper class. Doesn't this go against the rule of MVC? Doesn't this opens up a ways for developer to do heavy controller dependent code in views? If not, what's the best practice use case for current viewcontext and controller from the html helper class?

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

北城余情 提交于 2019-12-07 06:19:43
问题 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

MVC Api Action & System.Web.Http.AuthorizeAttribute - How to get post parameters?

拥有回忆 提交于 2019-12-07 05:25:53
问题 I have the following API Controller: public class TestController : ApiController { [HttpPost] [APIAuthorizeAttribute] public IQueryable<Computers> ListOfComputersInFolder(Guid folderId) { return GetListOfComputersForFolder(folderId); } // End of ListOfComputersInFolder } // End of TestController And the following is my basic APIAuthorizeAttribute . public class APIAuthorizeAttribute : System.Web.Http.AuthorizeAttribute { public override void OnAuthorization(System.Web.Http.Controllers