So I have a create_table like this for Courses at a School:
create_table :courses do |t|
t.string :name
t.references :course
t.timestamps
end
but I want it to reference TWO other courses like:
has_many :transferrable_as #a Course
has_many :same_as #another Course
can I say
t.references :transferrable_as, :as=> :c...
Does EF 4 support unidirectional one-to-many associations, as in:
public class Parent
{
public int Id { get; set; }
public string Something { get; set; }
public List<Child> AllMyChildren { get; set; }
}
public class Child
{
public int Id { get; set; }
public string Anotherthing { get; set; }
// I don't want a back-reference...
I am having trouble accessing the correct information in my rails model (which I believe to be correct) The schema for my tables are
create_table :schools do |t|
t.string :name
t.timestamps
end
create_table :variables do |t|
t.string :name
t.string :category
t.timestamps
end
create_table :data do |t|
t.string...
I have two models/tables in my Rails application: discussions and comments. Each discussion has_many comments, and each comment belongs_to a discussion. My discussions table also includes a first_comment_id column and last_comment_id column for convenience and speed. I want to be able to call discussion.last_comment for the last comment ...
Hi Everyone,
In my rails application I have two models called Kases and Notes. They work in the same way comments do with blog posts, I.e. each Kase entry can have multiple notes attached to it.
I have got everything working, but for some reason I cannot get the destroy link to work for the Notes. I think I am overlooking something tha...
Hi ,
i have 2 entities : ( person ) & (Address)
with follwing mapping :
<class name="Adress" table="Adress" lazy="false">
<id name="Id" column="Id">
<generator class="native" />
</id>
<many-to-one name="Person" class="Person">
<column name="PersonId" />
</many-to-one>
</class>
<class name="Person" table="Pe...
I wish to open a file (lets say, a word document) from a Java application using the associated program installed on the computer (in this example, using MS Word or Open Office Writer).
The catch is that I want to wait until this subprocess finishes, which can be done using the waitFor() method in the Process class.
String executable = ...
I have two models:
Program < ActiveRecord::Base
has_many :events
def federal_financing
events.sum(&:federal_financing)
end
def regional_financing
events.sum(&:regional_financing)
end
def local_financing
events.sum(&:local_financing)
end
end
Event < ActiveRecord::Base
belongs_to :program
# events table h...
Hi Everyone,
I have a model called Kase each "Case" is assigned to a contact person via the following code:
class Kase < ActiveRecord::Base
validates_presence_of :jobno
has_many :notes, :order => "created_at DESC"
belongs_to :company # foreign key: company_id
belongs_to :person # foreign key in join table
belongs_to :survey...
In my project properties I go to publish, options, and file associations and enter ".cms", "Contact manager File" "pqcms" and "1icon.ico", but when I publish and install it does not appear to associate the files...I want to be able to double click on the file and have it open the program but it does not appear to do so.
I believe there ...
I have a User model that has many fights. Fight belongs to User.
There are two foreign keys in the fight table that reference back to the user PK -- challenger_id and challengee_id.
The trick is how do I write the has_many association on the User model so that it returns fights where user_id = challenger_id or challengee_id?
...
I have three tables : Units, Offers and Agents with following associations
Unit hasMany Offers
Offer belongsTo Agent
When I paginate Unit table I get all the units and all the corresponding Offers for each unit , but not the Agent that offer belongs to.
Ex:
Unit1
offer1
offer2
Unit2
offer1
offer2
offer3
...
And I want t...
I have three models of concern here:
User
Fight
FightPunches
Punches
The associations are as follows:
User has many fights, foreign_key => 'challenger_id or challengee_id'
Fight belongs to challenger, as User
Fight belongs to challengee, as User
Fight has many fight_punches
FightPunches belongs to fight
Fight has many punches, thro...
I'm not quite sure what to do here, here's the situation:
Given these models...
class Post < ActiveRecord::Base
has_many :post_assets
has_many :assets, :through => :post_assets
acts_as_scopeable :assets, :scopes => [:featured]
end
class PostAssets < ActiveRecord::Base
belongs_to :post
belongs_to :asset
# context is so we...
Similar to this question, how do I set a property on the join model just before save in this context?
class Post < ActiveRecord::Base
has_many :post_assets
has_many :assets, :through => :post_assets
has_many :featured_images, :through => :post_assets, :class_name => "Asset", :source => :asset, :conditions => ['post_assets.context ...
In my application I have 2 classes like this:
class City < ActiveRecord::Base
has_many :events
end
class Event < ActiveRecord::Base
belongs_to :city
attr_accessible :title, :city_id
end
If I create city object:
city = City.create!(:name => 'My city')
and then pass parameters to create event like this:
event = Event.create!...
Hi guys,
I'm having a problem with some associations in Rails3.
I have the following associations
InformationCategory :has_many => Informations :has_many => InformationValues
I'm able to succesfully do the following:
Information.first.information_values
=> [#InformationValue..]
I'm also able to do the following:
InformationCateg...
Hi,
When I search a model which "has many" of something else.
For example a blog post has many categories.
When searching for blog post with categories associated, how do I order the associated categories? When the array is returned it ignores the order on the category model and defaults to it's usual id order.
Cheers.
...
Hello,
I'm new to rails and building a small test app on rails3 (beta4).
I am using Authlogic to manage user sessions (setup in a standard fashion as per this tutorial)
I have scaffolded and setup a card model (a post basically), and set up the basic active record associations for a belongs_to and has_many relationship
user.rb
has_m...
I have an Order object to represent a Prospective Order/Receipt. This is an entity. It has an identity.
I have a Writer object to read the Order object's properties and display it nicely.
It is a bit of a chore to have individual getters for all the pieces of the Client's Billing Details.
So, I am thinking of letting the Writer object...