rails 3 undefined method `model_name' for ActiveRecord::Relation:Class.
rails 3 form_for 的问题
undefined method `model_name' for ActiveRecord::Relation:Class.
def edit @office = Office.where("id = ? AND company_id = ?", params[:id], @company.id )end
<%= simple_form_for @office, :url => settings_office_path, :html => { :class => "office_form" } do |f| %> <h1>Edit <%= @office.office_name %> Details</h1> <%= render :partial => 'form', :locals => { :f => f } %><% end %>
@office = Office.where(:company_id => @company.id).find(params[:id])@office = @company.offices.find(params[:id])
class Event < ActiveRecord::Base belongs_to :user attr_accessible :event_name, :Starts_at, :finish, :tracksend
class User < ActiveRecord::Base has_many :events, :dependent => :destroy attr_accessible :name, :event_attributes accepts_nested_attributes_for :events, :allow_destroy => trueend
ActiveRecord::Schema.define(:version => 20101201180355) do create_table "events", :force => true do |t| t.string "event_name" t.string "tracks" t.datetime "starts_at" t.datetime "finish" t.datetime "created_at" t.datetime "updated_at" t.integer "user_id" endend
@users = User.find(<conditions go here>)#要变成@users = User.where(<conditions go here>).all#或者如下@users = User.where(:admin => true).where('created_at > ?', min_date).order('created_at').limit(10).all