Tag: 表单 用于

使用has_one和belongs_to的嵌套路由和form_for和模型

如何使用嵌套路由映射has_one模型以及如何在RESTful数据库之后为/localhost:3000/users/1/profile/new,html.erb添加form_for? 用户有一个个人资料。 楷模 class Profile < ActiveRecord::Base attr_accessible :name, :surname belongs_to :user end class User < ActiveRecord::Base attr_accessible :email, :email_confirmation, :password, :password_confirmation has_secure_password has_one :profile, dependent: :destroy end resources :users do resources :profiles (note: has_one profile) resources :progress_charts resources :calories_journals end 意见/型材/ new.html.erb About You controller:Profiles_controller.rb我发现了两个错误,因为我不太明白为什么它不起作用。 class ProfilesController < ApplicationController def index end def show […]