model

Better solution than accessing routes in the Model?

So I know that you shouldn't use UrlWriter methods in a model, but I wasn't sure what a better way to handle my current situation is. Basically, I want to allow a User to post something to his facebook feed, and want to write a post_to_fb_feed(object) method in class User. Now, the URL of what is actually posted depends on the object, s...

Best ASP.NET MVC practice to distinguish GET/POST action methods with same signature?

When implementing Edit action, I add two methods for Get and Post: Edit(string id) Ideally, they need have same signature. But of course this is not compilable. So I add a dummy parameter to HttpPost method (form in my case): [HttpGet] public ActionResult Edit(string id) { var user = Entities.Users.SingleOrDefault(s => s.UserID == ...

How to design a portable modularized GUI applications?

There are a lot of flexible, complete, cross-platform, et cetera, graphical user interface frameworks. Most of them provide many tools to turn software development easier. When building a desktop application in Qt environment, for example, one usually would have different file types, headers, implementation files, and user-interface file...

What is threading model in ASP.NET ?

ASP uses STA threading model while ASP.NET uses MTA. What does it mean ? ...

Updating nested params not working.. whats wrong?

Im trying to update some nested params from a form. I can see that the parameters im getting from the form is correct, however the database dont get updated. the view <% form_for @order do |f| %> <% f.fields_for :itemgroups do |ff, i| %> <% ff.fields_for :items do |fff| %> <%= ff.text_field :text, :id => "textField", :disab...

Change default find method in rails

I've read this somewhere but I can't find it now. I'm trying to change the default "find" method on a model from the id to for example the name. So when I map resources to a model it uses the the name instead of the id. I don't remember if this was a parameter in the resources command in the route file or if it was something you added ...

Magento: Custom MySQL query with locks not working

I'm trying to write a function to SELECT the least-recently fetched value from a table in my database. I do this by SELECTing a row and then immediately changing the last_used field. Because this involves a SELECT and UPDATE, I'm trying to do this with locks. The locks are to ensure that concurrent executions of this query won't opera...

Django regex field - unique and without blank spaces

Hello, i have a ModelForm, in which i'm having a CharField, which is declared as unique in the Model. But I have 2 problems: 1.If i fill in the form with a field having the same name i don't get an error message 2.I'd like this field not to contain white spaces Is it possible to do that using a ModelForm? Thanks a lot! ...

asp.net mvc model binding

Hi I am working with asp.net model binding, I have got it working previously with html forms, the problem here is the UI client is going to be a rich client. I have this controller action public ActionResult CreateUser(User profile) previously with html forms, as long as the form html input names matched the name of the properties of...

Duplicate entry when trying to edit a record

When i try to a edit a entry.. its creating a duplicate entry in the database. i have made sure i add an hidden id field when i go to the edit form. Restaurant RestaurantAttribute RestaurantContact these are the models i am using. tried reinitialize the id $this->Restaurant->id = $this->Restaurant->id; strange... in the db the ex...

Using a model as a frontend for a dao

Say I use a simple frontend for information passed on by a DAO that uses JDBC (without ORM). In other words, the class would have no attributes to speak of. Would this considered as a valid approach? What issues could it potentially cause and how could a class be designed to avoid them? ...

ASP.net MVC2 - Customize Metadata without using Custom Attributes

I'm pretty new to MVC, I'm trying to create a model that can be localized, but it doesn't seem like that would be possible given that I have to use a custom property attribute to define displayname and validation properties. Is there a way to dynamically create the model metadata attributes (DisplayName, UIHint, etc..) as opposed to h...

How to apply different validation rule according to polymorphic association type (Rails)?

I have Rails polymorphic model and I want to apply different validations according to associated class. ...

Django. Update data in db. Easy question.

Ok! I have this model: class my(models.Model): name = models.TextField() description = models.TextField() created = models.DateTimeField() def __unicode__(self): return self.name I'm gettin data to this model from mssql database and saving it. Something like this. mysql_name='somedata' #this data come...

Using models in CodeIgniter...

Can somebody explain to me when it's a good practice to use models in CI? An article in wikipedia was referring to CI models as "entirely optional and are rarely needed" is that true in any way?thanks in advance! ...

Problem modelling address generalization

Hello, I’m a bit concerned about how to model this rather simple scenario the best way in UML and ERM. When designed it has to be implemented in C# (Entity Framework 4) and SQL Server 2008. The case is that I have a person, who has a postal address. Now this address can be two types, either a postal box, or a house identifier (house nu...

Google App Engine: KindError - No implementation for kind 'ObjectName'

I'm writing a db.Model class in google app engine that looks something like this: class Cheese(db.Model): name = db.StringProperty() def say_cheese(self): return name + "cheese" For some reason, whenever I run: cheese = Cheese(name = "smelly") print thing.say_cheese() I get a KindError - No implementation for kind 'Chee...

gsub within before_validation method is zeroing out my value

I'm trying to remove dollar signs and commas from my form input (for example, $1,000.00 => 1000.00) I have the following following line in my before_validation method in my model: self.parents_mortgage = self.parents_mortgage.to_s.gsub!('$,','').to_i This is causing any number to be put through to zero out. Is there something wrong w...

How to change the name of a database model and table in Rails?

Lots out there about changing model names only or mapping new models to existing tables, but nothing about renaming both at the same time. For now, I'm starting with the DB table and working my way out with Find/Replace in my code, but I'm surprised there isn't something better or at least someone who's tried it and written about it. ...

how to force to refresh value of model in yii

let's say I have model A with relation to B. When I write: $a = A::model()->findByPK(1); $a->B->doSomething(); and now B may by changed (by other user for instance). When I write: $a->B->doSomething(); it uses old values of B. What I should do to force to refresh value of B before doSomething(). ...