So, I think I am on the right track.

I've changed the Use controller create function to be:

  def create
    if (params[:use][:ingredient])
      ingredient = current_user.ingredients.named params[:use]
[:ingredient]
      ingredient = current_user.ingredients.create :name => params
[:use][:ingredient] unless ingredient
      if ingredient.id
        params[:use][:ingredient_id] = ingredient.id
        params[:use].delete :ingredient
      end
    end

    hobo_create
  end

However, I am now getting an exception when the function is called
(though it seems to be working properly)
hobo_create doesn't seem to be returning the ajax properly.

TypeError (can't convert nil into String):
    /vendor/plugins/hobo/hobo/lib/hobo/dryml.rb:82:in `mtime'
    /vendor/plugins/hobo/hobo/lib/hobo/dryml.rb:82:in `page_renderer'
    /vendor/plugins/hobo/hobo/lib/hobo/controller.rb:83:in
`ajax_update_response'
    /vendor/plugins/hobo/hobo/lib/hobo/controller.rb:73:in
`hobo_ajax_response'
    /vendor/plugins/hobo/hobo/lib/hobo/model_controller.rb:533:in
`create_response'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
mime_responds.rb:131:in `call'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
mime_responds.rb:131:in `custom'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
mime_responds.rb:160:in `call'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
mime_responds.rb:160:in `respond'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
mime_responds.rb:154:in `each'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
mime_responds.rb:154:in `respond'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
mime_responds.rb:107:in `respond_to'
    /vendor/plugins/hobo/hobo/lib/hobo/model_controller.rb:531:in
`create_response'
    /vendor/plugins/hobo/hobo/lib/hobo/model_controller.rb:494:in
`hobo_create'
    /app/controllers/uses_controller.rb:18:in `create'



On Nov 25, 11:18 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hello, I am back to Hobo now that it seems a little more stable.
> Excited as always by the new features and shiny, I am trying to get
> autocomplete working.
>
> I have Recipes and Ingredients, that are joined through Uses.  In the
> Recipes show view, I want you to be able to autocomplete ingredients.
> However, each user has their own private list of ingredients.
>
> I've managed to limit the autocompletions list to just a particular
> user's ingredients using scopes:
>     hobo_completions :name, Ingredient.for_user(current_user)
>
> Now the list that shows up while I am typing is right, but if a user
> selects an ingredient with the same name as someone else's ingredient
> with a lower id number, I end up with a Use for the right recipe, but
> to someone elses ingredient with the same name as mine.
>
> I've traced it down to the fact that the form is submitted with "use"
> => {"recipe_id" => 4, "ingredient" => "salt"}
>
> then it tries to recreate the correct ingredient by the name, using
> the hobo function "named" which only searches by name.
>
> Is there an easy way around this?
>
> Also, eventually I'd like you to be able to type in a new ingredient
> in the autocompleter, and have it automatically create that new
> ingredient, and then create the use.  But that is for another
> question.
>
> Thanks!
> -Seth
--~--~---------~--~----~------------~-------~--~----~
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