Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok this is basic and you should be knowing this but still, I will tell you. The question is also vague so I will assume that you have a counter which is a number and a name for the counter. This is how you update any column from scratch.So first create </p> <pre><code> rails generate scaffold counter count:integer name:string </code></pre> <p>After this step. </p> <pre><code> def update @counter = Counter.find(params[:id]) if @counter.update_attributes(params[:counter]) redirect_to @counter, :flash =&gt; { :success =&gt; "Profile updated." } end end </code></pre> <p>After this create a view in edit.html.erb under views:</p> <pre><code>&lt;%= form_for(@counter) do |f| %&gt; &lt;div class="field"&gt; &lt;%= f.label :name %&gt;&lt;br /&gt; &lt;%= f.text_field :name %&gt; &lt;/div&gt; &lt;div class="field"&gt; &lt;%= f.label :count %&gt;&lt;br /&gt; &lt;%= f.text_field :count %&gt; &lt;/div&gt; &lt;div class="actions"&gt; &lt;%= f.submit "Update" %&gt; &lt;/div&gt; &lt;% end %&gt; </code></pre> <p>Go to counter.rb model and do the following:</p> <pre><code>class Counter &lt; ActiveRecord::Base attr_accessible :count, :name end </code></pre> <p>You dont have to add anything in the routes file because it already has the update resource. Now open the browser and if you say </p> <pre><code>localhost:3000/counter/1/update </code></pre> <p>after creating the first counter value then you can update stuff from there. </p> <p>This is how you updating can be done in ruby on rails. If you need more explanation regarding your code you should check the api documentation for rails it is a good start. I am a beginner too. </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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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