Colin Law wrote in post #1001240: > On 26 May 2011 14:51, Caroline M. <[email protected]> wrote: >>>> new/user_products path creating their own products, while on the >>> >>> to indicate that it is an ordinary product rather than a user product, >> >> user_products controller create them as user_products, not products? and >> not be read into the cart then. > > There is no direct relationship between a controller and a model. The > type is up to you. For example, if in user_products controller create > action you say > @product = Product.new( params[:product]) > then it will make a new Product. The fact that the controller happens > to be called user_products_controller is irrelevant to the model it > manages. A froglets_controller can manage Products if you want it to. > >> >>> Then you could use the fact that the user_id is nil >>> to indicate that it is an ordinary product rather than a user product, >>> rather than use a special category. >> >> where would i use this? > > In the controller or view to select which products you wish to view. > Or any other time you wish to select products that are not > user_products. > > Have you worked through the free-to-use-online tutorial > railstutorial.org? Although it may not address your exact requirement > it will introduce you to many useful techniques which will give you > ideas on how to go about things. > > > Colin
Colin, i tried to implement what you said i have all the fields now in one table. im still having a few hiccups with the views and some actions. in products index i want the products created by user_id 1 only to display. user_id 1 is my admin user. on the user_products controller in the index view i want the products of the logged in user only to display, maybe if user_id 1 is logged in they could see all products created by other users. also when i create a product in the user_product new view after i press create it reverts the product back to the products index instead of keeping it in an user_products index view, which is what i want as i have different fields on display for the two different types. so if i click show etc it displays products show view page but what i want for that product is the user_product show view page. dunno if im explainin this too well. thanks again for your help. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

