2013.08.19 Monday
スポンサーサイト
一定期間更新がないため広告を表示しています
| - | | - | -
<%= image_tag url_for_file_column(@user, :image, "large") unless @user.image.blank? %>
<%= image_tag url_for_file_column(@user, :image, "large") if @user.image %>
create_table :animals do |t|
t.string :species
end
create_table :hunts do |t|
t.integer :predator_id
t.integer :prey_id
t.integer :capture_percent
end
class Animal < ActiveRecord::Base
has_many :pursuits, :foreign_key => 'predator_id',
:class_name => 'Hunt',
:dependent => :destroy
has_many :preys, :through => :pursuits
has_many :escapes, :foreign_key => 'prey_id',
:class_name => 'Hunt',
:dependent => :destroy
has_many :predators, :through => :escapes
end
class Hunt < ActiveRecord::Base
belongs_to :predator, :class_name => "Animal"
belongs_to :prey, :class_name => "Animal"
end
id | name |
---|---|
1 | "ME" |
id | user_id | message |
---|---|---|
1 | 1 | "メッセージです" |