Search Results

Search found 523 results on 21 pages for 'associations'.

Page 16/21 | < Previous Page | 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Database error when deleting entry in my rails app.

    - by Danny McClelland
    Hi Everyone...again! I have almost everything in my Rails app working, with the exception of detroying entries. I can destroy entries for companies but not kases and people. The following error show when trying to do so: SQLite3::SQLException: no such column: kases_people.kase_id: SELECT * FROM "kases" INNER JOIN "kases_people" ON "kases".id = "kases_people".kase_id WHERE ("kases_people".person_id = 5 ) I suspect this is an error with the party model for the has_many :through associations that I dont fully understand. You can find an up to date version of the app at www.github.com/dannyweb/surveycontrol Thanks, Danny

    Read the article

  • Joining a one-to-many association with a many-to-many association in Rails 3

    - by Maz
    Hi all, I have a many-to-many association between a User class and a Table class. Additionally, i have a one-to-many association between the User and the Table (one User ultimately owns the table). I am trying to access all of the tables which the user may access (essintally joining both associations). Additionally, it would be nice to do this this with named_scope (now scope) Here's what I have so far: class User < ActiveRecord::Base acts_as_authentic attr_accessible :email, :password, :password_confirmation has_many :feedbacks has_many :tables has_many :user_table_permissions has_many :editableTables, :class_name => "Table", :through => :user_table_permissions def allTables editableTables.merge(tables) end end Thanks.

    Read the article

  • nHibernate query by example with multiple associated objects

    - by BurnWithLife
    I'm trying to use nhibernate's query by example to build dynamic queries. I'm stuck on how to code for an example object with multiple associations. Here's an example from NHibernate in Action. Its a User object with Items. Example exampleUser = Example.Create(u).IgnoreCase().EnableLike(MatchMode.Anywhere); Example exampleItem = Example.Create(i).IgnoreCase().EnableLike(MatchMode.Anywhere); return GetSession().CreateCriteria(typeof(User)) .Add( exampleUser ) .CreateCriteria("Items") .Add( exampleItem ) .List<User>(); If the User object has let's say a Category object as a property, how could I add that in to the above example? If i put another CreateCriteria at the end it refers to the Items, not the User.

    Read the article

  • Is it possible to group validation?

    - by lambdabutz
    I am using a lot of my own validation methods to compare the data from one association to the other. I've noticed that I'm constantly checking that my associations aren't nil before trying to call anything on them, but I am also validating their presence, and so I feel that my nil checks are redundant. Here's an example: class House < ActiveRecord::Base has_one :enterance, :class => Door has_one :exit, :class => Door validates_presence_of :enterance, :exit validate :not_a_fire_hazard def not_a_fire_hazard if enterance && exit && enterance.location != exit.location errors.add_to_base('If there is a fire you will most likely die') return false end end end I feel like I am repeating myself by checking the existence of enterance and exit within my own validation. Is there a more "The Rails Way" to do this?

    Read the article

  • Design review - do you think I'm doing this the right way? First commercial project for me!

    - by Sergio Tapia
    I'm tasked with designing an application that will allow a person to scan a legal document, save that associated with a Name and save it to a database. Now, inside of the Organization, there are many departments, and each department can have many sub departments. Problem lies in that some larger organizations will have many departments and smallers ones will only have 1 or two. I've though about creating a Department table and a Supdepartment table to create associations, etc. That way it's extensible and users can dynamically create departments to fit my program to their organizational scheme. Am I approaching this the right way? As I said, this is my first commercial application so I want to do it right and set a name for myself for delivering things on time and good code for other to expand upon.

    Read the article

  • Building a wiki like data model in rails question.

    - by lillq
    I have a data model in which I would like to have an item that has a description that can be edited. I would like to also keep track of all edits to the item. I am running into issues with my current strategy, which is: class Item < ActiveRecord::Base has_one :current_edit, :class_name => "Edit", :foreign_key => "current_edit_id" has_many :edits end class Edit < ActiveRecord::Base belongs_to :item end Can the Item have multiple associations to the same class like this? I was thinking that I should switch to keeping track of the edit version in the Edit object and then just sorting the has_many relationship base on this version.

    Read the article

  • Visual Studio Config File Editor - Not Formatting

    - by Ian
    Hi All, My VS 2008 seems to be acting a bit weird and the solution is eluding me. The problem is that if I open a config file; app.config or web.config, this looks and behaves as a plain text document. I have no formatting, no coloring, no intellisense and no collapsible or expandable regions. I have reset all setting and restored default file associations. If I go into the setting menu, Text Editor, XML, formatting I see an error "An error occurred loading this property page" Has any one seen this before and have you go a solution. Thanks

    Read the article

  • Table-per-type inheritance insert problem

    - by gzak
    I followed this article on making a table-per-type inheritance model for my entities, but I get the following error when I try to add an instance of a subclass to the database. Here is how I create the subtype: var cust = db.Users.CreateObject<Customer>(); // Customer inherits User db.Users.AddObject(cust); db.SaveChanges(); I get the following error when I make that last call: "A value shared across entities or associations is generated in more than one location. Check that mapping does not split an EntityKey to multiple store-generated columns." With the following inner exception: "An item with the same key has already been added." Any ideas on what I could be missing?

    Read the article

  • keep open windows console after a python syntax error

    - by basweber
    File associations on my machine (winxp home) are such that a python script is directly opened with the python interpreter. If I double click on a python script a console window runs and every thing is fine - as long as there is no syntax error in the script. In that case the console window opens up for a moment but it is closed immediately. Too fast to read the error message. Of course their would be the possibility to manually open a console window and to execute the script by typing python myscript.py but I am sure that there is a more convenient (i.e. "double click based") solution.

    Read the article

  • ActiveRecord Create (not !) Throwing Exception on Validation

    - by myferalprofessor
    So I'm using ActiveRecord model validations to validate a form in a RESTful application. I have a create action that does: @association = Association.new and the receiving end of the form creates a data hash of attributes from the form parameters to save to the database using: @association = user.associations.create(data) I want to simply render the create action if validation fails. The problem is that the .create (not !) method is throwing an exception in cases where the model validation fails. Example: validates_format_of :url, :with => /(^$)|(^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$)/ix, :message => "Your url doesn't seem valid." in the model produces: ActiveRecord::RecordInvalid Exception: Validation failed: Url Your url doesn't seem valid. I thought .create! is supposed throw an exception whereas .create is not. Am I missing something here? Ruby 1.8.7 patchlevel 173 & rails 2.3.3

    Read the article

  • Rails setting OR conditions in validate_presence_of in a model?

    - by Jty.tan
    In a rails model, is it possible to do something like class Example < ActiveRecord::Base #associations validates_presence_of :item_id, (:user_id OR :user_email) #functions end Where the model has 3 columns of :item_id, :user_id, and :user_email? I want the model to be valid as long as I have a :user_id or a :user_email. Idea being that if the item is recommended to a person who isn't currently signed up, it can be associated via email address for when the recommended person signs up. Or is there a different method that I can use instead?

    Read the article

  • CakePHP hasAndBelongsToMany (HABTM) Delete Joining Record

    - by Jason McCreary
    I have a HABTM relationship between Users and Locations. Both Models have the appropriate $hasAndBelongsToMany variable set. When I managing User Locations, I want to delete the association between the User and Location, but not the Location. Clearly this Location could belong to other users. I would expect the following code to delete just the join table record provided the HABTM associations, but it deleted both records. $this->Weather->deleteAll(array('Weather.id' => $this->data['weather_ids'], false); However, I am new to CakePHP, so I am sure I am missing something. I have tried setting cascade to false and changing the Model order with User, User-Weather, Weather-User. No luck. Thanks in advance for any help.

    Read the article

  • CakePHP hasOne ineffeciency?

    - by Andre
    I was looking at examples on the CakePHP website, in particular hasOne used in linking models. http://book.cakephp.org/view/78/Associations-Linking-Models-Together My question is this, is CakePHP using two queries to build the array structure of data returned in a model that uses hasOne linkage? Taken from CakePHP: //Sample results from a $this-User-find() call. Array ( [User] => Array ( [id] => 121 [name] => Gwoo the Kungwoo [created] => 2007-05-01 10:31:01 ) [Profile] => Array ( [id] => 12 [user_id] => 121 [skill] => Baking Cakes [created] => 2007-05-01 10:31:01 ) ) Hope this all makes sense.

    Read the article

  • Generating link path with parameters

    - by fl00r
    Hi. I've got model with many associations. User :has_many = :posts, :videos, :images etc I've got helper method, which receives one of this association draw_chart user.videos def draw_chart(assoc) assoc.each do |a| link_to "update", [a.user, a], :method => :put, :remote => true, :confirm => 'orrly?' end end Problem here is to send extra parameters to update action. For example I want to get this url: /users/1/videos/2?status=done but I am confused how to realize this while I am using [a.user, a] instead of user_videos_path(video, :status => 'done'). But I can't use last, because it can be either videos, or images or anything else

    Read the article

  • Find by include nil object error in rails

    - by SpyrosP
    I've been trying hard to solve this problem but i really don't know what is happening. I have this small piece of code : DiscoveredLocation.find_by_user_id(user.id, :include => [:boss_kills]) The models are : DiscoveredLocation(id, user_id, boss_location_id) BossKill(user_id, monster_id) and associations : Monster belongs_to :boss_location Monster has_many :boss_kills BossKill belongs_to :user BossKill belongs_to :monster DiscoveredLocation belongs_to :user DiscoveredLocation belongs_to :boss_location DiscoveredLocation has_many :monsters, :through => :boss_location DiscoveredLocation has_many :boss_kills, :through => :monsters When i executed the find_by i get this error : NoMethodError in BossesController#index You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.each If i change the include option to any other model, like :monster, it works great. I'm pretty much owned by this problem :P. Maybe somebody can help me ? :)

    Read the article

  • Foreign Key vs. Independent Relationships - is there improvement with Entity Framework 5?

    - by zam6ak
    I have read several articles and questions on concept of foreign key vs independent relationship when using Entity Framework. And I am still not 100% sure which way to go.... I would prefer not to "pollute" my domain POCOs by having a property that will be used in FK relationship when I already have a property reference to "has a" object. My questions are (looking at you @EFTeam, @Ladislav Mrnka) are there any improvements on this subject in the upcoming Entity Framework v5? are there more advantages if I use FK instead of independent associations (particularly with code first)?

    Read the article

  • Rails + simple role system through associative table

    - by user202411
    So I have the Ninja model which has many Hovercrafts through ninja_hovercrafts (which stores the ninja_id and the hovercraft_id). It is of my understanding that this kind of arrangement should be set in a way that the associative table stores only enough information to bind two different classes. But I'd like to use the associative table to work as a very streamlined authorization hub on my application. So i'd also like this table to inform my system if this binding makes the ninja the pilot or co-pilot of a given hovercraft, through a "role" field in the table. My questions are: Is this ugly? Is this normal? Are there methods built into rails that would help me to automagically create Ninjas and Hovercrafts associations WITH the role? For exemple, could I have a nested form to create both ninjas and hcs in a way that the role field in ninjas_hovercrafts would be also filled? If managing my application roles this way isn't a good idea, whats the non-resource heavy alternative (my app is being designed trying to avoid scalability problems such as excessive joins, includes, etc) thank you

    Read the article

  • Querying my JPA provider (Hibernate) for a collection of <Id,Name> of an entity

    - by Ittai
    Hi, I have an entity which looks something like this: Id (PK) Name Other business properties and associations... I have the need for my DAL (JPA with hibernate as provider) to return a list of the entities which correlate to some constraints (or just return them all) but instead of returning the entities themselves I'd like to receive only the Id and the Name properties. I know this can be achieved with HQL/SQL (something like: select id,name from entity where...) but I don't want to go down that road. I was thinking of somehow defining the pair a compositioned part of the entity and thought that might help me but I'm not sure that's "legal" as the Id is the PK. The logic for this scenario is to have a textbox which asynchronously queries the web-service (and through it the DAL) for the relevant entities and once an entity is selected then it is loaded as a whole and shipped to the front-end. Would appreciate any feedback, Ittai

    Read the article

  • How do I create a multiple-table check constraint?

    - by Zack Peterson
    Please imagine this small database... Diagram Tables Volunteer Event Shift EventVolunteer ========= ===== ===== ============== Id Id Id EventId Name Name EventId VolunteerId Email Location VolunteerId Phone Day Description Comment Description Start End Associations Volunteers may sign up for multiple events. Events may be staffed by multiple volunteers. An event may have multiple shifts. A shift belongs to only a single event. A shift may be staffed by only a single volunteer. A volunteer may staff multiple shifts. Check Constraints Can I create a check constraint to enforce that no shift is staffed by a volunteer that's not signed up for that shift's event? Can I create a check constraint to enforce that two overlapping shifts are never staffed by the same volunteer?

    Read the article

  • Accessing individual HABTM records in a form

    - by Pichan
    I'm building a form in my CakePHP project that lets you edit a company's information. Among all other things, every company has at least one geographical area in which the company operates, but it may have more. The areas are selected individually using select dropdowns. The relationship between companies and areas is HABTM, because I need to be able to change the amount of associated areas without modifying the database. Currently the associations and corresponding data are handled separately, which isn't really a problem but I was wondering how it could be done using as much Cake's own 'automagic' functionality as possible?

    Read the article

  • How would you create a notification system like on SO or Facebook in RoR?

    - by Justin Meltzer
    I'm thinking that notifications would be it's own resource and have a has_many, through relationship with the user model with a join table representing the associations. A user having many notifications is obvious, and then a notification would have many users because there would be a number of standardized notifications (a commenting notification, a following notification etc.) that would be associated with many users. Beyond this setup, I'm unsure how to trigger the creation of notifications based on certain events in your application. I'm also a little unsure of how I'd need to set up routing - would it be it's own separate resource or nested in the user resource? I'd find it very helpful if someone could expand on this. Lastly, ajax polling would likely improve such a feature. There's probably some things I'm missing, so please fill this out so that it is a good general resource.

    Read the article

  • User-customizable rails authorization

    - by neutrino
    Hello everyone, Seems there is an abundance of popular declarative-style authorization plugins, which allow you to somehow state in the code that, e.g., this controller action can be accessed by users with such-and-such roles. But what if I need a more dynamic scheme. I want to have an admin area, with a list of all authorizable actions and an ability to assign permissions on actions from the UI. I have ideas how to implement it from scratch, like to define a model corresponding to a controller and/or action and store the permissions via normal associations. Just wonder if there are any ready solutions to this. Thanks a lot

    Read the article

  • undefined method `events' for #<ActiveRecord::Relation:0x4177518> -rails 3.0.3

    - by brg
    I am having this unexplained NoMethodError with undefined method `events' for #. I don't know why since my model association are well defined and the event table has the foreign keys for the user table. I tried using this fix but it failed: Rails 3 ActiveRecord::Relation random associations behavior event.rb class Event < ActiveRecord::Base belongs_to :user attr_accessible :event_name, :Starts_at, :finish, :tracks end user.rb class User < ActiveRecord::Base has_many :events, :dependent = :destroy attr_accessible :name, :event_attributes accepts_nested_attributes_for :events, :allow_destroy = true end schema.rb ActiveRecord::Schema.define(:version = 20101201180355) do create_table "events", :force = true do |t| t.string "event_name" t.string "tracks" t.datetime "starts_at" t.datetime "finish" t.datetime "created_at" t.datetime "updated_at" t.integer "user_id" end end error message NoMethodError in Users#index undefined method `events' for # Extracted source (around line #10): 7: <%= sortable "Tracks" % 8: 10: <% @users.events.each do |event| % 11: <% debugger % 12: 13: <%= event.starts_at % Trace of template inclusion: app/views/users/index.html.erb Rails.root: C:/rails_project1/events_manager Application Trace | Framework Trace | Full Trace app/views/users/_event_user.html.erb:10:in _app_views_users__event_user_html_erb__412443848_34308540_1390678' app/views/users/index.html.erb:7:in_app_views_users_index_html_erb___603337143_34316016_0'

    Read the article

  • Rails ActiveRecord - How to set association save order

    - by Altonymous
    I have a weird relationship that needs to be maintained for legacy processes. I'm trying to figure out how to create the relationship given the new model association. New Relationship Setup Machine has_many MachineReadings has_many Disks has_many DiskReadings Old Relationship Setup Machine has_many MachineReadings has_many DiskReadings has_many Disks The problem is data will come in on the Machine model as nested attributes using the new relationship setup. I need to update the machine_reading_id in the DiskReading model so the old association can continue to be used. I tried doing this via an after_save hook that would traverse back up to the machine and then down to the readings to get the machine_reading.id so I could populate the DiskReading model. However, the associations aren't being saved in the order I would expect. They are saving the Disks & DiskReadings before saving the MachineReadings. So when I go after the machine_reading.id it hasn't been written and thus I am unable to get access to it. For example: #machine_disk_reading.rb after_save :build_old_relationship def build_old_relationship self.machine_reading_id = self.disk.machine.readings.find_by_date_time(self.date_time).id end

    Read the article

  • Best way to fix an out-of-sync TFS workspace after a back-up/restore

    - by DanO
    Wednesday I had to restore from a back-up image I made on Monday. At the time of the snapshot I had about 20 files modified, which I later checked in, and more, on Tuesday. Now that I am back to a snapshot from Monday morning, my workspace has all of these files checked-out or added, etc. even my check-in comments and work-item associations. But I already did that check-in on Tuesday. I'm thinking I will shelve all the pending changes (just in-case), and then just undo all changes, and get latest (specific version). And I should be back to good. Any cautions or suggestions? (TFS 2008, VS2010)

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21  | Next Page >