0
我有两个模型,僵尸和鸣叫。下面的模式:发送zombie_id来自僵尸#show to Tweet#新(一对多关系)
create_table "tweets", :force => true do |t|
t.string "status"
t.integer "zombie_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "zombies", :force => true do |t|
t.string "name"
t.string "graveyard"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
用下面的关联:
class Zombie < ActiveRecord::Base
has_many :tweets
end
class Tweet < ActiveRecord::Base
belongs_to :zombie
end
在僵尸#秀来看,我添加了一个“新建推”按钮发送它鸣叫#新(new_tweet_path)。在Tweet#新视图中,我有一个包含两个字段的表单:status和zombie_id。当我到达来自Zombie个人资料的Tweet#新页面时,我不想填写zombie_id,或者我希望它知道该ID是什么,因为我刚刚从它的配置文件页。
我需要做些什么才能做到这一点?我假设我需要将Zombie#show页面中的僵尸对象发送到Tweet#新页面,但我不确定在控制器或视图中需要做什么来处理此问题。有什么建议?