models

How do you reload your environment while using script/console?

I think I have seen Ryan Bates do it one of his screencasts, but I can't find it. I believe there is a command you can run while in script/console that lets you reload your models (if say you have made a change) so that you dont have to exit and then recall the console. Any Ideas? ...

ASP.net MVC - Update Model on complex models

Hi there, I'm struggling myself trying to get the contents of a form which is a complex model and then update the model with that complex model. My account model has many individuals [AcceptVerbs(HttpVerbs.Post)] public ActionResult OpenAnAccount(string area,[Bind(Exclude = "Id")]Account account, [Bind(Prefix="Account.Individuals")] En...

django url from another template than the one associated with the view-function

Heyy there, i have for example a view function like this: def profile_view(request, id): u = UserProfile.objects.get(pk=id) return render_to_response('profile/publicProfile.html', { 'object_list': u, }, context_instance=RequestContext(request)) and the url: url(r'^profile_view/(?P\d+)/$', ...

Rails setting OR conditions in validate_presence_of in a model?

In a rails model, is it possible to do something like class Example < ActiveRecord::Base #associations validates_presence_of :item_id, (:user_id OR :user_email) #functions end Where the model has 3 columns of :item_id, :user_id, and :user_email? I want the model to be valid as long as I have a :user_id or a :user_email. Id...

django accessing class variables in a view

hello, i want to make a notification function, and i need fields from 2 different models. how can i access those fields? in my notification view i wrote this data = Notices.objects.filter(last_login<date_follow) where last_login belongs to the model class User , and date_follow to Follow but it is not a proper and correct way of acc...

Why repeat database constraints in models?

In a CakePHP application, for unique constraints that are accounted for in the database, what is the benefit of having the same validation checks in the model? I understand the benefit of having JS validation, but I believe this model validation makes an extra trip to the DB. I am 100% sure that certain validations are made in the DB so...

Loading material parameteres from FBX in XNA

I've got some material parameters stored in the FBX file (DiffuseFactor, ShininessExponent, SpecularFactor and others), but I can't get to them using Effect.Parameters nor BasicEffect (they've got only the basic stuff - like EmmisiveColor or alpha). I know, that I can try to write a Effect-derived class, but is there any other way? A bui...

Is it bad to use a model directly from a view in codeigniter?

I know normally the data is passed thru to the view with the controller. however, currently in my view I load my model ($this->load->model('Db_model');) so i can use it in a loop to retrieve a users profile picture path from a array of IDs that is passed from controller. Will loading the db model in the view to accomplish this make my si...

Associated models in Rails?

Hi Everyone, In my rails application I have two models called Kases and Notes. They work in the same way comments do with blog posts, I.e. each Kase entry can have multiple notes attached to it. I have got everything working, but for some reason I cannot get the destroy link to work for the Notes. I think I am overlooking something tha...

Django: Grouping by Dates and Servers

So I am trying to emulate google app's status page: http://www.google.com/appsstatus#hl=en but for backups for our own servers. Instead of service names on the left it'll be server names but the dates and hopefully the pagination will be there too. My models look incredibly similar to this: from django.db import models STATUS_CHOICES...

How to render a Partial from a Model in Rails 2.3.5

I have a Rails 2.3.5 application and Im trying to render several Partials from within a Model (i know, i know -- im not supposed to). The reason im doing this is im integrating a Comet server (APE) into my Rails app and need to push updates out based on the Model's events (ex. after_create). I have tried doing this: ActionView::Base.n...

get and set for class in model - MVC 2 asp.net

Hi there, I want to improve the program so it has a proper constructor but also works with the models environment of MVC. I currently have: public void recordDocument(int order_id, string filename, string physical_path, string slug, int bytes) { ArchiveDocument doc = new ArchiveDocument(); doc.order_id...

Trying to make models in Kohana, relations problem.

I have a table of Hits, Articles and Categories Now, a Hit belongs_to an Article/Category (depends on where it was done). so I have a column on Hits table with the name 'parenttype' That tells me 'Article' or 'Category'. I wrote in the Hit model (extends ORM) protected $_belongs_to= array( 'page' => array('model'=> $this->parent...

How to change Controllers/Models source directory in CodeIgniter

I need to load controllers and models from a different folder than the default one. I am using a Linux system. I am building a simple CI application for some people, for use on a shared hosting I own. But I want to give them access only to /views folder and some /config files. And this is why I need to store the controllers and models ...

django: How to make one form from multiple models containing foreignkeys

I am trying to make a form on one page that uses multiple models. The models reference each other. I am having trouble getting the form to validate because I cant figure out how to get the id of two of the models used in the form into the form to validate it. I used a hidden key in the template but I cant figure out how to make it work i...

django app fields - copy and paste data

what field in the django models class should be used if the type of data (text/images/html) is unknown? i'm looking for a field that can handle copy and pasted html code, images, text, etc. ...

Mixing different models in one list in a view

I have three models: paste, snippet and tutorial. I want to show the newest of all of them mixed in one list, like this on the page: <ul> <li>Just a paste</li> <li>The worst snippet ever (-10202343 kudos) (1 quadrillion comments)</li> <li>Just another paste</li> <li>Ruby on Rails tutorial (5 kudos) (2 comments)</li> <li>Another snippet<...

[Django] models.Model class member not appearing in model_instance._meta.fields

Hi, I have a django.contrib.contenttypes.generic.genericForeignKeyField as a member of my model, however, it is not appearing when I instantiate the model and then try to get the fields out of the _meta of the object. e.g: class A(models.Model): field2 = models.IntegerField(...) field1 = generic.genericForeignKeyField() a...

Model validation problem in Cakephp

Hello all I am trying to implement form validation using cakephp models. Here are my code snippets... Model // File: /app/models/enquiry.php class Enquiry extends AppModel { var $name = "Enquiry"; var $useTable = false; var $_schema = array( "name" => array( "type" => "string", "length" => 100 ), "ph...

Cakephp: Validation Errors not appearing in data validation

Hello all I am trying to implement form validation using cakephp models. Here are my code snippets... Model // File: /app/models/enquiry.php class Enquiry extends AppModel { var $name = "Enquiry"; var $useTable = false; var $_schema = array( "name" => array( "type" => "string", "length" => 100 ), "ph...