RailsCasts Pro episodes are now free!
Learn more or hide this
class Product < ActiveResource::Base self.site = "http://localhost:3000" end
class Post < ActiveRecord::Base def product @product ||= Product.find(product_id) unless product_id.blank? end end
<p> <%= f.label :product_id %> <%= f.collection_select :product_id, Product.find(:all), :id, :name %> </p>
<% if @post.product %> <strong><%=h @post.product.name %></strong> <% end %>