controller

How to assign the contents of one model to another in Rails?

I have the following create action: def create @order = Order.new(params[:order]) if params[:same_as_above] == "1" @order.billing_address.name = @order.shipping_address.name @order.billing_address.number = @order.shipping_address.number @order.billing_address.street = @order.shipping_address.town end ...

Using custom classes in Kohana 3

Hey, I'm creating a Call of duty 4 Server Watcher in Kohana 3, and I had created the basic classes for it before: A static Socket class (for handling basic network commands) A Cod4Socket class, (which uses the previously mentioned Socket class) that provides wrapper functions for basic commands. What I want is to be able to use said ...

Stumped by ActiveRecord controller error

I'm making a message board application. Users can make a post, each post requires a tag. Users can comment on the posts. Pretty simple. I've been hacking away on it and got an error I can't explain. I made a post, message#index shows the the list of posts including the newest one. The title of each post links to the message#show view (no...

Passing an object between two controllers

Hi, I have two controllers , and I have one object. I want to pass that object between my two controllers in CodeIgniter. There is a registry or something like that?? Example - I am using ipbwi (for invision power board 3.1 integration ) , on my main controller I am doing this - private $ipbwi; function Main() { parent::Cont...

iPhone SDK: Can't specify view to Navigation Controller

Hi everyone, I am working on my first iPhone app and making good progress. But there is one thing I just don't understand. When my app starts it displays a UIView with some functionality on it. This works fine. One of the buttons on that screen is supposed to load a new view (HistoryViewController) which contains a navigation controlle...

iPhone SDK: Passing NSMutable Array to controller not working

Hi there! I have an NSMutableArray countHistory defined and am trying to pass it to the next view controller: Updated Code: NSLog(@"Debug One"); HistoryTableViewController *controller; NSLog(@"Debug Two"); controller = [[HistoryTableViewController alloc] initWithNibName:@"HistoryTableViewController" bundle:nil]; NSLog(@"Debug Three");...

ActionController::MethodNotAllowed (Only get and post requests are allowed.):

Not sure what's going on. I've used the following bit of code to try and edit the name of a category, but I'm getting the error message above. My code for the form and submit for the edit is: - <% form_for :category, :url => categories_url(@category),:html => { :method => :put } do |f| -%> <p>Name: <br /><%= f.text_field :name, :size =>...

When to use a singleton?

Hello, I have this code: class MyController { public function newUserAction() { $view = new View('myfrontend'); if($this->request->isPost()) { $form = new MyForm; $posts = $this->request->getPosts(); if($form->isValid($posts)) { //... } } $view->display(); } } S...

RESTful Rails & encapsulating behaviour

Background - I have a model, say Door, that has a state of open or closed. I encapsulate the behaviour of opening the door in a method #open on each instance (And I also have a #close equivalent). But what's the best way to expose this in a RESTful way? What should my route be? It is an UPDATE to Door instance, but what should I UPDATE...

Problem with sending data to Modal View Controller on iPhone

So I've got one main view with some images on it, and when someone touches one of the images, the image will return an ID number to this main view and then this view will present a modal view controller to display a larger version of this image. But the current way I'm doing it, the function on the modal controller is getting there befor...

asp.net mvc generic controller

I am thinking of implementing a generic Controller in ASP.NET MVC. PlatformObjectController<T> where T is a (generated) platform object. Is this possible? Is there experience / documentation? One related question for example is how the resulting URLs are. ...

KO3 - Kohana 3 - How can I pass $_POST data from a controller/action back to the view/form that called it?

Hey everyone, I am trying to validate a form submission in Kohana 3. I have the form::open point to my action_create in my controller which successfully validates the data posted to it from the form in my view. If the data passes validation, a new item is created as intended, and the user is redirected to the item that was just creat...

How can I request a Rails page from within a Rails page?

A certain action must load an html page according a uri parameter. It works fine for all valid uris, except those of the current server. Is there an easy way to request a page from within a controller? require 'uri' class MainController < ApplicationController def foo uri = URI(params[:uri]) if uri.host =~ /localhost|mydomain\...

Determine result type in OnException of controller

I'm working on an MVC.NET 2.0 project where I'm trying to put in some special error handling logic in the OnException method of the controller. Basically I want to be able to determine the result type of the controller method in which the unhandled exception was raised, so that I can return error data in a certain format dependent upon ...

Launching navigation controller in landscape?

I'm trying to make a landscape app that uses navigation controller, but I can't get the app to launch in lanscape mode. Once I'm in another view and I use [self.navigation popToRootViewControllerAnimated:YES]; then the root view is in landscape. Why isn't it in landscape from the launch of the app. I've already put it in landscape mod...

Changing the text in a UITextView at runtime.

I have a ViewController consisting of just a textView. In its viewDidLoad method, I simply initialize the textView and add it as a subview. In my main ViewController class, when the user presses a button, I switch views and display the view that has the textView. I am trying to change the textView's text however it is not working. Can I ...

AbstractWizardFormController using Annotated @Controllers

I was wondering if anyone has attempted to rewrite AbstractWizardFormController (deprecated in Spring 3) using annotated controllers and could give me a hint on how to start. I am using Spring 3.0.3 ...

Rails: Flatten array in parameter

Hi, I'm trying to flatten an array for my form. def update @tour = Tour.find(params[:id]) params[:tour][:hotel_ids][0] = params[:tour][:hotel_ids][0].split(',') ... This results in: "hotel_ids"=>[["1","2"]] Naturally I want it to be "hotel_ids"=>["1","2"] My Form: <%= text_field_tag 'tour[hotel_ids][]', nil %> Hope anyon...

Where do I set common data for header in Pylons?

This is rather a general question about MVC. I have a set of templates for multiple controllers and their actions. All of them inherit from a overall template that contains footer/header. I want header to render email of currently logged in user. Common task. All tutorials are too simple to have basic example of how and where do I pa...

MVC: Relationship between controller and model

Hi, I'm slightly confused about the controller-model relationship in MVC. Should a controller be able to access any model in the system or should it have a 1:1 relationship with a specific model? Both options seem to present problems: If the relationship is 1:1 obviously if something elsewhere needs to be updated it can't for example ...