Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am also having some difficulty trying to figure out what you mean, but between your last question and this one, I think I may understand most of what you are having trouble with.</p> <p>I'm going off the assumption that a 'statistic' is a single table row with columns for each of the 'stats' you are tracking. If that is the case, this should about do it.</p> <pre><code># character.rb class Character &lt; ActiveRecord::Base has_one :statistic end # statistic.rb class Statistic &lt; ActiveRecord::Base belongs_to :character end # characters_controller def show @character = Character.find(params[:id]) end # characters#show.html.erb &lt;h1&gt;&lt;%= @character.name %&gt;&lt;/h1&gt; &lt;%= form_for @character.statistic do |f| %&gt; &lt;fieldset&gt; &lt;label&gt;Statistics&lt;/label&gt; &lt;%= f.text_field :strength %&gt; &lt;%= f.text_field :dexterity %&gt; ... &lt;%= f.submit 'Update' %&gt; &lt;/fieldset&gt; &lt;% end %&gt; # statistics_controller.rb def update @statistic = Statistic.find(params[:id]) if @statistics.update_attributes(params[:statistics]) redirect_to character_path(@statistic.character, :notice =&gt; 'Updated stats' else redirect_to character_path(@statistic.character, :error =&gt; 'Could not update' end end </code></pre> <p>I do think that things would probably be a lot simpler if the character table just had each of the stats directly on that table, so that the form could just be for a character, and you only create form elements on the show page for the stats.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload