model

Trying to make comments of comments. How to arrange models?

My :post model is the parent model. Within a post are many comments. And comments have potential of having many more comments, and so forth. I thought I had had this right, but I were to type : Comment.last.comments I get : NoMethodError: undefined method `comments' for #<Comment:0x1053a1ff0> My Models : #comment.rb belongs_to ...

ASP.NET MVC save data between controllers

Hi everyone, another ASP.NET MVC question. Assume the following scenario. You have three controllers: getFirstData getSecondData useFirstData The workflow of your site requires that the user first uses the getFirstData controller, and inputs some data (lets say an int) in the view. I then need to use the second controller (getSecon...

Ruby On Rails User Model for multiple types

I am learning RoR coming from many years of c# and MSSQL. I have picked a project to build a web site for my brother who is a rental property manager. I figured this should be fairly easy as the models should be straight forward, but it think I may be over thinking everything or I’m having trouble letting go of the ‘old’ way. Anyway h...

FormViewModel in MVC for Relations

I am very new to MVC and LINQ.And have some questions. I have a table named users where I am storing "M" or "F" for male and female.There is another table called Genders Which is linked to the Users table.I have Users Model in ASP.NET MVC application.My question is when I show data where should I create a property to convert that "M" to...

Development environment query on some models very slow

Hi there, I am scratching my head over for this issue for last few weeks. My local rails dev environment has been so slow for some reasons. I have production environment working as quick as a bullet on the servers. But with the same code, my dev environment is taking so slow and I have decided to dig into that further. I have found ...

Cakephp "joins" destroys conditions?

A bug has a state and hasandbelongs to many usergroups among other things. Now, when listing the bugs I used the pagination helper and also give the user the ability to filter it by various setting. Works great so far. You can filter it by project, you can filter it by state (via the state_id property of the bug) and by several other it...

Anyone know how to save many objects in one form?

I am trying to save many new objects in a form to one pre-existing parent object. - form_for :parent_object do |f| This is the beginning of my form. And then within it, I would do: - 2.times do - fields_for :child_object do |f| Now if I were to save this, it would render as an ParentObject_Controller Update action which would...

Query Atl transformation HOT

how to create a query using an ATL transformation in accordance with the ATL metamodel (to understand a HOT)? thanks ...

Defining models with Mongoid for this database structure

Hey I'm trying to build a rails 3 app with Mongoid (for MongoDB). What I'm now trying to do: Languages: id (automatically created, right?) name (e.g. English) code (e.g. en_US) Languages_Texts: id (see above...) name (e.g. hello_world) Translations: id (see above...) translation (e.g. Hello, world!) I hope this database sc...

Django convert Model to sql code

Hi, My plan is to be able to dynamically generated sql tables. Since I know django can create sql tables via Models, they must have a function for this. The problem is I can not find this function in the django folder, or maybe I simply don't recognize it. thnx ...

Best practise for adding a bidirectional relation in OO model

I'm struggling to come up with a good way of adding a bidirectional relation in OO model. Let's say there is a Customer who can place many Orders, that is to say there is a one-to-many association between Customer and Order classes that need to be traversable in both directions: for a particular customer it should be possible to tell all...

Testing a model spec that uses an after_create callback

Guys, Here is a model that I'm using, I've simplified it a bit down to the simplest form that still fails my example: class User < ActiveRecord::Base after_create :setup_lists def setup_lists List.create(:user_id => self.id, :name => "current") List.create(:user_id => self.id, :name => "master") end end And I'd like t...

Rails: Adding methods to models to perform checks based on current_user?

I have a model that looks something like this: class Comment < ActiveRecord::Base ... #allow editing comment if it is moderated and the user passed-in #is the one that owns the comment def can_edit?(user) moderated? and user.Type == User and user.id == self.user_id end ... end And a call in a view: <%= link_to 'Show C...

CakePHP: Setting up relationship between two models via a third table

I have the followning tables: Users Organizations Email_Addresses Email_Address_Relations Both Users and Organizations may have email addresses, which are stored in the Email_Addresses table and related to via the Email_Address_Relations table. Structure of Email_Address_Relations id char(36) NOT NULL module varchar(64) NOT NULL DE...

Rails authentication gift list for each user?

Hi Everyone, I am trying to get to grips with the basics of authentication in Rails. To start with I have used the nifty_authentication generator by Ryan Bates. It's helping me learn the basic options for user logins etc. I have a simple application the has a person and gift table in the database. The idea is, each user creates a list...

Is it proper TDD practice to design your model before you write tests, or write tests that design your model?

I am building a DDD system and we have all the requirements on paper for the system already set. There is a disagreement on how we go about building our domain model that I need an opinion on. My preference is to take the requirements and sketch out a basic domain model with the outline for the classes, their properties and behaviors a...

Self-Referential Association has a routing error..

I am following Ryan Bate's tutorial: http://railscasts.com/episodes/163-self-referential-association But my setup is slightly different. I am making comments that are self-referential so that comments can be commented on. The form displays in the view, but when I submit, I get this : Routing Error No route matches "/conversations" ...

MVC Model Design

I am having issues to understand MVC model structure.I have 3 tables connected by Foreign keys. Users,UsersInCommittee,Committees .Tables can be though of as below. User: UserId FirstName Last Name Committees: CommitteeId Name UsersIncommitee: Id UserID CommitteeID ExpirationDate I need to create a Users create , edit , list page so...

Soliciting Rails Association Feedback + Questions from a Noob

hi All, Preface: If you hang out in #rubyonrails on freenode this may sound like an echo to you as i asked it in there 2 days ago. After spending a number of hours researching AR associations, following my discussions in #rubyonrails, i still feel lost so I'm asking here. :) Goal I host a number of blogs. My intent is to create ba...

Magento - Passing data between a controller and a block

Really quick and simple question but I can't find a decent answer to this - What is the best way to pass data from a controller to a block in Magento. Incase it makes a difference, I am loading the layout as follows: $this->loadLayout(array('default', 'myModule_default')); $this->_initLayoutMessages('customer/session') -...