model

MVVM pattern in wpf - one data model , multiple view models

I am currently designing simple editor as part of learning process. Its basicaly hierarchical tree structure of polygons-lines-points, that is implemented in data model. I need to display these data in two views First view: hierarchical data in tree view item Second view: rendered geometry on screen Following the MVVM pattern i have ...

Rails problem display attribute key along with attributes value

I have the following problem. I have a form which takes input for a "Chart" object. But after processing the form, i wish to display one of the values, and it adds the key of this value. Class model class Chart attr_accessor :title, :series def initialize(title = nil, series = []) @title, @series = title, series end end ...

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 ...

Redirect view after saving Rails model

Hello, When I: self.save or save! in a model it automatically redirects me to the show view for that given model. How can I override this? I want to save the model and then go to another action/view in the same controller. In particular, I have a process where I save a members details, and then I want to continue the process by g...

Rails 3 model associations. Limit the number of data selected

I have a model user, a feed, and a comment. user has many feeds and comments, feeds belong to user and have many comments and finally comments belong to user and feed. No when i show feeds for a certain user, it selects all the comments made till date for every feed. I want it to select only those comments that were made in the last 1 m...

How to change the sequence of 'joins' in CakePHP?

I have the problem with the sequence of joins. The similar problem was in another question http://stackoverflow.com/questions/3343348/manipulating-order-of-joins-in-cakephp. The answer was to use Containable behavior. In my case that is unacceptable because I have deeper associations and containable generates too many queries. Containabl...

Validating a model in ASP.Net MVC2.

I have the following database table: And here is the code I use to validate the model created by Entity Framework: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.ComponentModel.DataAnnotations; using System.Web.Mvc; namespace UTEPSA.Models { [MetadataType(typeof(Area_Validation)...

Simple validates_length_of yields unexpected NoMethodError

I have a message form which uses validates_length_of in the model to limit the length of the message. validates_length_of :content, :maximum => 1024 I "tested" this by entering 5k or so characters and submitted the form. But I get this NoMethodError: NoMethodError in Messages#create Showing app/views/messages/_messages.html.erb w...

System.MissingMethodException: No parameterless constructor defined for this object.

I'm using MVC 2.0 with a Html.ListBoxFor as below: <% using (Html.BeginForm()) { %> <input type="submit" value=">" /> <%= Html.ListBoxFor(x => x.lstTest, new MultiSelectList(new [] {"someone", "crap", "why"})) %> <% } %> When I click the input submit button below with nothing selected, it posts back fine, when I ...

Update App Engine model with dictionary

You can create a new model in App Engine using a dictionary: my_model = MyModel.get_or_insert(keyname, **kwargs) Is there a way to update a model using a dictionary instead of doing the following? my_model.firstprop = 'first' my_model.secondprop = 'second' ...

Rails -- How to setup model that can belong to either of 3 different models

I'm trying to make an app that does testing similiar to what you would experience in school. I have a model Question, which can belong to either an Exam, Quiz, or Assignment. Should I create fields for ":exam_id, :integer, :null => false; :quiz_id, :integer, :null => false; :assignment_id, :integer, :null => false;"? The question w...

How to do ASP.NET MVC Model Validation with DataAnnotations where ViewModel contains objects from an external Web Service?

I would like to use DataAnnotations for basic client and server-side validation of my MVC ViewModels. My ViewModel looks like this: public class MyViewModel { public Client Client1 { get; set; } public Client Client2 { get; set; } public Product Product { get; set; } } So I would like to check that both client objects have...

(How) can you add methods to a collection of entities in Google App Engine python?

In GAE-python, you can model a one-to-many relationship by assigning a reference property to the child model. class Book(db.Model): title = db.StringProperty() class Author(db.Model): book = db.ReferenceProperty(Book, collection_name = 'authors') is_primary = db.BooleanProperty() name = db.StringProperty() This way, I can ...

Extends class [PHP]

In kohana 2.3.4 system load first application, after modules and system. I want to extends User_Model in application with User_Model in modules. How to do that? ...

Rails variable loads first time and then is nil!

I am receiving the following error: ActionView::TemplateError (You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.include?) on line #24 of app/views/index/index.html.erb: 21: <% @achievements.each do |achievement| %> 22: <%= achievement.name %> 23: ...

asp.net mvc c# - Is it possible to access value of textbox in View from Model in CodeBehind ?

Hello, I have a problem to get a value of textbox which is in view into the controller. In WebForms it was quite easy, it needed just to call textbox in codebehind trouhg Id, but in MVC it seems not possible this way, or? Help me please! Take care, Ragims ...

Rails -> do something with "updated_at" like "set_primary_key" for the id

have a legacy table with a field "LastModifiedDate", and I want to use that column as my "updated_at" column. Is there any way to tell Rails to use that field? Or, let me rephrase. :) ... How can I tell Rails to use that field? :) Thanks! ...

Magento - Trouble with setting up Model Read Adapter

I was following through on Alan Storm's tutorial on Magento's Model and ORM basics and I've run into a bit of a problem. When I get to the portion where I load from the Model for the first time I get this error "Fatal error: Call to a member function load() on a non-object...". I've reset everything already and tried again from scratch b...

Parsing and modification of SQL statements in Java

Hi, Does anyone know about a SQL statements parser, in Java, that would allow having an Object representation of a SQL query, allow modifying this representation and generate back the updated SQL statement? Regards, Christophe ...

asp.net mvc c# - how to use check box in view and get it's value in model?

Hello everybody, can I use it like this in View? <%= Html.CheckBoxFor(user => user.Role, "Administrator")%> and then just read a value of property in model if checkbox is checked: string role = user.Role; (role = "Administrator") Help me please! Take care, Ragims ...