I am new to rails and I been using asociations for 1-2 weeks with no issues so far, but this time I need to use them from the start.. all the examples online are with "already" data in the data base to create a new record with the associations working.. in my case obviosly if you have no data at all only the scheme and I want to fill in the form and create a new record that will write to the both models associated, but I am trying all possible ways in the console before I even bother with the new.html.erb view and im banging my head. any help will be apreciated here is the info:
class Calendario < ActiveRecord::Base has_many :tareas end class Tarea < ActiveRecord::Base belongs_to :calendario end
ActiveRecord::Schema.define(:version => 20080810072747) do
create_table "calendarios", :force => true do |t| t.date "fecha" t.datetime "created_at" t.datetime "updated_at" t.time "hora" end
create_table "tareas", :force => true do |t| t.integer "calendario_id" t.string "titulo" t.text "cuerpo" t.datetime "created_at" t.datetime "updated_at" end
end
in the console I am trying:
tarea.calendario = Calendario.create tarea.calendario = Calendario.new then the reverse just in case calendario.tarea = Tarea.new calendario.tarea = Tarea.create I as well have try the mothods the association supposed to create with no luck like create_tarea or create_calendario
I know I am doing something very wrong but since I am a noob the mix of info from my book and google search is confusing me even more with alike situation but none just like mine.