model

Can I use Struct.new as a Rails model? Or: How to create anonymous structured non-db backed sessions?

Given the following example: class AnonymousSession << Struct.new(:location, :preferences) def valid? ... end def new_record? ... end end While this interface is sufficient to create resourceful form and so on, it fails as soon as I want to save my form data to the session: if session[:user] = AnonymousSession.create(...

accessing data from the model using script/console (Ruby on Rails)

I'm looking to write a Ruby script which I can load into the Rails Console which will access data from the models I have created. I created a model called student using the following command and populated it with data: script/generate scaffold student given_name:string middle_name:string family_name:string date_of_birth:date grade_point...

ASP.NET MVC Model Binding

I was wondering if there was a way to bind the value of an input field straight to the property in the Model through a strongly typed model. For example, let's say my Model is an Address object. I want to be able to say Html.Textbox(Model.Address1.State, "state", Model.Address1.State). So the first parameter would be the explicit prop...

DB Architecture : Linking to intersection or to main tables?

Hi, I'm creating fantasy football system on my website but i'm very confuse about how I should link some of my table. Tables The main table is Pool which have all the info about the ruling of the fantasy draft. A standard table User, which contains the usual stuff. Intersection table called pools_users which contains id,pool_id,user...

IE6 Box Model bug. Spry Sub-Menu displays over my Normal Menu in IE6. Wrong Positioning.

Hello, first of all im a beginner so any descriptive help i would really appreciate. so my spry menu looks fine in every browser except IE6... my website is ritztheatre.net (srry cant post more then one hyperlink) here is a screenshot of what happens when you hover in IE6. any ideas? http://img130.imageshack.us/img130/1612/spryprob.j...

What do you have in your Model class?

What do you have in your model classes. Generally if i use any framework or any library (Zend Framework) , my classes only have variable which is table name . I know that in complicated applications models have lots of thing to do , so i want to know what these jobs are. Maybe instead of using library`s general select function ,you cre...

Get all table names in a Django app

How to get all table names in a Django app? I use the following code but it doesn't get the tables created by ManyToManyField from django.db.models import get_app, get_models app = get_app(app_name) for model in get_models(app): print model._meta.db_table ...

Should I make a DateRange object?

Hi. First question ever. A few of my domain objects contain date ranges as a pair of start and end date properties: public class Period { public DateTime EffectiveDate { get; set; } public DateTime ThroughDate { get; set; } } public class Timeline { public DateTime StartDate { get; set; } public DateTime EndDate { get; set;...

Django: several tables for one model.

I have a model "Messages" which i use to store messages throughout the site. These are messages in discussions, private messages and probably chat. They are all stored in 1 table. I wonder if it will be faster if i spread messages among several models and tables. 1 for chat, one for discussions and so on. So should i keep all message...

Django: Access model through another model

class Project(models.Model): title = models.CharField() class Job(models.Model): name = models.CharField() user = models.ForeignKey(User) project = models.ForeignKey(Project) I have many jobs for each project. How do i get a list of all users of all jobs of a project? I came up with this: users = set() for job in pr...

prepopulate MVC Models with IOC - an alternative to caching?

Hello, I'm considering strategies for a simple-minded CMS implementation for an ASP.NET MVC site. The simple-minded part is that I've abstracted the values used in various partial views, all of which are user controls that share identical CSS layouts. So I'm populating the custom values in the identical partial views from the database ...

Sitemap webpart based on user permissions using object model

Hi All, I have requirement to create a custom sitemap webpart. The webpart should have a misc field in the edit pane where we could set the number of tiers or levels of childnodes. Here the sites in the sitemap should be displayed based on the permissions of the user who have logged in. Your help would be highly appreciated. ...

is there a difference between MyModel.objects.filter(pk=1) and MyModel.objects.get(pk=1) ?

Is there a difference in the result between: MyModel.objects.filter(pk=1) and MyModel.objects.get(pk=1) If there is no difference, then why does the .get() method exist? ...

The model in MVVM: business object or something else?

I'm trying to get to grips with MVVM and so I've read a bunch of articles - most focus on the View -> ViewModel relationship and there's general agreement about what's what. The ViewModel -> Model relationship and what constitutes the Model gets less focus and there's disagreement. I'm confused and would like some help. For example, t...

What are the basic rules for designing class structure to map relational database?

A WPF application should be a visualizer front-end for a ERP database (in fact only small part of it). They are connected trough web services. What are main rules for designing a data model class structure for mapping database tables? For example, should it be a one big flat class with lots of members, or lots of classes representing di...

Model generation for manually entered page in Spring framework

I have to extend some Spring web application, but I'm not very familiar with the framework (however, I have some experience with few other frameworks). I can see that there is "ModelAndView" concept used by the framework. Controller returns both: a model and a view from onSubmit() method. But what to do if a model have to be generated fo...

Flex: Displaying properties from two objects in a datagrid

Previously I post a discussion on this matter on Flex Adobe forum and still don't understand what needs to be done. So, I'll try my luck again on stackoverflow. I'm using drag and drop data binding functionality in flash builder 4 on a data-grid. However, the data I need to show need to be query from another object. <mx:DataGrid id="da...

How do I add a temporary field to a model in Django?

I'm developing a web-app where the user can create multiple related elements and then save those elements to a database. The webapp has no idea of what the primary keys will be in the database so it assigns each element a UUID. These UUIDs are saved with each element in the database. When the webapp sends the data to the webserver to ...

How to get pages.path

I have the following two tables. I want to get all from menus table and also path from pages table. I tried it but I am not able to get the pages.path. Can anyone point out my mistakes please. CREATE TABLE IF NOT EXISTS `pages` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL DEFAULT '', `keywords` varchar(2...

Validation Layer in MVC pattern

Where is the best place to validate data which will be used by model. For example, think about registration form. We have some data which come from registration form. So where is the best place to verify this data.We should check every data by if statements or special validator class, and this means lots of coding, so i want to learn whe...