Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

Questions tagged [controller]

In MVC architecture (Model-View-Controller), the object responsible for passing and receiving data to and from views, acting as a bridge between the "Model" and the "View".

Filter by
Sorted by
Tagged with
4 votes
2 answers

Search and filter in MVC3 Razor using Linq

This code works fine, but I just don't like all the if else. If I keep adding field to filter, it's going to get messy. I am not using EF and cannot on this. ...
Stone Temple Aviators's user avatar
0 votes
2 answers

How can I refactor this oversized Ruby method into smaller bits and have unit tests for them?

This is the existing code. Clearly way too much is going on in this index method and furthermore it's untested (and hard to test in its current form). ...
Michael Durrant's user avatar
4 votes
2 answers

PHP MVC controller code needs diet?

This is the dashboard controller code in PHP Symfony 2. It collects some aggregate data and points for charts, but i don't like it very much. Do you think that this code belongs to what a controller ...
gremo's user avatar
  • 439
1 vote
3 answers

Loading data in controllers

I am refactoring my controllers, trying to improve the way common data is loaded for the actions. Initially, I was using before_filter methods to do this but read ...
user avatar
1 vote
1 answer

Refactoring my controller specs

In my project, I have this kind of code to test my controllers: ...
Dougui's user avatar
  • 167
7 votes
2 answers

Dispatcher for a JSON API without routes

I am using this code for a fast JSON API without routes. Does this code contain any useless parts? Is the class loader efficient enough? Are there any better options? Is ...
Aalex Gabi's user avatar
8 votes
3 answers

Linking issues, classifying the relationship as a cause, effect, superset, etc

I first saw this gigantic if and tried to refactor it. Could only end with a endless switch statement. Old code - ...
eLobato's user avatar
  • 181
4 votes
1 answer

Need help with cleaning up this Controller

I've written the following controller and i was looking for some input/advice on how i could go about cleaning this up or rewriting it. I feel like i'm repeating myself a lot or that there might be a ...
zSysop's user avatar
  • 141
4 votes
2 answers

Controller for searching with certain parameters

In the index view a user can search with any combination of one to all of the following parameters: firstname, lastname or ...
Theja's user avatar
  • 143
6 votes
3 answers

Not feeling 100% about my Controller design.

Basically, I'm uploading an excel file and parsing the information then displaying what was parsed in a view. ...
user avatar
28 votes
4 answers

Unit-testing a controller in Ruby on Rails

I intend this to be a general question on writing an effective set of test cases for a controller action. I include the following ingredients: Ruby on Rails RSpec: A testing framework. I considered ...
Steven's user avatar
  • 281

1 2 3