ActiveResource allows you to easily communicate between multiple Rails applications. See how in this episode.
# models/product.rb
class Product < ActiveResource::Base
self.site = "http://localhost:3000"
end
# models/post.rb
class Post < ActiveRecord::Base
def product
@product ||= Product.find(product_id) unless product_id.blank?
end
end
<!-- views/posts/edit.html.erb -->
<p>
<%= f.label :product_id %>
<%= f.collection_select :product_id, Product.find(:all), :id, :name %>
</p>
<!-- views/posts/show.html.erb -->
<% if @post.product %>
<strong><%=h @post.product.name %></strong>
<% end %>
分享到:
相关推荐
第四章读书笔记,(好懵逼,笔记大致就对着概念摘抄下来了,个人理解的话比较少,期待二次读的时候,有更多的个人理解)1,Y86-64直接领结构体系。源可以是立即数
第七章 链接链接是将各种代码和数据片段手机并组合成为一个单一文件的过程,这个文件可以被加载(复制)到内存中执行。静态链接链接可以在编译时由静态编译器完成,为了构
第十一章 网络编程全球 IP 因特网TCP/IP 实际是一个协议族,其中每个都提供不同的功能。把因特网看做一个世界范围的主机集合,满足一下特性:主机集合被映射为
第十二章 并发编程1、基于进程的并发编程这种并发编程方法,每个逻辑控制流都是一个进程,由内核来调度和维护。因为进程有独立的虚拟地址空间,想要和其他流通信,控制流
第一章编译系统分为4个阶段:预处理器--->编译器--->汇编器--->链接器1.预处理阶段:将hello.c编译成hello.i2.编译阶段:将hello.i
6.1. 1 随机访问存储器 6.2 局部性 6.2.3 局部性原则 6.3 存储器层次结构 6.3.1 存储器层次结构中的缓存 6.3.2 存储器层次结构概念
ffmpeg basics ffmpeg basics ffmpeg basics ffmpeg basics ffmpeg basics
Blockchain Basics A Non-Technical Introduction in 25 Steps 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
MPLS BasicsMPLS Basics
Python Basics with Numpy Python Basics with Numpy Python Basics with Numpy
FFmpeg Basics
Stepper Motor Basics
FFmpeg Basics = 119.pdf
The Basics of Cloud Computing
LabWindows CVI BASICS I & II 英文版的都是
An easy introduction to Computational Fluid Dynamics.... Covers the basics - grid generation, numerics, incompressible flow and supersonic flow. Motivates the reader with many examples.
LabVIEWTM Basics I: Introduction Course Manual (498页)
Welcome to HTML Basics. This workshop leads you through the basics of Hyper Text Markup Language (HTML). HTML is the building block for web pages. You will learn to use HTML to author an HTML page to ...
英语原版 MSP430 Microcontroller Basics.pdf
创建基于 phonegap 的应用程序##################basics to start creatign phonegap project ############## phonegap create my-app cd my-app cordova platform add android phonegap 运行 android ############...