【发布时间】:2011-01-11 02:18:10
【问题描述】:
我有两个 RoR3 应用程序:
http://users.domain.localhttp://profiles.domain.local
我创建了“用户/模型/profile.rb”:
class Profile < ActiveResource::Base
self.site = "http://profiles.domain.local"
end
在 'profiles/models/profile.rb' 我有:
attr_accessible :name
我的个人资料的 SQL 表包含以下列:
- 身份证
- 姓名
- user_id
因此,如果我运行Profile.create(:name => "test_name"),则会在http://profiles.domain.local 中创建一个名为“test_name”的新配置文件。
出于明显的安全原因,我不想让“user_id”属性可访问,但我需要在配置文件创建时设置它从“用户”应用程序。
我尝试了很多方法来做到这一点,但我找不到一个简单的解决方案。也许,可以在“profile”应用程序的“attr_accessible”附近使用if 语句来填充来自“user”应用程序的请求。
有人可以帮帮我吗?
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-3 activeresource attr-accessible