Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
What the View and Controller code would be?
2 Posts
What the View and Controller code would be?

I've a User model with username, email and password fields in one of my customized e-commerce site. Now, I want to have a Customer resource with some additional customer-specific infos like shipping address, billing, etc.. so that if the customer revisits the site, his stored Customer infos would be populated in the Checkout action. The User model will have the login credentials but it's not necessary that he will have the Customer model will have the related data. After googling around, I found "this blog post":http://afreshcup.com/2008/10/19/coming-in-rails-22-delegate-prefixes/ which depicts the scenario similar that I'm looking for. But I couldn't figure out how can I accomplish this in my controller and views?? Since the comment is closed on that post, I'm here to get some help. Thanks

In this case you should consider the shipping / billing address as resources too, and related with customer's info. Routing looks like this:

map.resources :customers, :has_many => [:shipping_address, :billing_address]

Following "this link":http://api.rubyonrails.org/classes/ActionController/Resources.html#M000354 for more details.

2 Posts
Login to add your message