Ruby on rails edit form for has_one relation
- by user2900873
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.