model

Rails Validation Issue

OK, so I'm really new to Ruby on Rails. I'm using InstantRails, if that is going to make any difference. Here is my problem- I am trying to validate some entries into a form. If I use the form without any validations, then it works fine. If I add the validations, it completely changes the application's behavior and does not work. For ...

Is the string version of every model in Rails a URL?

In the Rails docs, it says this: <%= url_for(@workshop) %> # calls @workshop.to_s # => /workshops/5 Is this because the string version of every model in Rails corresponds to a URL for a particular instance of that model? ...

How to make database field readonly in rails.

Hey folks, I have a database table with a certain field which should be impossible to update once it has been inserted to the database. How do I tell my model that it shouldn't allow updating of a certain field? Best Regards, x3ro ...

Best database design for a "sensor system"

I'm doing a schoolwork and.. I have to do a vehicle tracker system. I thought of these three designs. What do you think? My database schemas (png at ImageShack ~99KB) http://img390.imageshack.us/img390/3781/des.png Opinions? ...

Only one record true, all others false, in rails

Hi, I have the following situation class RecordA has_many :recordbs end class RecordB belongs_to :recorda end RecordA has many recordbs but only one of them may be an active recordb. I need something like myRecordA.active_recordb If I add a new column like is_active to RecordB, then I have the potential problem of setting two r...

LINQ vs. presentation model

Does LINQ substitute the presentation model? I read in the book "ASP.NET MVC in Action" about presentation models. I wonder why to build a presentation model?! For instance, projecting a domain object (entity) by creating a new class at runtime via LINQ is in my opinion more comfortable than creating dozens of presentation objects. ...

Render partial from another model

Hi everyone, I have a rails application that models a house. There is a house model that has many parameters and it has_many rooms. A room has a house_id and a name. I've also used http://github.com/ryanb/complex-form-examples to allow many lights and small_appliances to be added to room. complex-form-example uses RJS and partials to...

Delphi: Good pattern/strategy for view <-> model synchronization

There's a lot of talk about model-view-controller, model-view-viewmodel, model-view-presenter and so on these days. What do you see as the best pattern for use with delphi and non-data aware components? How do you usually implement it? ...

HABTM-Relation : Create a relation for all other records

Hi! If i want to add a record to TABLE A, is there an efficient way to add a record in the JOIN TABLE for many (or all) records in TABLE B? I try to build a simple task management (in CakePHP). An user adds a task and there will be added a connection to each other user in the same group as the current user. At the moment, I use th...

How do I make an exact duplicate of a Core Data object graph?

I need to make a duplicate of an existing object graph from one NSManagedObjectContext and insert it into a second NSManagedObjectContext. Is there a straightforward way to do this? From what I can tell I could ask the MOC for its -registeredObjects and then do something like this to copy the attributes: NSString* entityName = [[...

Checking Model relationships in CakePHP

Is there a way to check CakePHP's model relationships? One model is saving twice on a table and I really suspect there's something wrong with my relationships. Problem is I have a lot of tables so it's really a pain. I'm wondering if there's a more sure and easy way of doing this maybe automatically? Thanks in advance! ...

Proper design a Model-Controller in Cocoa?

Hi, I'm trying to design a simple Cocoa application and I would like to have a clear and easy to understand software architecture. Of course, I'm using a basic MVC design and my question concerns the Model layer. For my application, the Model represents data fetched on the Internet with a XML-RPC API. I'm planning to use Core Data to re...

Cannot implicitly convert type 'System.Linq.IQueryable<Project.Models.TaskTimeLine>' to 'Project.Models.TaskTimeLine'.

I'm trying to pass a custom shaped class to a view, but I'm having a little trouble. This is the error I'm getting. Cannot implicitly convert type 'System.Linq.IQueryable' to 'Project.Models.TaskTimeLine'. An explicit conversion exists (are you missing a cast?) This is the first time I've added a list to a class, and trying to pass on...

Django: How to model a MySQL VARBINARY HEX Field? (solved)

I am trying to model a VARBINARY MySQL field in Django v1.1.1. The binary field stores a hexadecimal representation of data (i.e. one would use INSERT INTO test(bin_val) VALUES X'4D7953514C') Reading the Django documentation[1] I came up with this sollution: class MyTest(models.Model): bin_val = BinValField() class BinValField(mod...

Understanding Ruby on Rails ActiveRecord model Accessors

Hey there, I'm currently learning RoR and I've got the following problem: My Model, "DataFile", has a bunch of fields which I'd like to set from outside the Model, e.g. file = DataFile.new file.owner = 123 Now, as far as I know, I'd have to place an "attr_accessor :field" in my model, for every field that I'd like to modify from ou...

How to obtain current action from within model in RoR?

I found some information to get action_name within the controller, but I need to know what it is inside my model. I'm kind of second guessing myself and wondering if that's at all something you would need or could get from being within the model, but I'm not sure. Please let me know if there's a way to get something like action_name with...

How to implement Active Record inheritance in Ruby on Rails?

How to implement inheritance with active records? For example, I want a class Animal, class Dog, and class Cat. How would the model and the database table mapping be? ...

Error in getting values from XML file to array Collection in Flex

I am trying display values in a datagrid in my application. I have all the values as an xml file. I had only one set of record n the XML file, to fill only one row of the data grid. While trying to store the values from the XML file to an Array Collection in the application File using the code, i.e., <mx:Model id="reviewList" source="...

Handling circular data in Oracle's SQL

Hi everyone, There is a problem that don't know how to resolve only with SQL (I could do it with PL/SQL, but it should be doable only with SQL). I have a table (in fact it's not a table but the result of a with query) with contains pair of values like this: column1 column2 --------- --------- value1 value2 value1 ...

Many-to-many relation with attributes in refClass

Hello, I'm currently designing a website, using symfony (1.2) with Doctrine as an ORM. I have a Dinner class, a Criteria class, and a Mark class. A Mark is linked with a Dinner and a Criteria, and has private attributes, like DateOfMark, MarkValue, etc. Dinner and Criteria can have many Marks (or none). As I use Doctrine, I defin...