undefined method `model_name' for Project:Class

后端 未结 3 1575
天涯浪人
天涯浪人 2020-12-11 01:59

I\'ve looked through all the related questions but nothing\'s new for me here.

I have a Project controller with \"new\" action

class ProjectsControll         


        
相关标签:
3条回答
  • 2020-12-11 02:03
    class Project < ActiveRecord::Base
    
    0 讨论(0)
  • 2020-12-11 02:17

    just for the record - here is the Railscast for that issue:

    http://railscasts.com/episodes/219-active-model

    0 讨论(0)
  • 2020-12-11 02:23

    if Project is not an active record subclass, you need these and you can use form_for

    class Project
      extend ActiveModel::Naming
      include ActiveModel::Conversion
      def persisted?
        false
      end
      ...
    end
    

    view:

    <%= form_for(@newproject)  do |f| %>
      <%= f.label :name %>:
      <%= f.text_field :description %><br />
    <% end %>
    
    0 讨论(0)
提交回复
热议问题