model

ASP.NET MVC 2 Model partial binding

Hi, My problem is that I want to partially edit my model - to display 2 fields and to edit another 2 fields for example. When POST happens, returned model contains only the fields that are editable, other fields that I use only to display are NULL. How to fix this, on POST to be returned model with all fields, because on ERROR when I ret...

How to access old state values within datamapper observer?

I'm using dm-observer to observe my dm models, and I need to perform some actions based on state changes within the model. I've figured out that @state is used to store the updated state value, but I have not been able to figure out how to access the old state value. In the example below I've used "old_state", but obviously that does not...

Rails model constants with hash

I have added some constants to a model say MyModel.rb as shown below. MY_CONST = { :foo =>"Some Name for Foo", :bar =>"Some Name for Bar" } Also I have saved string foo as the column value in a table record. @m = MyModel.find(1) @m.column_name #=> foo Now in my view I need to show "Some Name for Foo" as the output for @m.colu...

Interactive 3D Model in HTML5

Hi, does anybody know if its possible to get a 3D model of a building made in 3ds Max for example, onto an HTML5 web-page and make it interactive, for example pans and zooms,maybe even use it for navigation through a site? If this is not possible in HTML 5 or with such a detailed model does anyone have any recommendations for achieving ...

Passing a variable into a models after_initialize method

I have the following (heavily simplified) model, that uses will_paginate class Search < ActiveRecord::Base attr_reader :articles def after_initialize @articles = Article.paginate_by_name name, :page => 1 end end and the controller code in my show action is @search = Search.new(params[:search]) This all works fine, but ...

Looking for a earth model that I can customize.

I am looking for some kind of earth model that at run time can pick up some data from an xml file and display it on the earth based on lan or lon etc.Is there something like that ? Any OpenGL or flash where I don't have to do coding just feed the thing.Can someone shed some light on available ways to accomplish this.Something on the line...

Passing the model in a view back to an action

Hello, I am wondering how I can pass a model back to an action so that I can continue to work on the data but in a different action based on the button's pressed To send it back, I specify the Control, Action and use the new { dom = Model } to specify the parameter. dom is a List (so a list of domain objects. My model passed in is an ...

Model Callback beforeDelete

I'm trying to delete images when deleting the container of those images with a cascading model::delete The cascading works fine, but I can't get the model call back afterDelete to work properly so I can delete the actual image files when doing the delete. function beforeDelete() { $containerId = $this->id; $numberOfImages = $th...

Can't override a core model in Magento

Hi, I’m trying to override Mage_Catalog_Model_Layer_Filter_Category. In system.log I’m getting a warning: Warning: include(Mycomp_Catalog_Model_Layer_Filter_Category.php): failed to open stream: No such file or directory in /var/www/magento/includes/src/Varien_Autoload.php on line 93 Warning: include(): Failed opening ‘Mycomp_Cat...

default_scope :order => :index does not works

I have a simple models class Item < ActiveRecord::Base has_many :parts end class Part < ActiveRecord::Base belongs_to :item default_scope :order => :index end Each part has it's own index, to be ordered inside of the Item in question. When i load parts for the item in ItemsController.show method, the parts are not ordered. ...

Rails before_validation strip whitespace best practices

I would like my User model to sanitize some input before before save. For now some simple whitespace stripping will do. So to avoid people registering with "Harry " and pretend to be "Harry", for example. I assume it is a good idea to do this stripping before validation, so that the validates_uniqueness_of can avoid accidental duplicat...

Problems using ActiveRecord model on existing table.

I've created a model for an existing table using the following generator command: script/generate model Group The table in question have a different name, so I've changed the model to account for it. set_table_name 'demandegroupe' Then I've fired up the console to look if everything was working. >> Group.all [#<Group login: "XXXXX...

reverse validates_associated

i am trying to validate a field depending on attributes from the associated model. looking at the code will make more sense (i hope) class User < ActiveRecord::Base has_and_belongs_to_many :user_groups has_one :profile, :dependent => :destroy accepts_nested_attributes_for :profile validates_associated \ :profile, :allo...

Route to nested model/form for unsaved parent

I have a complex form for a model Schedule that belongs to a parent Listing model: class Listing < ActiveRecord::Base has_many :schedules, :dependent => :destroy accepts_nested_attributes_for :schedules, :allow_destroy => true, :reject_if => :all_blank ... end class Schedule < ActiveRecord::Base belongs_to :listing ... end ...

Populating properties on my Model with values from a SelectList when I post

I'm building an Asp.net MVC 2 application. I have an entity called Team that is mapped via public properties to two other entities called Gender and Grade. public class Team { public virtual int Id { get; private set; } public virtual string CoachesName { get; set; } public virtual string PrimaryPhone { get; set; } ...

CakePHP, setting recursive to -1 for a model so it doesn't do "joins"?

I have 2 models that are associated but don't want it to use joins when I make database updates.. from the cakephp cookbook, I can't quite gather how I am supposed to set "recursive" to -1, also, do I do it for the model that has the association, the other one, or both such as if model1 "belongs to" model2 and I am trying to make it so...

navigate ecore model

How do I navigate, programmatically in java, an Ecore model to extract the elements information? ...

Getting form data in Yii to a CActiveRecord model works for one model but not for another

I'm getting a submitted form in this way: $resume->attributes = $_POST['ResumeModel']; $profile->attributes = $_POST['UserProfile']; Both CActiveRecord models are correctly populated before this from the corresponding tables, they have the correct data and all. Both models' data is present on $_POST as modified by the form. But it see...

model and view in a simple strategygame with cocos2d&cocoa touch

Hey i need some general advice on how to structure my project. i am trying to make a simple strategygame where some object move around in a "worldspace" and youve got several different tactical views, which show diffent areas of the game. nothing special. but since i'm a rather unexperienced programmer, some things are not quiet clear to...

How do I separate datamapper observer class into a different file from the model class?

I'm running into an error when I try to split the dm-observer class into a separate file from my model class. Previously it worked fine if I put it all into a single file. # test_observer.rb require 'dm-observer' class TestObserver include DataMapper::Observer observe Test before :create do # does funky stuff end end ...