controller

Why doesn't this associated create call work?

I've got a User model that has many Items. A Rating belongs to a User and an Item. In the DB, I have set ratings.user_id to be not NULL. when I am creating an Item, I would like to do this: def create current_user.items.create(params[:item]).ratings.create(params[:rating] redirect_to items_path end However, this balks wi...

Thunderdome MVC- Why one-model-in in MVC?

When Jeremy & Chad posted about their FubuMvc project, one of the differentiators they mentioned was their "Thunderdome Principal": The “Thunderdome Principle” – All Controller methods take in one ViewModel object (or zero objects in some cases) and return a single ViewModel object (one object enters, one object leaves). T...

Zend Framework, run query without a view?

Hello, I am currently building a small admin section for a website using Zend Framework, this is only my second time of using the framework so I am a little unsure on something things. for example are I have an archive option for news articles where the user will hopefully click a link and the article will be archived however I cannot w...

Passing multiple result sets to a view from a controller in ASP.NET MVC?

So I have a controller set up as follows: using NonStockSystem.Models; namespace NonStockSystem.Controllers { [Authorize(Users = "DOMAIN\\rburke")] public class AdminController : Controller { private NonStockSystemDataContext db = new NonStockSystemDataContext(); public ActionResult Index() { ...

VGA standard for Graphics Controller

I'm attempting to create a generic graphics controller for VGA monitors with an Altera FPGA via a VGA connector, but I cannot find any good online resources explaining the standard specification which monitors use. I've found all the pin descriptions and some resources which describe how to create a specific graphics controller, such as ...

What should you name your controller in MVC? When should you create a new one?

I have a question that really applies to any MVC framework, I'm using the Zend Framework MVC. When exactly should you create a new controller? What exactly should the Controller layer define? I've created several apps with the MVC, progressively becoming more reusable, but I've always struggled with naming Controller classes. For t...

Controller equivalent of HttpContext.Current in ASP.NET MVC

I'd like to get access to the current executing Controller so I can offload the return of the appropriate ActionResult onto a helper method. To this end, I'm looking for the equivalent of what I would have thought would be ControllerContext.Current but isn't. Thanks! Edit for clarification: I've got a generic form control which is Jav...

ASP.NET MVC passing complex type into controller problem

Hello, I have a problem passing in a complex type into a controller. Here is how my Model looks like: public class Party { [XmlAttribute] public int RsvpCode { get; set; } public List<Guest> Guests { get; set; } public string Comments { get; set; } } public class Guest { [XmlAttribute] public string Name { get;...

setting the filename for a downloaded file in a rails application

Hi All, I have a controller action that allows a user to download a file with an extension of .ppt . It's not really a powerpoint binary, just an xml-ish format that powerpoint can read. the file is downloaded from the show action of a controller called ElementsController, but the show action is not actually defined in the controller, t...

What are some patterns for creating views and controllers in an MVC or MVP app?

I'm working on a MVC/MVP GUI for editing a document. The document has a tree structure, with some nodes representing text, others images. The app model also includes a command stack, with commands operating directly on the model. Since different nodes have radically different controls, I'm planning on implementing individual MVC/MVP t...

Using Server in Mvc.Controller

Hey All. I have my own inherited App.Controller from Mvc.Controller which then all of my controllers inherit from. I wrote a provider utilizing an interface and implemented it as MyService and the constructor takes the Server property of Mvc.Controller which is of HttpServerUtilityBase. However, I instantiate MyService in App.Controll...

MVC Controller independent of Type of view UpdateModel

I want to use the updateModel in a controller that has no notice of the type of the view. I have different views that have different types but all have an ExternalBase class as inherited type. So in my controller I always have a ExternalBase but the controller doesn't know the correct type. On saving I call a method that gets the co...

allow multiple roles to access controller action

Right now I decorate a method like this to allow "members" to access my controller action [Authorize(Roles="members")] How do I allow more than one role? For example the following does not work but it shows what I am trying to do (allow "members" and "admin" access): [Authorize(Roles="members", "admin")] ...

MVC + Wich pattern for this 1:n relationship

I have a Server application with a GUI. Written in c#. Now I want to use the MVC pattern for the whole Application. Normally you have 1 Model, 1 Controller and maybe n views. Okay, I have one of everything, but I'm not sure with the Model. My Situation: There are 1 server state, that can be online / offline, that has a client count, et...

Question about ASP.NET MVC & a form post using HTTP-POST.

Hi folks, I've got a standard ASP.NET MVC form post. eg. <% using (Html.BeginForm<CommentController>(c => c.Create())) { %> .. <% } %> (and in the controller) [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(Comment comment) { .. } Now, how can i make it so that i IGNORE certain values, like the ID or CreatedOn properti...

Unit testing my controller method results in an empty ViewName?

Hi folks, I'm doing some simple MS unit tests on my standard, nothing special controller. When i check the ViewName proprty, from the returned ViewResult object, it's "" (empty). I'm under the impression that the ViewName is implied by the name of the View (as suggested by this MS article on ASP.NET MVC controller testing). BTW, whe...

post and get with same method signature

In my controller I have two actions called "Friends". The one that executes depends on whether or not it's a "get" versus a "post". So my code snippets look something like this: // Get: [AcceptVerbs(HttpVerbs.Get)] public ActionResult Friends() { // do some stuff return View(); } // Post: [AcceptVerbs(HttpVerbs.Post)] public A...

view to controller communication

I am trying to found what is the best practice for view-controller communication for case when I need for example filtering. I have collection of items on page and filter control. I am filtering items by letter, status, etc... It is straightforward scenario, I am sending filter selected values to controller and controller gives back res...

How can I avoid AmbiguousMatchException between two controller actions?

I have two controller actions with the same name but with different method signatures. They look like this: // // GET: /Stationery/5?asHtml=true [AcceptVerbs(HttpVerbs.Get)] public ContentResult Show(int id, bool asHtml) { if (!asHtml) RedirectToAction("Show", id); var result = Stationer...

What is the proper way to handle forms in ASP.NET MVC?

Forms + ASP.NET MVC = Confusing for me: What are the preferred ways to setup your controller action for form posts? Do I need to specify an attribute that has [AcceptVerbs(HttpVerbs.Post)]? Should the controller action take a "FormCollection" or should I use ModelBinders? If I should use ModelBinders, how? How do I setup the f...