Hey Kristian,

Did you have a chance to look at the code I uploaded
(four_table.zip)?  Also, did you modify the viewhints as well?

Thanks,

Owen

On Sep 14, 8:49 am, Kristian <[email protected]> wrote:
> Today I tried to run through the examples in the "Hobo Book", using
> Hobo 0.8.8.
> I am stuck on page 57 of Chapter 4, where you try to create Many-to-
> Many associations.
>
> I even tried to copy-paste the fields and associations from the book
> directly into recipe.rb, category.rb and category_assignment.rb
>
> category_assignment.rb
> ----------------------
>    fields do
>      timestamps
>    end
>
>   belongs_to  :category
>   belongs_to  :recipe
>
> category.rb
> ----------------------
>   fields do
>     name :string
>     timestamps
>   end
>
>   has_many :recipes, :through => :category_assignments
>   has_many :category_assignments, :dependent => :destroy
>
> recipe.rb
> ----------------------
>   fields do
>       title   :string
>       body    :text
>       timestamps
>     end
>
>   has_many :categories, :through => :category_assignments, :accessible
> => true
>   has_many :category_assignments, :dependent => :destroy
>   belongs_to :country
>
> ---
>
> Even if I rollback to step 1 of my migrations and do a new
> hobo_migration I get the following schema:
>
>   create_table "categories", :force => true do |t|
>     t.string   "name"
>     t.datetime "created_at"
>     t.datetime "updated_at"
>   end
>
>   create_table "category_assignments", :force => true do |t|
>     t.datetime "created_at"
>     t.datetime "updated_at"
>     t.integer  "category_id"
>     t.integer  "recipe_id"
>   end
>
>   create_table "recipes", :force => true do |t|
>     t.string   "title"
>     t.text     "body"
>     t.datetime "created_at"
>     t.datetime "updated_at"
>     t.integer  "country_id"
>   end
>
> ---
> Which look completely fine!
>
> In the interface for New/Edit Recipe, I get a drop-down to select a
> Category, but when I make a selection nothing happens.
> When I make a save, it still says "No category assignments" and when I
> go back to edit, I can see my selection wasn't saved.
> ---
>
> If I look in the console log, I can see this:
>
> Processing RecipesController#update (for 127.0.0.1 at 2009-09-14
> 14:37:50) [PUT]
>   Parameters: {"page_path"=>"recipes/edit",
> "authenticity_token"=>"VJvWuMq34S5pxT4rs1eyRpO2DiI87bpSB0x3BcBxsNc=",
> "id"=>"1-abe", "recipe"=>{"body"=>"Hello", "title"=>"Abe",
> "country_id"=>"1", "categories"=>[""]}}
> --
>
> So obviously, the categories parameter remains empty on submit.
>
> --
> Looking in the HTML source code:
>
> <div class="input select-many categories-tag array recipe-categories"
> name="recipe[categories]">
> <div class="item-proto" style="display: none;">
> <div class="item proto-item">
> <span/>
> <input class="proto-hidden" type="hidden" name="recipe[categories][]"/
>
> <input class="remove-item proto-remove-button" type="button"
> value="Remove"/>
> </div>
> </div>
> <div class="items"> </div>
> <select>
> <option value="">Add Category</option>
> <option value="@1">sour</option>
> </select>
> </div>
>
> ...
>
> So why does the select being generated have no name?
> Has anyone out there really made it through this step?
>
> ---
>
> Kristian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo 
Users" 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/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to