如何解决未定义的方法`model_name' for 1:Fixnum错误(ruby on rails)

时间:2016-02-16 08:55:12

标签: ruby-on-rails ruby-on-rails-3

单击提交时,应该转到dashboard_contings方法的dashboard_controller。点击我得到这个错误。怎么解决这个

任何帮助都是值得赞赏的

undefined method模型名称' 1:Fixnum`

`enter image description here

我有这样的路线

namespace :generic_users do root to: 'dashboard#show' get 'settings', to: 'dashboard#settings' patch "settings" => "dashboard#update_settings", :as => "update_settings" end

我的仪表板控制器就像这样

class GenericUsers::DashboardController<ApplicationController before_filter :authenticate_user! def settings @title='Generic Users Profile Management Page' @generic_user = current_user.specific.id end def update_settings @generic_user = GenericUsers.find(current_user.specific.id) if @generic_user.update_attributes(sign_up_params) redirect_to generic_users_root_path, flash: {notice: "Your details have been updated"} else render "new" end end private def sign_up_ end private def sign_up_params params.require(:generic_user).permit(:username,:mobile,:firstname,:lastname, :email,:image,:referred_by,:address) end end

在views / dashboard文件夹中,查看调用的文件,  settings.html.erb

&#13;
&#13;
  <%= simple_form_for(@generic_user, :url => generic_users_update_settings_path) do |f| %>
  <div class="form-inputs">
    <%= f.input :username, required: true, autofocus: true %>
    <%= f.input :firstname, required: true, autofocus: true %>
    <%= f.input :lastname, required: true, autofocus: true %>
    <%= f.input :email, required: true, autofocus: true %>
    <%= f.input :mobile, required: true, autofocus: true %>
    <%= f.input :image, required: true, autofocus: true %>
    <%= f.input :referred_by, required: true, autofocus: true %>
    <%= f.label :address, "Address" %><br>
    <%= f.text_area :address, required: true, autofocus: true %>
  </div>

  <div class="form-actions">
    <%= f.button :submit, "Sign up" %>
  </div>
<% end %>
&#13;
&#13;
&#13;

还有一个模型generic_user.rb 请给我一个解决这个错误的方法。 我不知道

1 个答案:

答案 0 :(得分:1)

  

未定义的方法`model_name&#39; 1:Fixnum

您需要更改@generic_user方法中的settings,如下所示

def settings
  @title='Generic Users Profile Management Page'
  @generic_user = GenericUsers.find(current_user.specific.id)
end

simple_form_for中的第一个参数应为 记录