Note that there are some explanatory texts on larger screens.

plurals
  1. POArgumentError, wrong number of arguments
    primarykey
    data
    text
    <p>I'm getting the error</p> <pre><code>ArgumentError in PagesController#home, wrong number of arguments (0 for 1) </code></pre> <p>but I don't know why. I have a <code>Users</code> model from Devise, and a <code>Dplan</code> model, where dplan <code>belongs_to :user</code> and a user <code>has_many :dplans</code>. I'm trying to set up my site so that you can create a new dplan on the home page. My home page view is this: </p> <pre><code>&lt;% if user_signed_in? %&gt; &lt;h1&gt;Hello &lt;%= current_user.name %&gt;! &lt;h1&gt; &lt;%= form_for @dplan do |f|%&gt; &lt;div class="field"&gt; &lt;%= f.text_area :name %&gt; &lt;/div&gt; &lt;div class="actions"&gt; &lt;%= f.submit "Submit" %&gt; &lt;/div&gt; &lt;% end %&gt; &lt;% else %&gt; &lt;h1&gt;DPlanner&lt;/h1&gt; &lt;p&gt; This is the home page for DPlanner. &lt;/p&gt; &lt;%= link_to "Sign up now!", new_user_registration_path, :class =&gt; "signup_button round" %&gt; &lt;% end %&gt; </code></pre> <p>This is dplans_controller.rb: </p> <pre><code>class DplansController &lt; ApplicationController def create @dplan = current_user.dplans.build(params[:dplan]) if @dplan.save flash[:success]="Dplan created!" redirect_to root_path else render 'pages/home' end end def destroy end end </code></pre> <p>And here is pages_controller.rb: </p> <pre><code>class PagesController &lt; ApplicationController def home @title = "Home" @dplan = Dplan.new if user_signed_in? end end </code></pre> <p>I don't understand why I'm getting this error message - the only argument needed on the page is dplan, which I define in the pages controller. Help!</p> <p>Here is dplan.rb:</p> <pre><code>class Dplan &lt; ActiveRecord::Base attr_accessible :name belongs_to :user validates :name, :presence=&gt;true, :length =&gt; { maximum =&gt; 30 } validates :user_id, :presence =&gt;true end </code></pre>
    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