Search Results

Search found 1068 results on 43 pages for 'relation'.

Page 5/43 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Rails fields_for parameters for a has_many relation don't yield an Array in params

    - by user1289061
    I have a model Sensor with has_many and accepts_nested_attributes_for relationships to another model Watch. In a form to update a Sensor, I have something like the following <%= sensor_form.fields_for :watches do |watches_form| %> <%= watches_form.label :label %><br /> <%= watches_form.text_field :label %> <% end %> This is indended to allow editting of the already-created Watches belonging to a Sensor. This call spits form inputs as so: <input name="sensor[watches_attributes][0][label]" ... /> <input name="sensor[watches_attributes][0][id]" ... /> When this gets submitted, the params object in the Sensor controller gets an assoc like "sensor" => { "id"=>"1", "watches_attributes"=> { "0"=>{"id" => "1", "label" => "foo"}, "1"=>{"id" => "2", "label" => "bar"} } } For a has_many, accepts_nested_attributes_for update to work upon the @sensor.update_attributes call, it seems that that attributes key really must map to an Array. From what I've seen in the examples, the combination of has_many, accepts_nested_attributes_for, and sensor_form.fields_for should allow me to pass the resulting params object directly to @sensor.update_attributes and update each related object as intended. Instead the Sensor takes place, with no errors, but the Watch objects are not updated (since "watches_attributes" maps to a Hash instead of an Array?) Have I missed something?

    Read the article

  • Databind Parent/Child relation with Mysql

    - by e2k
    What is the best way to databind parent/child relations? Lets say I have two simple objects: Parent with the following properties, ParentId, Name and Childs and Child with the following properties, ChildId, Name and Parent. I want to write a repository using MySql for this but is failing when I bind both Childs and Parent properties, I have only been able to bind either the Childs property of parent or the Parent property och Child or else I would get a infinite loop. Thinking of it the preferable solution would be to only bind this properties when requested. If I use Linq to sql i would be able to write Parent.Childs[0].Parent.Name but how should I accomplish this with my own repository and with MySql, could anyone point me in the right direction? Looking at the Linq 2 sql generated classes they use EntitySet<Child and EntityRef<Parent could this be used with Mysql? I had a thought of using my IChildRepository in the Parent object and let the Public IEnumerable Childs databind the childs but it seems not right? Best regards E2k

    Read the article

  • Conditional relation

    - by Lowgain
    I've got a model like this: Stem -id -etc And then I have Stemrelation -stem_id -related_stem_id -active I can get the related stems with the following relations class Stem < ActiveRecord::Base has_many :stemrelations has_many :related_stems, :through => :stemrelations end class Stemrelation < ActiveRecord::Base belongs_to :stem belongs_to :related_stem, :class_name => "Stem", :foreign_key => "related_stem_id" end But now I'd only like to get the active relations. I tried adding this to the Stem model: has_many :active_related, :through => :stemrelations, :source => :related_stem, :conditions => {:active => true} but this gives me an error becasue it tries to check the active flag on the stem model instead of the stemrelation. What do I change here? Thanks!

    Read the article

  • log4j/log4cxx : exclusive 1 to 1 relation between logger and appender

    - by Omry
    Using the xml configuration of log4cxx (which is identical in configuration to log4j). I want to have a certain logger output exclusively to a specific appender (have it the only logger which outputs to that appender). I found that it's possible to bind a logger to a specific appender like this: <logger name="LoggerName"> <level value="info"/> <appender-ref ref="AppenderName"/> </logger> but it that logger still outputs to the root appender because I have this standard piece in the conf file: <root> <priority value="DEBUG"/> <appender-ref ref="OtherAppender"/> </root> How can I exclude that logger from the root logger? in other words, how do I configure the log such that all loggers inherit the appenders of the root logger except a specific logger?

    Read the article

  • Rails relation select

    - by Dimitar Vouldjeff
    Hi, I have the following models: class User < ActiveRecord::Base has_many :results, :dependent => :destroy has_many :participants, :dependent => :destroy has_many :courses, :through => :participants end class Course < ActiveRecord::Base has_many :tests, :dependent => :destroy has_many :participants, :dependent => :destroy has_many :users, :through => :participants end class Result < ActiveRecord::Base belongs_to :test belongs_to :user end class Test < ActiveRecord::Base belongs_to :course has_many :results, :dependent => :destroy end The Idea is that a user has_and_belongs_to_many courses, the course has_many tests, and every test has_and_belongs_to_many users (results). So what is the best query to select every Result from a single Course (not test), and also the query to select every Result from a single Course, but from one user. Thanks!

    Read the article

  • Seed has_many relation using mass assignment

    - by rnd
    Here are my two models: class Article < ActiveRecord::Base attr_accessible :content has_many :comments end class Comment < ActiveRecord::Base attr_accessible :content belongs_to :article end And I'm trying to seed the database in seed.rb using this code: Article.create( [{ content: "Hi! This is my first article!", comments: [{content: "It sucks"}, {content: "Best article ever!"}] }], without_protection: true) However rake db:seed gives me the following error message: rake aborted! Comment(#28467560) expected, got Hash(#13868840) Tasks: TOP => db:seed (See full trace by running task with --trace) It is possible to seed the database like this? If yes a follow-up question: I've searched some and it seems that to do this kind of (nested?) mass assignment I need to add 'accepts_nested_attributes_for' for the attributes I want to assign. (Possibly something like 'accepts_nested_attributes_for :article' for the Comment model) Is there a way to allow this similar to the 'without_protection: true'? Because I only want to accept this kind of mass assignment when seeding the database.

    Read the article

  • What is the relation between ContentPane and JPanel?

    - by Roman
    I found one example in which buttons are added to panels (instances of JPanel) then panels are added to the the containers (instances generated by getContentPane) and then containers are, by the construction, included into the JFrame (the windows). I tried two things: I got rid of the containers. In more details, I added buttons to a panel (instance of JPanel) and then I added the panel to the windows (instance of JFrame). It worked fine. I got rid of the panels. In more details, I added buttons directly to the container and then I added the container to the window (instance of JFrame). So, I do not understand two things. Why do we have two competing mechanism to do the same things. What is the reason to use containers in combination with the panels (JPanel)? (For example, what for we include buttons in JPanels and then we include JPanels in the Containers). Can we include JPanel in JPanel? Can we include a container in container?

    Read the article

  • ViewModel Views relation/link/syncroniztion

    - by mehran
    Third try to describing problem: Try 1: Sunchronizing view model and view Try2: WPF ViewModel not active presenter Try3: I have some class for view models: public class Node : INotifyPropertyChanged { Guid NodeId { get; set; } public string Name { get; set; } } public class Connection: INotifyPropertyChanged { public Node StartNode { get; set; } public Node EndNode { get; set; } } public class SettingsPackModel { public List<Node> Nodes { get; private set; } public List<Connection> Connections { get; private set; } } I also have some templates to displays these models: <DataTemplate DataType="{x:Type vm:Node}">…</DataTemplate> <DataTemplate DataType="{x:Type vm:Connection}"> <my:ConnectionElment StartNodeElment="???" EndNodeElment="???"> </my:ConnectionElment> <DataTemplate> But the problem is that DataTemplate for Connection need reference ot two element of type UIElement , how can I pass these two, how can I fill ??? in above expression?

    Read the article

  • Relation many-to-many with attributes : how ?

    - by mada
    Hi, Excuse me for my poor english in advance as it is not my mother tongue. Like in this example: http://www.xylax.net/hibernate/manytomany.html But i have in the table foo-bar 2 attributes which are not part of the primary or foreign keys.: one boolean(A) & one string(B). I know how to map it without attributes but not in this case. I have not found an answer in the documentation. I need to know please how to map it & what kind of collection i have to declare in my class Foo. Thanks in advance for your answer. I really appreciate the time given by you.

    Read the article

  • Rotation of two objects in relation

    - by DMan
    I've got a two sprites- I'll say I have a swing and a person. The swing 'swings' back and forth as I passed a rotation variable into spriteBatch.Draw(). Now I want my person to 'sit' on the swing, and am not sure of how to approach it. Since I want a relative to the swing sprite, I tried personPos=swingPos, but that obviously doesn't work as the swing's position is always the same (it's anchored to a point and swings from there). How would I make the person sprite follow the swinging part of the swing sprite, if that makes any sense?

    Read the article

  • Hbase and 1- Many Relation

    - by Shuja
    Hi All I have one question which can be best described by the following scenario. Suppose I have three tables BaseCategory,Category and products. If i am thinking in terms of RDBMS then the relationship amoung these tables are 1- One BaseCategory has Many categories 2- One Category has Many Products. Now i am thinking to convert it into HBase. can anybody help me how to map these relations into HBase?

    Read the article

  • unique constraint (w/o Trigger) on "one-to-many" relation

    - by elgcom
    To illustrate the problem, I make an example: A tag_bundle consists of one or more than one tags. A unique tag combination can map to a unique tag_bundle, vice versa. tag_bundle tag tag_bundle_relation +---------------+ +--------+ +---------------+--------+ | tag_bundle_id | | tag_id | | tag_bundle_id | tag_id | +---------------+ +--------+ +---------------+--------+ | 1 | | 100 | | 1 | 100 | +---------------+ +--------+ +---------------+--------+ | 101 | | 1 | 101 | +--------+ +---------------+--------+ There can't be another tag_bundle having the combination from tag 100 and tag 101. How can I ensure such unique constraint when executing SQL "concurrently"!! that is, to prevent concurrently adding two bundles with the same tag combination Adding a simple unique constraint on any table does not work, Is there any solution other than Trigger or explicit lock. I come to only this simple way: make tag combination into string, and let it be unique. tag_bundle (unique on tags) tag tag_bundle_relation +---------------+--------+ +--------+ +---------------+--------+ | tag_bundle_id | tags | | tag_id | | tag_bundle_id | tag_id | +---------------+--------+ +--------+ +---------------+--------+ | 1 | 100,101| | 100 | | 1 | 100 | +---------------+--------+ +--------+ +---------------+--------+ | 101 | | 1 | 101 | +--------+ +---------------+--------+ but it seems not a good way :(

    Read the article

  • VendInvoiceJour.InvoiceAccount <- VendTable.AccountNum relation

    - by vukis
    Hi. I have following situation: I need to join VendInvoiceJour.InvoiceAccount <- VendTable.AccountNum and take VendTable.Vendgroup. In all cases (queries,or even views) Dynamics ax joins tables VendInvoiceJour.OrderAccount<- VendTable.AccountNum not VendInvoiceJour.InvoiceAccount <- VendTable.AccountNum. I`m trying to use this kind of query: qBdSVendJour = element.query().dataSourceTable(tablenum(VendInvoiceJour)); qBdSVendTbl = qBdSVendJour.addDataSource(tablenum(VendTable)); qBdSVendTbl.relations(true); qBdSVendTbl.joinMode(JoinMOde::InnerJoin); qBdSVendTbl.fetchMode(QueryFetchMode::One2One); qBdSVendTbl.addLink(FieldNum(VendInvoiceJour,InvoiceAccount),FieldNum(VendTable,AccountNum));//(Dynamics ax automaticaly corrects InvoiceAccount to orderaccount in reports if trying this link in morphx)

    Read the article

  • XForms relation of 'constraint' and 'required' properties

    - by Danny
    As a reference, the most similar question already asked is: http://stackoverflow.com/questions/8667849/making-xforms-enforce-the-constraint-and-type-model-item-properties-only-when-fi The difference is that I cannot use the relevant properties since I do want the field to be visible and accessible. I'm attempting to make a XForms form that has the following properties: It displays a text field named 'information'. (for the example) This field must not be required, since it may not be necessary to enter data. (Or this data will be entered at a later time.) However, if data is entered in this field, it must adhere to the specified constraint. I cannot mark the field as not relevant since this would hide the field and some data may need to be entered in it. The trouble now is that even though the field has no data in it, the constraint is still enforced (i.e. even though it is not marked as 'required'). I have taken a look at the XForms 1.1 specification, however it does not seem to describe how the properties 'required' and 'constraint' should interact. The only option I see, is to add a part to the constraint such that an empty value is allowed. e.g.: . = '' or <actual-constraint However, I don't like this. It feels like a workaround to add this to every such field. Is there any other way to express that non-required fields should not need to match the constraint for that field? (Am I missing something?)

    Read the article

  • django model relation definition

    - by Laurent Luce
    Hello, Let say I have 3 models: A, B and C with the following relations. A can have many B and many C. B can have many C Is the following correct: class A(models.Model): ... class B(models.Model): ... a = ForeignKey(A) class C(models.Model): ... a = ForeignKey(A) b = ForeignKey(B)

    Read the article

  • has_many relation doesn't seems right or logical, some thing like belongs_to_many looks right

    - by Vijendra
    My situation is like this. Company has many users and users may belongs to many companies. And current implementation is something like below. class Company has_many :employments has_many :users, :through = :employments end class Employment belongs_to :company belongs_to :user end class User has_many :employments has_many :companies, :through = :employments #This doesn't looks correct end User has many companies doesn't looks logically meaningful.It must be some thing like belongs_to_many companies. Do I need to use has_and_belongs_to_many? But that also will gives the same meaning. Can some one please suggest the right way for representing these relationships?

    Read the article

  • Using a backwards relation (i.e FOO_set) for ModelChoiceField in Django

    - by Bwmat
    I have a model called Movie, which has a ManyToManyField called director to a model called Person, and I'm trying to create a form with ModelChoiceField like so: class MovieSearchForm(forms.Form): producer = forms.ModelChoiceField(label='Produced by', queryset=movies.models.Person.producer_set, required=False) but this seems to be failing to compile (I'm getting a ViewDoesNotExist exception for the view that uses the form, but it goes away if I just replace the queryset with all the person objects), I'm guessing because '.producer_set' is being evaluated too 'early'. How can I get this work? here are the relevant parts of the movie/person classes: class Person(models.Model): name = models.CharField(max_length=100) class Movie(models.Model): ... producer = models.ForeignKey(Person, related_name="producers") director = models.ForeignKey(Person, related_name="directors") What I'm trying to do is get ever Person who is used in the producer field of some Movie.

    Read the article

  • LINQ parent child relation

    - by Shane Km
    I'm working on the BLOG functionality in MVC. I need to be able to create 'blog comments'. So each comment may have a parent comment etc. Given table "Comments": CommentId - int - identity autoincrement PostId - int ParentId - int Comment - string Is there a way to get a list of comments for a given article ordered by CreateDate and ParentId? Or maybe there is a better table design you may suggest. What is the best design when inserting Post comments like this? I'm using Entity framework. thanks

    Read the article

  • has_many relation doesn't seems right or logical in business perceptive, needed some thing like belo

    - by Vijendra
    My situation is like this. Company has many users and users may belongs to many companies. And current implementation is something like below. class Company has_many :employments has_many :users, :through = :employments end class Employment belongs_to :company belongs_to :user end class User has_many :employments has_many :companies, :through = :employments #This doesn't looks correct end It works, but "user has many companies" doesn't looks logically meaningful. It must be some thing like belongs_to_many companies. Do I need to use has_and_belongs_to_many? Can some one please suggest the right way for representing these relationships?

    Read the article

  • what is the relation between SIGTSTP and SIGCHLD

    - by Rawhi
    I have tow handlers for each one of them (SIGTSTP, SIGCHLD), the thing is that when I pause a process using SIGTSTP the handler function of SIGCHLD run too. what should I do to prevent this . void ExeExternal(char *args[MAX_ARG], char* cmdString, LIST_ELEMENT** pList, int *Susp_Bg_Pid, int *susp) { int pID, status, w; switch (pID = fork()) { case -1: perror("smash error: >"); break; case 0: // Child Process setpgrp(); execv(args[0], args); execvp(args[0], args); perror("error"); exit(EXIT_FAILURE); break; default: if (cmdString[strlen(cmdString) - 1] != '&') { *Susp_Bg_Pid = pID; *susp = 1; while(*susp); } else { InsertElem(pList, args[0], getpid(), pID, 0); } break; } } signal handlers : void signalHandler(int signal) { int pid, cstatus; if (signal == SIGCHLD) { susp = 0; pid = waitpid(-1, &cstatus, WNOHANG); printf("[[child %d terminated]]\n", pid); DelPID(&JobsList, pid); } } void ctrlZsignal(int signal){ kill(Susp_Bg_Pid, SIGTSTP); susp = 0; printf("\nchild %d suspended\n", Susp_Bg_Pid); } Susp_Bg_Pid used to save the paused process id. susp indicates the state of the "smash" the parent process if it is suspended or not .

    Read the article

  • Database schema to store AND, OR relation, association

    - by user455387
    Many thanks for your help on this. In order for an entreprise to get a call for tender it must meet certain requirements. For the first example the enterprise must have a minimal class 4, and have qualification 2 in sector 5. Minimal class is always one number. Qualification can be anything (single, or multiple using AND, OR logical operators) I have created tables in order to map each number to it's given name. Now I need to store requirements in the database. minimal class 4 Sector Qualification 5.2 minimal class 2 Sector Qualifications 3.9 and 3.10 minimal class 3 Sector Qualifications 6.1 or 6.3 minimal class 1 Sector Qualifications (3.1 and 3.2) or 5.6 class Domain < ActiveRecord::Base has_many :domain_classes has_many :domain_sectors has_many :sector_qualifications, :through => :domain_sectors end class DomainClass < ActiveRecord::Base belongs_to :domain end class DomainSector < ActiveRecord::Base belongs_to :domain has_many :sector_qualifications end class SectorQualification < ActiveRecord::Base belongs_to :domain_sector end create_table "domains", :force => true do |t| t.string "name" end create_table "domain_classes", :force => true do |t| t.integer "number" t.integer "domain_id" end create_table "domain_sectors", :force => true do |t| t.string "name" t.integer "number" t.integer "domain_id" end create_table "sector_qualifications", :force => true do |t| t.string "name" t.integer "number" t.integer "domain_sector_id" end

    Read the article

  • sql create view in one to many relation

    - by new to sql
    i want to create a view in a one-to-many relatiom. here is my relations: (a -* b) and (a -* c). i want to create a view to have this data : a1 - (all b's related to a1 + all c's relted to a1) i don't wnat sth like (a1 ,b1,c1 - a1,b1,c2 ,...) how can i create this view ?

    Read the article

  • SQL: find entries in 1:n relation that don't comply with condition spanning multiple rows

    - by milianw
    I'm trying to optimize SQL queries in Akonadi and came across the following problem that is apparently not easy to solve with SQL, at least for me: Assume the following table structure (should work in SQLite, PostgreSQL, MySQL): CREATE TABLE a ( a_id INT PRIMARY KEY ); INSERT INTO a (a_id) VALUES (1), (2), (3), (4); CREATE TABLE b ( b_id INT PRIMARY KEY, a_id INT, name VARCHAR(255) NOT NULL ); INSERT INTO b (b_id, a_id, name) VALUES (1, 1, 'foo'), (2, 1, 'bar'), (3, 1, 'asdf'), (4, 2, 'foo'), (5, 2, 'bar'), (6, 3, 'foo'); Now my problem is to find entries in a that are missing name entries in table b. E.g. I need to make sure each entry in a has at least the name entries "foo" and "bar" in table b. Hence the query should return something similar to: a_id = 3 is missing name "bar" a_id = 4 is missing name "foo" and "bar" Since both tables are potentially huge in Akonadi, performance is of utmost importance. One solution in MySQL would be: SELECT a.a_id, CONCAT('|', GROUP_CONCAT(name ORDER BY NAME ASC SEPARATOR '|'), '|') as names FROM a LEFT JOIN b USING( a_id ) GROUP BY a.a_id HAVING names IS NULL OR names NOT LIKE '%|bar|foo|%'; I have yet to measure the performance tomorrow, but severly doubt it's any fast for tens of thousand of entries in a and thrice as many in b. Furthermore we want to support SQLite and PostgreSQL where to my knowledge the GROUP_CONCAT function is not available. Thanks, good night.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >