controller

Unit testing all controllers from a single test

I just created an action filter that I want to apply to nearly all of my controllers (including any new ones that are introduced later on). I figure a really useful unit test would be one that cycles through each controller and verifies that if certain criteria are met, then the action filter will impact the result. Is it wise to creat...

Magento: Extending Customer Account Controller to add actions to the forgot password steps

We are trying to add a couple of actions to the AccountController to add another action after the forgotpasswordpost action. The problem is if we add the action to the preDispatch logict to make sure you don't have to be logged in it still redirects back to the login page. public function preDispatch() { // a brute-force pro...

Windows Security Template to Allow CAN Controller Access

I'd like to see advice on how the security template should be configured to permit CAN controller access from an application. Thank you. ...

requestAction() does not go to the controller's function after beforeFilter(), from a shell class

Hi, In my CakePHP aplication, I use a shell script with a cron job which is working perfectly, except when it comes to call the requestAction() function. Thanks to my logs, I can see it going to the proper Controller->beforeFilter() function, but after that nothing happens. It neves goes into the specific function. I tried to output $t...

Generate a 1x1 white gif as a Stream in c#

Hi - I would like to return an image as an ActionResult from an MVC2 controller. This image is a 1x1 white pixel (for a tracking application). I do not want to reference an image on the disk or in a database. I would like to generate the image in my method and then return it from the controller action. Any one know how to generate a ...

ASP.NET MVC 2 Controllers to Model Associations

In my model I have relationships like this: [Person] PersonId (PK) ... [Orders] OrderId (PK) PersonId (FK to Person.PersonId) ... A person can have multiple orders. I generated PersonController with Create/Details/List/Edit views. I want to be able to manipulate Orders also, but within the context of a Person. In other words, I...

ASP.NET MVC - Insert or Update view with IEnumerable model

I've seen plenty of examples (NerdDinner, Sanderson's Sports Store, etc.) where a view is bound to a collection of objects. The syntax in the view is usually something like this... <%@ Page... Inherits="System.Web.Mvc.ViewPage<IEnumerable<MyViewModel>>" %> ... <% foreach (var myViewModel in Model) { %> I've also seen plenty of exampl...

Where can I use cookies in Ruby on Rails

I'm using controller's initializer to setup stuff that I will need. def initialize super() a = cookies[:a] # EXCEPTION end However I can't use cookies because it's null, the system hasn't read them from the header yet. The same problem was with ASP.NET MVC, where I couldn't access the cookies in the constructor, but I could acce...

Invoking Rake::Task in rails causes "Don't know how to build task..."

Trying to integrate some friendly_id gem functionality on a controller method. Essentially, I have a Market object, which has its URL created based on a custom method. Since it's based on a custom method, friendly_id won't update the URL when the Market object gets updated. Friendly_id does offer a redo_slugs rake task, but when I cal...

How to call controller function from template in Django?

How to call controller function from template in Django instead of hardcoding URIs? ...

Best way to display current logged-on user in default.ctp?

I am in the process of customizing the default.ctp file and I am trying to display the currently logged on user's name on the top of the page. In app_controller.php, I have the following: function beforeFilter() { $user = $this->Auth->user(); if($user != null) { $this->Session->write('user_name',$user['User']['user...

Spring 3.0 HEAD Requests

Hi recently we moved to spring 3.0 Controller handling like this: @Controller public class MyController { @RequestMapping(method = RequestMethod.POST) protected String onSubmit ( Form form, Errors errors) { // handle POST } @RequestMapping(method = RequestMethod.GET) protected void getForm ( Form form ) { ...

Outputting a hyperlink from a controller in cakePHP

Hi I'm just getting started with cakePHP, and things aren't going so well so far. I have a controller that handles confirming user emails. On registration the user is sent an email with a confirmcode in a link. Depending on the confirm code they give, the controller gives different text responses. One of these responses includes a hype...

Copy Local != true System.Web.MVC - Asp.net MVC 2 Dictionary Error in Controller Before Action

I am getting an odd error in an ASP.NET MVC (mvc dll version 2.0.0.0) project after the server is under load (50 to 100 requests per second) for a few hours and cache is approaching its memory limit. If I am reading the error log right (we use elmah) the MVC action parameter parser is failing before it gets to my controller's action. ...

Magento - local file is not working.

Hi, I have a question regarding Magento's local directory. I am trying to override a core controller - Mage/Contacts/controllers/IndexController.php. So I copied IndexController.php to /app/local/Mage/Contacts/controllers/ but Magento is still using core file. I can confirm it because I see 404 page when I rename Mage/Contacts/contro...

iPhone Having Two Views associated with ONE view controller

Blarg! I'm trying to develop a game with zelda-like qualities. (i.e. When the PC hits the edge of the screen, the screen changes to the next view, and the PC's position restarts at the appropriate edge.) The problem I'm having is that I don't want to have multiple View Controllers for each level-segment, because all of the data/functio...

ASP.NET MVC - Keeping a controller thin (too many action methods)

I'm working on my first real ASP.NET MVC project and I've noticed that the controller I've been working in is getting rather large. This seemingly goes against the best practice of keeping your controllers thin. I've done a good job keeping the business logic out of the controllers. I use a separate layer for that. Each action primar...

Removing null records from a set in Grails Controller

Hello again, so, Grails is making me feel quite stupid again, I'm new to this. I have A grails domain that maps a table thats in production on a postgresql database. I am trying to track progress on the project by a date field 'migratedDate'. Everytime a process takes place the field is timestamped. I can't seem to make a controller ...

Checking an attribute is true before executing a CRUD action

Before any of my article controller crud actions can run (excluding index), i want to make sure that the article's active field is true. I thought about doing this in a before_filter, but at that point @article has not been set, any ideas please? Thanks ...

same code in different actions of the controller in rails -- how to make DRY?

I have a controller with two different actions, but both need this same code, which is a little long, how can I allow them access to this same behavior but keep it DRY? @list = Contact.find :all, :select => "companies.name AS co_name, companies.id AS comp_id, COUNT(contact_emails.id) AS ema...