Hi all,
I'm having trouble creating a new model row in the database using ActiveRecord in a Sinatra app I'm developing. The object in question is being created without any errors (using save!, no exceptions are raised), but most of the data I specify for the save is not present.
class ProjectMeta < ActiveRecord::Base
attr_accessor ...
I have dilemma about how to organize connection (repository class) to data layer in my application that uses the Entity Framework.
How would you write it? And why?
public class ResearchRepository
{
public Research GetResearch (int id)
{
using (MnijenjeEntities mnijenjeContext = new MnijenjeEntities())
{
...
I'm new to asp.net mvc, but I'm trying to do an funny app with GDI+ and I need to do some image view with asp.net mvc.
I have a Model which has an image property:
namespace DomainModel.Entities
{
public class BackgroundImage
{
// Properties
public Image Image {get; private set; }
public BackgroundImage(...
Hi everyone,
My goal is to allow users of a Rails web app to see all their open sessions on other computers and close/sign out of them remotely. Similar to gmail's "Account activity" page (link found at the bottom of the gmail inbox page).
I can technically achieve this by using the sessions in the database
account_sessions = CGI::Se...
During a recent interview for a front-end developer position I was asked what the box model was. I thought the interviewer was referring to testing (i.e. white box testing, black box testing). I was wrong.
What is the box model, in reference to front-end development?
...
I am writing an application which is used for drawing widgets/menus/controls etc to create application mockups. Each screen is represented as collection of widgets, and each widget is simple class e.g.
class Model(object):
def __init__(self):
self.widgets = []
class Widget(object):
def __init__(self):
self.x, se...
In the following Python code, I get an UnboundLocalError. As I understand it, local functions share the local variables of the containing function, but this hardly seems to be the case here. I recognise that a is an immutable value in this context, but that should not be a problem.
def outer():
a = 0
def inner():
a += 1
...
This has to be simple...
I'm trying to preserve the current date that is already stored in an updated_at field in the DB.
I'm updating a single field value in the same row and then saving but I don't want it to update the updated_at field. I want to preserve the existing updated_at value.
I only want to do this in one, maybe two situa...
I'm working on a new application that is basically a "library" type app similar to iPhoto or iTunes, i.e. the user enters data into the app and it handles storage rather than the user storing files himself. [Skip to last para for the meat of the question.]
What is different about my approach is that I want the user to define the fields ...
When I have a class with a Map member, I don't want to draw a separate class/interface object to represent the Map itself, but I'd prefer to treat the map as if it was a native type, rather than a complex object.
Consider the following example
public class IndexManagerImpl implements IndexManager {
/* ... */
private static Map...
I have a datagridview that is bound to a bindingsource which is in turn bound to the an EDM object. I'm importing objects from a CSV file and wish to add these objects to the EDM context and have the new items show up in my datagridview. However, I do not want the new objects committed to the database until the user indicates the data ...
Hi, I'm currently working on a brownfield application, it's written with winforms,
as a preparation to use WPF in a later version, out team plans to at least use the
MVVM/Presentation model, and bind it against winforms...
I've explored the subject, including the posts in this site (which i love very much),
when boiled down, the main a...
Hello, I'm having some difficulties to sort my results by Date. Is there any special method?
Because I'm doing this right now:
var db = new DB();
var articles = db.Articles;
var orderedArticles = articles.OrderBy(a => a.Date);
return View(orderedArticles.ToList());
Where Date is a datetime field.
And there is no effect for OrderBy(..)...
I'm not interested in answers concerning client side validation or model binding. Really, this question could apply to any data access class library outside of MVC, but the issues are similar, I think.
I'm using the Repository pattern currently for data access with my entities (models). Currently the repositories handle all of the CRU...
Hello there,
I don't know if there is an easy way to do it but basically what I would like to do is:
var highlights = db.Banners.Where(h => h.Category == "highlight").ToList().GetRange(0,4);
I have this model Banners where I have some highlights but I would like to retrieve just 4 random highlights each time in different order.
So th...
Hi gys i am trying to link two entities to one entity which is governing body, estate and repo_document, then a governing body can have repo_document that the estate can also have so i decided to create a join table named document_owner.. but i dont know what to write in their models..i have got this code in my document_owner model..
b...
I am trying to create an intermediate model between two models that I'd like to have a many to many relationship. I am creating an atypical book checkout project and have two models setup Book and Person. I'd like to setup an intermediate model BookCheckOut to track OutDate and ReturnDate.
Dan Singerman provided what looks like the answ...
Can I create a Rails model where the ID auto-increments from 0, not 1? How? Are there any gotchas? I checked here, and it seems I can't:
http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#M001911
If, as it seems, I cannot, is there reason why I can't or shouldn't just manually assign an ID of 0 to ...
I was wondering what the excepted standard is for handling errors in the Model.
Currently I have 'setError' and 'getError' methods that's in use by all my Models.
This means I'm only concerned with whether a call to a method in my Model is true or false. If it's false then I would use $this->model->getError() in my Controller.
Additio...
Hi all,
I'm a jstl newbie so probably this question will sound to you funny.
Anyway, I have a model with a List as property and I'd like to fill this with a list of values (chosen from a list of checkboxes). I'm using the useBean tag in the form-processing jstl page, but doing this:
<jsp:useBean id='subscription' class='Subscription'>...