controller

Is the Rails update_attributes method the best choice for doing an update of a model in the database?

def update @album = Album.find(params[:id]) if @album.update_attributes(params[:album]) redirect_to(:action=>'list') else render(:action=>'edit') end end A Rails 1.1.6 tutorial that I'm covering recommends using the update_attributes method for updating a model, as in the example code from my controller listed above. L...

Can someone show me a diagram of how view controllers work?

Can someone show me a diagram of how view controllers work in cocoa (obj-c). I just want to understand because they are confusing me Thanks! ...

Passing data between controllers with the session RESTfully

I'm using a hideous pattern in my code and I know there must be a better way to do this. Help me rethink what I'm doing. My website is a kind of discussion forum. All replies to discussions are done on the DiscussionsController#show page, inline. Some replies are invalid, though - for example, if you try and post a reply that has no t...

Not sure where (model or controller) to define my find method

(Warning: Clueless Rails Newbie!) In my show.html.erb for my albums view, I call a public method in my albums controller: <% albums_feature = find_albums_with_feature(feature.id) %> It generates a NoMethodError. So I copied the method into my Album model and tried calling it from the view as: <% albums_feature = Album.find_albums_w...

In asp.net mvc is it possible to make a generic controller?

I'm attempting to create a generic controller, ie: public class MyController<T> : Controller where T : SomeType { ... } However, when I try to use it, I'm running into this error everywhere... Controller name must end in 'Controller' So, my question, Is it possible to make a generic controller in asp.net mvc? Thanks! ...

thunderdome action invoker asp.net mvc

Hi, I know basic idea of thunderdome principle (one object enters, one object leaves) but I didn't see any real world example of it in asp.net mvc. Is it good example of thunderdome principle public ActionResult Index(Employee employee) { //some actions here return View(employeeViewModel); } ...

How do you indicate where the form_tag is submitted to in Rails?

I'm new to Rails and am not sure how to specify where the form_tag submits to? <% form_tag do %> <%= submit_tag "checkout_submit" %> <% end %> In the case of the example above, does this form submit itself to the "checkout_submit" action from the same controller that rendered this view? ...

Repository in Controller or Model?

I've been working through the NerdDinner Tutorial and most of it makes sense. What I'm not sure about is why the Repository is used directly in the Controller and not the Model objects. For instance, if we wanted to implement our own membership system and it had an AccountController with a Login method, what would be the best solution fo...

Will IoC lead to too many params for ASP.NET MVC Controller constructor?

I have decided to use ASP.NET MVC for a website project and want to follow some of the best practices being written about. So, I have separated out the Domain/Model into a separate project, created IRepositories and concrete repositories and have now turned my attention to Castle Windsor as the IoC. The problem I now face is that for a...

Rails application settings

I'm creating two related Rails applications, and I'm noticing a lot of non-DRY work. For example, the @title field being set in the various controller methods do the same thing, except for the application title, as in: # SiteController (application 'Abc') def SiteController < ApplicationController def index @title = 'Abc' end ...

Rails and MVC metaphors

I am working on re-writing my application based on things that I learned at RailsConf 2009. I understand that the Model, Controller and View relate to each other. However, one thing that I have struggled with is the "proper" level for a controller. If the Rails Model maps (roughly) to a database table... And if the Rails View maps (roug...

Creating model objects from raw form data - is a one-to-one field match required?

If I say this in the controller: @order = Order.new(params[:order]) What is required for this to work? Does there need to be a one-to-one match between all of the fields in params[:order] and the Order model? Or can there be more or fewer fields in params[:order] than are required to instantiate an Order? ...

How to access domain properties from a controller in Grails?

I have the following Grails domain class: class Product { String name Float basePrice Category category String image = "default.jpg" static constraints = { name(size:3..25, blank:false) basePrice(scale:2, nullable:false) category(inList:Category.list(), nullable:false) image...

StructureMap controller factory and null controller instance in MVC

I'm still trying to figure things out with StructureMap and one of the issues i'm running into is my Controller Factory class blowing up when a null controller type is passed to it. This only happens when the application builds for the first time, after which every subsequent build works fine. Even when i shutdown Visual Studio and reope...

Cocoa Touch App Architecture - MVC controller?

I am quite new to Cocoa and to iPhone programming. I am using the Xcode Utility Application template to implement a simple app that has: a view with a text field to collect a username a view with a connect button to start a connection to a remote site using the username to get some data via HTTP. The data will be presented as a text ...

Navigation view controller question

Below is what I want to implement: The main screen of my app is a UITableView. Each row in the table view is a category, when you click the detail disclosure button in the row, you can see a bunch of items under this category in the category detail view. Now in the main screen, I click the "+" button in navigation bar to create a new c...

Passing data from MVC Controller to View in PHP

I have my own hand-rolled PHP MVC framework for some projects that I'm working on. When I first created the framework, it was in the context of building an admin CMS. Therefore, there was a very nice one-to-one relationship between model, view, and controller. You have a single row in the DB, which maps to a single model. The controller ...

[iphone] Do I need multiple controllers for a single view with different types of controls?

If I have a view with several buttons, a table, and some other controls, do I need a controller for each type (button, table, etc), or should I have one controller per view that handles all of the necessary actions? It doesn't seem a single controller is possible as they may have to inherit from different parent classes. What is the bes...

Groovy: parametrized link tag

Hi I have the following gsp page: <g:def var="incidentMngmntId" value="${incidentMngmntInstance?.id}"/> <g:link controller="ticketMngmnt" action="list" params="[incidentMngmntId : incidentMngmntId]" id="${incidentMngmntInstance?.id}"> Tickets </g:link> The generated URL is as follows http://localhost:8080/smtool/tic...

ASP.NET MVC Controller.OnException not being called

I have a base controller class where I'm overriding to the Controller.OnException handler method in order to provide a generic error handling for certain types of controllers that will inherit from this class (these are API controllers that will return JSON results). The OnException method never gets called when an exception gets raised...