ruby - I can't figure out why I'm getting this error in rails app: First argument in form cannot contain nil or be empty error -
ok i've been trying figure out awhile... wan´t render partial in views/users/show.html.erb
this form code in partial want rendered
<%= form_for @addon, :html => {:class => "form-horizontal center"} |f| %> <div class="form-group"> <%= f.label :addon_1, "1.addon:", class: "col-md-4 control-label" %> <div class="col-md-8"> <%= f.text_field :addon_1, class: "form-control" %> </div> </div> <div class="form-group"> <%= f.label :addon_2, "2.addon:", class: "col-md-4 control-label" %> <div class="col-md-8"> <%= f.text_field :addon_2, class: "form-control" %> </div> </div> <div class="form-group"> <%= f.label :addon_3, "3.addon:", class: "col-md-4 control-label" %> <div class="col-md-8"> <%= f.text_field :addon_3, class: "form-control" %> </div> </div> <%= f.submit "submit", class: "btn btn-default btn-primary" %>
i have addon.rb
model , user.rb
model
this addon.rb
model
class addon < activerecord::base belongs_to :user end
and user.rb
model
class user < activerecord::base has_many :addons end
and in users_controller.rb
have, in show
action
def show #@addon = current_user.addons.build @addons = current_user.addons end
i've tried both use @addons
, @addon
both gives errors.
if use @addons
rails gives error first argument in form cannot contain nil or empty
and if try use @addon
rails gives error :unknown attribute 'user_id' addon
am missing here, can't see why shouldn't work, can please advise.
i think not logged in, there no current_user
& @addon
.
Comments
Post a Comment