Search Results

Search found 6420 results on 257 pages for 'mathieu parent'.

Page 60/257 | < Previous Page | 56 57 58 59 60 61 62 63 64 65 66 67  | Next Page >

  • Does anybody have any tips for managing polymorphic nested resources in Rails 3?

    - by Ryan
    in config/routes.rb: resources posts do resources comments end resources pictures do resources comments end I would like to allow for more things to be commented on as well. I'm currently using mongoid (mongomapper isn't as compatible with rails3 yet as I would like), and comments are an embedded resource (mongoid can't yet handle polymorphic relational resources), which means that I do need the parent resource in order to find the comment. Are there any elegant ways to handle some of the following problems: in my controller, I need to find the parent before finding the comment. if params[:post_id] parent = Post.find(params[:post_id] else if params[:picture_id] parent = Picture.find(params[:picture_id] end which is going to get messy if I start adding more things to be commentable also url_for([comment.parent,comment]) doesn't work, so I'm going to have to define something in my Comment model, but I think I'm also going to need to define an index route in the Comment model as well as potentially an edit and new route definition. There might be more issues that I have to deal with as I get further. I can't imagine I'm the first person to try and solve this problem, are there any solutions out there to make this more manageable?

    Read the article

  • LIMIT amount of rows fetched by JOIN

    - by user892134
    How do i LIMIT the child rows fetched to only 5? Here is the SQLfiddle http://sqlfiddle.com/#!2/bd96a/2. Right now it fetches all rows with parentid='4' and parentid='14'. It should only fetch 5 of each parentid. Assuming i have hundreds of rows, it should only fetch a max of 5 for each parentid. "SELECT child.* FROM mytable as parent LEFT JOIN mytable as child on child.parentid=parent.id WHERE parent.pageid IN ( 1, 2) AND parent.submittype='1' ORDER BY child.id ASC"; How do i solve this?

    Read the article

  • Many to many self join through junction table

    - by Peter
    I have an EF model that can self-reference through an intermediary class to define a parent/child relationship. I know how to do a pure many-to-many relationship using the Map command, but for some reason going through this intermediary class is causing problems with my mappings. The intermediary class provides additional properties for the relationship. See the classes, modelBinder logic and error below: public class Equipment { [Key] public int EquipmentId { get; set; } public virtual List<ChildRecord> Parents { get; set; } public virtual List<ChildRecord> Children { get; set; } } public class ChildRecord { [Key] public int ChildId { get; set; } [Required] public int Quantity { get; set; } [Required] public Equipment Parent { get; set; } [Required] public Equipment Child { get; set; } } I've tried building the mappings in both directions, though I only keep one set in at a time: modelBuilder.Entity<ChildRecord>() .HasRequired(x => x.Parent) .WithMany(x => x.Children ) .WillCascadeOnDelete(false); modelBuilder.Entity<ChildRecord>() .HasRequired(x => x.Child) .WithMany(x => x.Parents) .WillCascadeOnDelete(false); OR modelBuilder.Entity<Equipment>() .HasMany(x => x.Parents) .WithRequired(x => x.Child) .WillCascadeOnDelete(false); modelBuilder.Entity<Equipment>() .HasMany(x => x.Children) .WithRequired(x => x.Parent) .WillCascadeOnDelete(false); Regardless of which set I use, I get the error: The foreign key component 'Child' is not a declared property on type 'ChildRecord'. Verify that it has not been explicitly excluded from the model and that it is a valid primitive property. when I try do deploy my ef model to the database. If I build it without the modelBinder logic in place then I get two ID columns for Child and two ID columns for Parent in my ChildRecord table. This makes sense since it tries to auto create the navigation properties from Equipment and doesn't know that there are already properties in ChildRecord to fulfill this need. I tried using Data Annotations on the class, and no modelBuilder code, this failed with the same error as above: [Required] [ForeignKey("EquipmentId")] public Equipment Parent { get; set; } [Required] [ForeignKey("EquipmentId")] public Equipment Child { get; set; } AND [InverseProperty("Child")] public virtual List<ChildRecord> Parents { get; set; } [InverseProperty("Parent")] public virtual List<ChildRecord> Children { get; set; } I've looked at various other answers around the internet/SO, and the common difference seems to be that I am self joining where as all the answers I can find are for two different types. Entity Framework Code First Many to Many Setup For Existing Tables Many to many relationship with junction table in Entity Framework? Creating many to many junction table in Entity Framework

    Read the article

  • problem with the drop down menu with jquery

    - by amir
    Hi Basically I have some links which include some other links, I'm trying to show the parent links only and when one clicks on the parent link the child links should appear and when one clicks on the parent link again the child link should disappear, the code works for the first click and it opens the relevant child links but how do I make them disappear when I click on the parent link again, thanks for the help. jQuery.noConflict(); jQuery(document).ready(function(e) { jQuery('.nav-container ul.level0 li.level1 a').click(function(e) { e.preventDefault(); jQuery(this).css({'background':'#000000','color':'#ffffff'}); jQuery('.nav-container ul.level0 li.level2 a').css('display','block'); }); });

    Read the article

  • JQuery: Read each line of an element

    - by Sarfraz
    Hello, Suppose I have this html markup: <div id="wrapper"> $(function(){ // hide all links except for the first $('ul.child:not(:first)').hide(); $("a.slide:first").css("background-color","#FF9900"); $('ul.parent a.slide').click(function(){ $('ul.parent a.slide').css("background-color","#3399FF"); $('ul.parent a.slide').mouseout(function(){ $(this).css("background-color","#3399FF"); }); $('ul.parent a.slide').mouseover(function(){ $(this).css("background-color","#66CC66"); }); }); }); </div> What is the easiest way to read each line of code present in the div. How do I extract each line of code from that div or loop over each line styling in any way I want. Thanks

    Read the article

  • Google sites creation

    - by bhuvi
    Hi, I am creating a sites by java programming using google sites API developer guide. I had easily created different type of pages as parent page and sub pages also. my problem is,I am not able to create a web page as parent page and file cabinet, announcement, list page as sub page. That's parent page and sub page is created as same not as different page. please tell me a solution.

    Read the article

  • Qt "no matching function for call"

    - by Blin
    I have no matching function for call to 'saveLine::saveLine()' error when compiling my application. The construcor is never actually called. saveLine class definition: class saveLine { public: saveLine(QWidget *parent); private: QPushButton *selectButton, *acceptButton; QLabel *filePath; QLineEdit *allias; }; saveLine is used in another class which is defined as follows: class MWindow : public QWidget { Q_OBJECT public: MWindow(QWidget *parent=0); private: saveLine line1; }; error points to MWindow constructor implementation MWindow::MWindow(QWidget *parent):QWidget(parent) { this->setWindowTitle("Launcher"); this->resize(600,600); } What should i do? I intend to use saveLine class in a vector, to create lines at runtime.

    Read the article

  • So where is this calling super?

    - by dontWatchMyProfile
    From the Core Data docs: Inheritance If you have two subclasses of NSManagedObject where the parent class implements a dynamic property and its subclass (the grandchild of NSManagedObject) overrides the methods for the property, those overrides cannot call super. @interface Parent : NSManagedObject @property(nonatomic, retain) NSString* parentString; @end @implementation Parent @dynamic parentString; @end @interface Child : Parent @end @implementation Child - (NSString *)parentString { // this throws a "selector not found" exception return parentString.foo; } @end very, very funny, because: I see nobody calling super. Or are they? Wait... parentString.foo results in ... a crash ??? it's a string. How can that thing have a .foo suffixed to it? Just another documentation bug?

    Read the article

  • Having a UITextField in a UITableViewCell

    - by Mathieu
    Hi! I'm trying to do that for a couple of days now, and after reading tons of messages of people trying to do that too, I'm still unable to have a fully working UITextField in some of my UITableViewCells, just like in this example: http://img231.imageshack.us/img231/4858/picture4za3.png Either I have the form working but the text is not visible (although I set its color to blue), the keyboard goes on the field when I click on it and I haven't been able to correctly implement the keyboard events. I tried with a bunch of examples from Apple (mainly UICatalog, where there is a kinda similar control) but it's still not working correctly. Can somebody help me (and all the people trying to realize this control) and post a simple implementation of a UITextField in a UITableViewCell, that works fine? Thank you very much.

    Read the article

  • I'm following Qt Tutorials and got a simple question

    - by nzer0
    If I want to create my own class MyWidget which inherits from QWidget Tutorial tells me to write constructor like this... MyWidget::MyWidget(QWidget *parent) : QWidget(parent){....} I'm wondering what is the role of : QWidget(parent) Does it mean explicit call for QWidget's constructor?

    Read the article

  • Display Wordpress Category

    - by saorabh
    I want to display only the those parent category name and with their child category.. Example category AAAAA,BBBB,CCCCC,DDDDD Parent category AAAAA having child category a,b,c Parent category BBBB having child category x,y,z Now I want to display only (Result required) AAAAA a,b,c BBBB x,y,z Please help me...

    Read the article

  • Fast serialization/deserialization of structs

    - by user256890
    I have huge amont of geographic data represented in simple object structure consisting only structs. All of my fields are of value type. public struct Child { readonly float X; readonly float Y; readonly int myField; } public struct Parent { readonly int id; readonly int field1; readonly int field2; readonly Child[] children; } The data is chunked up nicely to small portions of Parent[]-s. Each array contains a few thousands Parent instances. I have way too much data to keep all in memory, so I need to swap these chunks to disk back and forth. (One file would result approx. 2-300KB). What would be the most efficient way of serializing/deserializing the Parent[] to a byte[] for dumpint to disk and reading back? Concerning speed, I am particularly interested in fast deserialization, write speed is not that critical. Would simple BinarySerializer good enough? Or should I hack around with StructLayout (see accepted answer)? I am not sure if that would work with array field of Parent.children. UPDATE: Response to comments - Yes, the objects are immutable (code updated) and indeed the children field is not value type. 300KB sounds not much but I have zillions of files like that, so speed does matter.

    Read the article

  • How to create a dynamic number of possibly children objects using partial views?

    - by NullReference
    I have a parent object that contains a property that is a list of children objects. I'd like to have it so that when the form loads to create the parent object a partial view is used to create the list of child objects. The problem is I have to idea how to have the list of children object populated. I can do one object ok, but a dynamic list of possible children is difficult. Any ideas? @Html.RenderPartial("_CreateChild", Model.Children); public class Parent { private List<Child> _list; public Guid Id { get; set; } public List<Child> Children { get { return _list; } set { _list = value; } } public Parent() { _list = new List<Child>(); } }

    Read the article

  • C++ linked list based tree structure. Sanely copy nodes between lists.

    - by krunk
    edit Clafification: The intention is not to remove the node from the original list. But to create an identical node (data and children wise) to the original and insert that into the new list. In other words, a "move" does not imply a "remove" from the original. endedit The requirements: Each Node in the list must contain a reference to its previous sibling Each Node in the list must contain a reference to its next sibling Each Node may have a list of child nodes Each child Node must have a reference to its parent node Basically what we have is a tree structure of arbitrary depth and length. Something like: -root(NULL) --Node1 ----ChildNode1 ------ChildOfChild --------AnotherChild ----ChildNode2 --Node2 ----ChildNode1 ------ChildOfChild ----ChildNode2 ------ChildOfChild --Node3 ----ChildNode1 ----ChildNode2 Given any individual node, you need to be able to either traverse its siblings. the children, or up the tree to the root node. A Node ends up looking something like this: class Node { Node* previoius; Node* next; Node* child; Node* parent; } I have a container class that stores these and provides STL iterators. It performs your typical linked list accessors. So insertAfter looks like: void insertAfter(Node* after, Node* newNode) { Node* next = after->next; after->next = newNode; newNode->previous = after; next->previous = newNode; newNode->next = next; newNode->parent = after->parent; } That's the setup, now for the question. How would one move a node (and its children etc) to another list without leaving the previous list dangling? For example, if Node* myNode exists in ListOne and I want to append it to listTwo. Using pointers, listOne is left with a hole in its list since the next and previous pointers are changed. One solution is pass by value of the appended Node. So our insertAfter method would become: void insertAfter(Node* after, Node newNode); This seems like an awkward syntax. Another option is doing the copying internally, so you'd have: void insertAfter(Node* after, const Node* newNode) { Node *new_node = new Node(*newNode); Node* next = after->next; after->next = new_node; new_node->previous = after; next->previous = new_node; new_node->next = next; new_node->parent = after->parent; } Finally, you might create a moveNode method for moving and prevent raw insertion or appending of a node that already has been assigned siblings and parents. // default pointer value is 0 in constructor and a operator bool(..) // is defined for the Node bool isInList(const Node* node) const { return (node->previous || node->next || node->parent); } // then in insertAfter and friends if(isInList(newNode) // throw some error and bail I thought I'd toss this out there and see what folks came up with.

    Read the article

  • jaxb: How can I bind nested element

    - by user368532
    There is my xml: <parent> <children> <child>1</child> <child>2</child> </children> </parent> I want to have the following Parent class: @XmlRootElement Parent{ @XmlElement(name="children/child") List<Child> children; } I don't want to have class for element 'children'. How should I map field children ?

    Read the article

  • Any way to make a generic List where I can add a type AND a subtype?

    - by user383178
    I understand why I cannot do the following: private class Parent { }; private class Child extends Parent { }; private class GrandChild extends Child { }; public void wontCompile(List<? extends Parent> genericList, Child itemToAdd) { genericList.add(itemToAdd); } My question is there ANY practical way to have a typesafe List where you can call add(E) where E is known to be only a Parent or a Child? I vaguely remember some use of the "|" operator as used for wildcard bounds, but I cannot find it in the spec... Thanks!

    Read the article

  • Is it possible to modify the value of a record's primary key in Oracle when child records exist?

    - by Chris Farmer
    I have some Oracle tables that represent a parent-child relationship. They look something like this: create table Parent ( parent_id varchar2(20) not null primary key ); create table Child ( child_id number not null primary key, parent_id varchar2(20) not null, constraint fk_parent_id foreign key (parent_id) references Parent (parent_id) ); This is a live database and its schema was designed long ago under the assumption that the parent_id field would be static and unchanging for a given record. Now the rules have changed and we really would like to change the value of parent_id for some records. For example, I have these records: Parent: parent_id --------- ABC123 Child: child_id parent_id -------- --------- 1 ABC123 2 ABC123 And I want to modify ABC123 in these records in both tables to something else. It's my understanding that one cannot write an Oracle update statement that will update both parent and child tables simultaneously, and given the FK constraint, I'm not sure how best to update my database. I am currently disabling the fk_parent_id constraint, updating each table independently, and then enabling the constraint. Is there a better, single-step way to update this content?

    Read the article

  • MFC: 'Gluing' two windows/dialogs together

    - by John
    I'm trying to set something up so my main dialog has one or more child dialogs, and these are glued/docked to the outside of the main dialog - when the main dialog is minimised, the children are too, when main dialog moves, children move with it. I'd tried setting child dialogs as having main dialog CWnd as parent, with CHILD style. But then they get clipped by the parent's boundary. If I set them as POPUP, they can be outside but then don't move with the parent. I'm looking at putting an OnMove handler on the parent dialog, but is there something built-in? And, should child dialogs still be children of the main dialog... I assume they should? This is VS2005 (I think VS2008 has some related functionality so I mention this).

    Read the article

  • ASP.NET MVC2 : DateTime modelbinding via HTTP GET

    - by mathieu
    I'm getting some trouble binding a date from QueryString : I have the following model public class QueryParms { public DateTime Date { get; set; } } And the following controller action : public ActionResult Search( QueryParms query ); I have a form, with a field where I can type my date. If the form is FormMethod.Post, everything is fine, my date is correctly bound to my model. If the form is FormMethod.Get, it is not working anymore. The date is left to the default value (01/01/0001) I think it is a culture issue : When i look into the value provider, the FormValueProvider has a culture property set for my date : {fr-FR}. The QueryStringValueProvider doesn't have the culture property set. Is there a way to set this property ?

    Read the article

  • transform file/directory structure into 'tree' in javascript

    - by dave
    I have an array of objects that looks like this: [{ name: 'test', size: 0, type: 'directory', path: '/storage/test' }, { name: 'asdf', size: 170, type: 'directory', path: '/storage/test/asdf' }, { name: '2.txt', size: 0, type: 'file', path: '/storage/test/asdf/2.txt' }] There could be any number of arbitrary path's, this is the result of iterating through files and folders within a directory. What I'm trying to do is determine the 'root' node of these. Ultimately, this will be stored in mongodb and use materialized path to determine it's relationships. In this example, /storage/test is a root with no parent. /storage/test/asdf has the parent of /storage/test which is the parent to /storage/test/asdf/2.txt. My question is, how would you go about iterating through this array, to determine the parent's and associated children? Any help in the right direction would be great! Thank you

    Read the article

  • Qt - 2 QMainWindow glued - Size of Layout

    - by user1773603
    I have a main window that I center this way in main.cpp : int main(int argc, char *argv[]) { QApplication app(argc, argv); QMainWindow *qmain = new QMainWindow; Ui_MainWindow ui; ui.setupUi(qmain); QRect r = qmain->geometry(); r.moveCenter(QApplication::desktop()->availableGeometry().center()); qmain->setGeometry(r); qmain->show(); return app.exec(); } In this "qmain" main window, I can create another QMainWindow and I try to make stick (or glue I don't know how to say) the two windows. Actually, I would like the right-top corner of the first one to be located at the left-top of the second one. For this, I use the following Ui_MainWindow's member function : void Ui_MainWindow::generate_IC() { qmenu = new QMainWindow; DiskMenu = new Ui_DiskGalMenu; DiskMenu->setupUi(qmenu); setInitialDiskMenuPosition(qmenu, this); qmenu->show(); } and the setInitialDiskMenuPosition : void Ui_MainWindow::setInitialDiskMenuPosition(QMainWindow *MainWindow, Ui_MainWindow *parent) { QSize size = parent->widget->size(); QDesktopWidget* desktop = QApplication::desktop(); int width = desktop->width(); int height = desktop->height(); int mw = size.width(); int mh = size.height(); int right = (width/2) + (mw/2); int top = (height/2) - (mh/2); MainWindow->move(right, top); } But the problem is that I don't get exactly what I want since the centralwidget size "parent- widget-size()" only returns the size of the widget and not the whole "qmain" parent window. So I have a light shift because the borders of the "qmain" window are not taken in account like it is shown below : If I could have access to the size of the whole parent window... If anyone could help me

    Read the article

  • Updating the collections of entities with NHibernate the correct way

    - by karel_evzen
    A simple question regarding how NHibernate works: I have a parent entity that has a collection of other child entities. Those child entities have a reference to the parent entity they belong to. Now I want to implement an Add method to the parent entity that would add a child to it. Should that Add method only add the child to its new parents collection, or should it also update the parent reference of the child or should it also remove the added entity from its previous parents collection? Do I have to do all these things in that method or will NHibernate do something for me? Thanks.

    Read the article

< Previous Page | 56 57 58 59 60 61 62 63 64 65 66 67  | Next Page >