model

Fetching or Deleting Entity from Google App Engine DB with Unicode Property Name

I have an Expando model kind in my App Engine datastore and I'm setting many arbitrary property names. I didn't consider that I couldn't store Unicode property names, and now I'm in a troubling situation where any attempt to fetch entities of this kind, or even deleting them to get rid of the offender get the following error: Traceback ...

How to display error message on model in rails

Hi, I need to display error message on model in rails, my coding on model is like this, if my_address.valid? # I need here the validation error. return nil end I used errors.add("Invalid address") but it is not working please help to solve this problem , ...

Rails variable in model not working

Hello. In my controller, I have this: user.save if user.leveled_up==true flash[:notice]="HOOOORAY!!!" end and in my model I have: before_save :check_xp # .... def leveled_up=(leveled_up) @leveled_up=leveled_up if @leveled_up==true self.statpoints+=5 hp=max_hp end end def leveled_up @le...

Creating a created_by column and association with rails?

Sigh... I feel like a big newbie on this one, so lets say I have a few models: class Question < ActiveRecord::Base has_many :answers belongs_to :user end class Answer < ActiveRecord::Base belongs_to :question has_one :user end class User < ActiveRecord::Base has_many :questions has_many :answers, :through => :questions end...

Geokit and Authlogic, geocoding the users ip address when they create a user

Has anyone done this? I'm confused at how I can make this work, first off I have my user model Geocoding with it works fine in IRB, just can't figure out how to get it to work in my project. Trying to use some examples from the readme here: http://github.com/andre/geokit-rails/tree/master. Anyhow here is what I have: class User < Act...

Unable to modify App Engine entities, except in administration console

I'm experiencing a critical problem with my App Engine datastore, and it seems to be completely immune to debugging: I'm unable to modify entities after constructing them. The problem is even present when working from a console defined in app.yaml that does not share any code with my main application. Here's an example from the console...

Recursive model in Rails

I have a trouble trying to get this working. I have an Item model, and each Item can have other items or nothing. So is this possible or do I need to do some magic? ...

Extensible domain model with NHibernate

I'm currently designing solution where the domain model & the repository can be extended by application plugins. Now, i have come across a few issues that i am listing below. My first issue is making domain model extensible. I was thinking about using inheritance here, but honestly, i have no idea how i can leverage multiple plugin ass...

How to remove Field Names in validates_presence_of on rails Model

How to remove Field Name in validates_presence_of on rails Model for the following coding validates_presence_of :address, :attributes => true, :discard_if => :invalid?, :on => :save, :message=> "Invalid Address" and the Output is Address Invalid address and I don't want Address field in this validation Please Help me to solve th...

Is there a standard model to controller 'ratio' when trying to implement good ASP.NET MVC?

I'm not sure if this question is non-sense or not, please tell me if so. I am wondering do I create my models like one per each table in my database, or do you do one per controller? Is there something I am missing here? From what I read the Model is suppose to be a representation of the real business objects, so would I just want to ma...

Adding a model layer (with caching) for UIWebViews; trouble with UIWebViewNavigationType and shouldStartLoadWithRequest

I'm tinkering with adding a model layer to an iPhone application so that I can serialize/prioritize HTTP requests and selectively cache responses. Thanks to UIWebViewDelegate, the following method makes this fairly straight forward (in theory): - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navi...

Magento - Retrieve products with a specific attribute value

In my block code I am trying to programatically retrieve a list of products that have a attribute with a specific value. Alternately if that is not possible how would one retrieve all products then filter them to just list the products with a specific attribute? ...

django model design questions

I need to store various info about some movies, books, games, and maybe other media. Starting from publisher to disc count in DVD-box. At first i thought about abstract Item model, with children Book, Movie, Game. But it's all hard-coded and not very scalable, i think. What if i would need to add some new item type? Then I've read abou...

How would you model this device?

I'm creating an in-house diagnostics application for a product that has a bunch of individually addressable devices on an I2C bus. The general idea is that I query each device on the bus and obtain a byte array of 'raw data'. The length of the byte array depends on the individual device. I've created an abstract class called 'Form...

How to skip ActiveRecord callbacks?

I have model like this class Vote < ActiveRecord::Base after_save :add_points_to_user ..... end Is it possible to somehow force model to skip calling add_points_to_user when saved? Possibly something like ActiveRecord#delete vs ActiveRecord#destroy? ...

Per-Site User Permissions in Django Admin

In the same way that Articles can have a relationship with Sites (OneToOne/ManyToMany), I'd like to be able to assign a User permission to work on a certain Site (or Sites). ...

Using custom ModelBinder to have strongly typed TPH models in controller actions-- is this smelly?

Here's a little background on my solution: ASP.Net MVC app Using Linq-to-SQL with table-per-hierarchy inheritance Using DataAnnotationsModelBinder as default So I have a Device abstract class and then a series of derived classes (ServerDevice, DiskDevice, PSUDevice, etc) that inherit from it in the proscribed Linq-to-SQL way. I have...

How to require a value is entered in a search form

I built a basic search form that queries one column in one table of my app. I followed episode 37 Railscast: http://railscasts.com/episodes/37-simple-search-form. Note I just posted another search related question, but it's on a completely different issue. In my app, the search queries the zip code column of my profile table, and retur...

Qt model's tree view and table view

I have a list of Product objects ( as rows ), each object has several data fields ( like product id, product family, etc ) - as columns. I managed to create a table model subclassing QAbstractTableModel, and display the datas in a QTableView. What i want is provide a "grouped" view of the model in a tree-like structure. For example I wa...

Simple DB Model

I do not have much experience using frameworks or anything so that leaves me with little experience using Models (MVC). I have no interest whatsoever in using a framework at the moment. I am working on a website and I am trying to model some objects but I'm not sure exactly how I should be designing the class. For instance, right now I ...