Ruby on rails edit form for has_one relation
Posted
by
user2900873
on Stack Overflow
See other posts from Stack Overflow
or by user2900873
Published on 2013-10-25T21:39:22Z
Indexed on
2013/10/25
21:54 UTC
Read the original article
Hit count: 144
ruby-on-rails
|activerecord
I have a clan.rb and clan_options.rb
clan.rb
class Clan < ActiveRecord::Base
has_one :options, :class_name => "ClanOptions", :foreign_key => "clan_id", dependent: :destroy
end
clan_options.rb
class ClanOptions < ActiveRecord::Base
belongs_to :clan
end
To create an edit form for clan.rb I use the following:
<%= form_for @clan, :html => {:class => 'form-horizontal'} do |clan| %>
<fieldset>
<!-- form stuff -->
</fieldset>
<% end %>
It works how I want. But now I want to create an edit form for the clan_options.rb, I have no idea how to do this.
If anymore information is needed to solve this, ask me.
© Stack Overflow or respective owner