models

rails model attributes without corresponding column in db

I have some rails models which don't need any persistence, however I'd like rails to think the model actually has attributes x, y, z so when calling methods like to_json in the controller I get them included for free. For example, class ModelWithoutTableColumns << ActiveRecord::Base def x return "Custom stuff here" end There is n...

Correct Model Data Structure? (My 1st Rails App)

I'm about to build my first Ruby on Rails application (and first anything beyond xhtml and css), and I'm looking for some helpful feedback on my model structure. I've included a mockup to help visual the application. The only models I'm sure I need so far are: 1. a movie model (to serve as the main model, named movie so URL's will look...

model (3ds) stats & snapshot in linux

I want to write an app that takes in a model filename via cmd line, create a list of stats (poly count, scaling, as much as possible or maybe the stats that i would like) and to load the model with its textures (with anything else) and draw it from multiple position to save the images as pngs. How would i do this? are there utils i can ...

ASP.NET MVC - Multiple models in a form and model binders

I have a form which needs to populate 2 models. Normally I use a ModelBinderAttribute on the forms post action i.e. [Authorize] [AcceptVerbs("POST")] public ActionResult Add([GigBinderAttribute]Gig gig, FormCollection formCollection) { ///Do stuff } In my form, the fields are named the same as the models pro...

Cycling through array of objects within view in Rails: unexpected behaviour

Hi. I've got a simple calendar displaying some events, that's not quite giving me the expected results. Here's the code: <!-- Begin Calendar --> <%= calendar(:year => @year, :month => @month, :first_day_of_week => 1) do |d| output = [] output << render_calendar_cell(d.mday) if d.wday == 1 @garden.plants.collect do |p|...

Django linked models - available fields in admin

I'm building a website for a friends's art exhibition. I currently define a model called Participant, every participant should also be able to log in to the system, so when a Participant is created a new User is also created. Now when editing or creating a new Participant, I would like to be able to display certain fields from User suc...

Refactoring in model: what's going wrong?

I'm currently trying to DRY up this initial verbose code: def planting_dates_not_nil? !plant_out_week_min.blank? || !plant_out_week_max.blank? || !sow_out_week_min.blank? || !sow_out_week_max.blank? end def needs_planting?(week) if !plant_out_week_min.blank? && !plant_out_week_max.blank? (plant_out_week_min..plant_out...

Freely available 3D graphics resources

I'm primarily a programmer and always have the same issue when starting new projects: I have no artistic bone in my body. But you can't always afford an artist. What resources can I use for graphics? I'm primarily looking for free 3D models in various file types. They don't have to be elaborate, but should work for rapid prototyping....

I get "parent_id may not be NULL" when creating my Django model

I'm creating my own Group model; I'm not referring to the builtin Group model. I want each hroup to be a member of another group (it's parent), but there is the one "top" group that doesn't have a parent group. The admin interface won't let me create a group without entering a parent. I get the error personnel_group.parent_id may not be...

Creating Models in ASP.NET MVC

I'm just starting a project in ASP.Net MVC with LINQ to Entities and I was wondering if there was a nice, clean way of defining models that creates the appropriate tables in the database for me. I'm most familiar with Django (in terms of MVC frameworks) and am looking for the .Net equivalent of models.py so I can have everything versione...

Rails CRUD Parameters Issue

So my background is in Java web services, but I'm trying to make the move to ROR. I'm using FlexImage to handle image uploading and thumbnail generation. I followed the guide and CRUD behavior was working fine at one point. However, at some point, CRUD behavior for one of my models (Images) was broken. The error code I'm getting back...

Why use a web framework (like rails) over php?

This isn't a question about what framework to use. I've learned both Rails and Django, and I write all of my webapps in PHP. My question is why bother with the frameworks? It's always taken me longer to use a framework than to reuse old MySQL code and build "models" with phpMyAdmin. I also like writing everything myself, because I know w...

How can I get an accurate absolute url from get_absolute_url with an included urls.py in Django?

I've building a app right now that I'm trying to keep properly decoupled from the other apps in my Django project (feel free to lecture me on keeping Django apps decoupled, I'd be happy to learn more any/all the time). My problem is this: The get_ absolute_url() method I've written is returning a relative path based on my view. I think ...

(Ruby,Rails) CRUD nested models more than 4 levels deep on a single page...?

Hi All, As much amazing info as is out there, it often seems to fall just short of my demented requirements. That said, I'm looking for a mechanism by which to handle multiple nested models on a single page. Now, I've seen all the videos and posts (not really, but humor me) on nesting two models (Railscasts, etc.). However, I need to...

rails models

i have a model named test.rb and when i use @tests=Test.new in my controller i get the following error. Can someone temme how can i resolve this? "undefined method `new' for Test:Module" ...

Django reading old model?

I changed the model, synced the db, and now when i do: Prs = Products.objects.filter(PrName__icontains='bla') I get the error: ERROR: column search_products.pr_name does not exist LINE 1: SELECT "search_products"."id", "search_products"."pr_name", ... But pr_name was the old model, this is how the new model looks like: class ...

Django Relational database lookups

I cant figure out how to do relationships. I have a products model and a stores model. A product has a foreign key to the stores. So i would like to get the product name, and the store name in the same lookup. Since the products model is: class Products(models.Model): PrName = models.CharField(max_length=255) PrCompany = models....

Django pre_save signal called when commit=False

I am writing a Django application that will track changes to the models, in a similar way to the admin interface. For example, I will be able to display a list of changes to a model, that look something like Changed Status from Open to Closed. I am using the pre_save signal to do this, comparing the relevant fields between the existing ...

(Rails) Architecting a multi-model controller and index view...?

Hi All, I'm currently managing multiple models from a single SITE MANAGER page. I have the following relationships: Sites -> Buildings -> Meters -> Values Beside each "Sites" item I have "Edit | Delete | Add Building" Beside each "Building" item I have "Edit | Delete | Add Meter" Beside each "Meter" item I have "Edit | Delete | Add ...

How to make a Django ImageField save the image to another model?

I have a member profiles application that stores simple information about members of a team. Part of the profile is an image to be used as an avatar. I've been using Photologue to create standard galleries of photos, but it has an ImageModel that can be extended to take advantage of Photologue's resizing and caching functionality. The...