search for: create_item

Displaying 2 results from an estimated 2 matches for "create_item".

2006 Mar 16
1
beginner question on active record relationships
...# - name class Item < ActiveRecord::Base belongs_to :user end What is the correct way for creating a new item instance with relationships in place (assuming the current user is available in the current_user instance)? Do you have to manually associate the models like the following? def create_item @item = Item.new(params[:name]) @item.user_id = current_user current_user.items << @item @item.save end -- Posted via http://www.ruby-forum.com/.
2008 Nov 19
2
Where should I put "prerequisite logic"?
Hi there, I have this model called InventoryItem. Every time an InventoryItem is created (through the CharactersController and the create_item action) I need to update others tables and make lookups in other tables, to check if the Character has the prerequisites to actually create the InventoryItem. My problem is that I cannot seem to find a good place to put this logic. I''ve tried to put it in a InventoryItem#validate_on_creat...