Note that there are some explanatory texts on larger screens.

plurals
  1. PORoR - Scaffolding - unedfined method 'to_sym' for nil:NilClass only an error in the edit method
    text
    copied!<pre><code>undefined method `to_sym' for nil:NilClass </code></pre> <p>I have this error only in my edit page of my nifty_scaffold.</p> <p>This is _form.html.erb</p> <pre><code>&lt;% form_for @progress do |f| %&gt; &lt;%= f.error_messages %&gt; &lt;p&gt; &lt;%= f.label :date %&gt;&lt;br /&gt; &lt;%= f.date_select :date %&gt; &lt;/p&gt; &lt;p&gt; &lt;%= f.label :description %&gt;&lt;br /&gt; &lt;%= f.text_area :description %&gt; &lt;/p&gt; &lt;p&gt; &lt;%= f.label :weight %&gt;&lt;br /&gt; &lt;%= f.text_field :weight %&gt; &lt;/p&gt; &lt;p&gt; &lt;%= f.label :fatpercentage %&gt;&lt;br /&gt; &lt;%= f.text_field :fatpercentage %&gt; &lt;/p&gt; &lt;p&gt; &lt;%= f.label :height %&gt;&lt;br /&gt; &lt;%= f.text_field :height %&gt; &lt;/p&gt; &lt;p&gt;&lt;%= f.submit "Submit" %&gt;&lt;/p&gt; &lt;% end %&gt; </code></pre> <p>This is edit.html.erb</p> <pre><code> &lt;% title "Edit Progress" %&gt; &lt;%= render :partial =&gt; 'form' %&gt; </code></pre> <p>And this is my controller:</p> <pre><code>class ProgressesController &lt; ApplicationController def new @progress = Progress.new end def create @progress = Progress.new(params[:progress]) if @progress.save flash[:notice] = "Successfully created progress." redirect_to progresses_url else render :action =&gt; 'new' end end def edit @progress = Progress.find(params[:id]) end def update @progress = Progress.find(params[:id]) if @progress.update_attributes(params[:progress]) flash[:notice] = "Successfully updated progress." redirect_to progresses_url else render :action =&gt; 'edit' end end def index @progresses = Progress.all end end </code></pre> <p>What could be wrong? I can't seem to find my error :-S. It seems that it: - fetches the data correctly - can't insert the db-values into the "edit view" fields.</p> <p>I'm using :float, :string and :date as data types in the scaffold. </p> <p>Just for the completed post, this is my error: NoMethodError in Progresses#edit</p> <pre><code>Showing app/views/progresses/edit.html.erb where line #3 raised: undefined method `to_sym' for nil:NilClass Extracted source (around line #3): 1: &lt;% title "Edit Progress" %&gt; 2: 3: &lt;% form_for @progress do |f| %&gt; 4: &lt;%= f.error_messages %&gt; 5: &lt;p&gt; 6: &lt;%= f.label :date %&gt;&lt;br /&gt; </code></pre> <p>At line 6 the log of the code ends...</p> <p>Edit: It seems to be an error in my routes.rb. This is currently commented:</p> <pre><code> map.edit_progress "edit_progress", :controller =&gt; "progresses", :action =&gt; "edit" </code></pre> <p>when i uncomment it, it gives an error also in my index view.</p> <p>For some reason, this is called: '<a href="http://127.0.0.1:3001/progresses/1/edit" rel="nofollow noreferrer">http://127.0.0.1:3001/progresses/1/edit</a>', shouldn't it be: '<a href="http://127.0.0.1:3001/progresses/edit/1" rel="nofollow noreferrer">http://127.0.0.1:3001/progresses/edit/1</a>' ? Even though it seem's that the "edit view" is called... Perhaps this is the reason why the values aren't filled in, in my view...</p> <p>What could be my solution?</p>
 

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