Did place a hidden field inside your form to transfer the project_id
back to your app?
ie,
<form with="&@project.custodians.build">
<select ..../>
<input type="hidden" name="#{param_name_for_this}[project_id]"
value="&@project.id"/>
</form>
Bryan
Montgomery Kosma wrote:
> Kevin - thanks for the tip, but I don't see how that could be right.
> Here's the basics on the associations:
>
> class Project
> has_many :project_custodians
> has_many :custodians, :through => :project_custodians
> ...
> class Custodian
> has_many :project_custodians
> has_many :projects, :through => :project_custodians
> ...
> class ProjectCustodian
> project_id
> custodian_id
> ...
>
> I have an existing list of custodians, I just want a select that lets
> me pick one of them and a formlet-submit button that creates a new
> ProjectCustodian with project_id = @project.id and custodian_id = the
> value of the select.
>
> clear?
>
> On Jul 7, 8:39 pm, kevinpfromnm <[email protected]> wrote:
>> Instead of using with="&ProjectCustodian.new" use
>> with="&@project.custodians.new" (assuming custodians is the
>> association). That will take care of the id automatically.
>>
>> On Jul 7, 4:22 pm, Montgomery Kosma <[email protected]> wrote:
>>
>>> Kevin -- I have the new item as the context, and can set values inside
>>> the object from ruby code, but can't figure out how to poke the
>>> custodian id from the select into my new object. Any tip on that?
>>> <formlet with="&ProjectCustodian.new" reset-form refocus-
>>> form>
>>> <div>
>>> <%#*Name:%>
>>> <%
>>> options = Custodian.all.select {|x| can_view?(x)}
>>> values = @project_custodians.*.custodian
>>> this.project_id = @project.id
>>> -%>
>>> <select name="custodian_id" merge-attrs="&{:disabled
>>> => disabled}">
>>> <option value="">Add Custodian</option>
>>> <option repeat="&options.sort_by {|x|
>>> x.to_s.downcase}" value="#{this.id}"
>>> merge-attrs="&{:disabled => 'true'} if
>>> this.in?(values)"><%= h this.to_s %></option>
>>> </select>
>>> <%#*<name-one:custodian complete-target="&@project"
>>> completer="new_custodian_name" />%>
>>> <%#*<name-one:custodian />%>
>>> <formlet-submit label="Add Custodian" update="self"
>>> confirm="foo" message="yikes!">
>>> <% require 'ruby-debug'; debugger %>
>>> <% this.custodian_id = param[:custodian_id] %>
>>> <% logger.info "FOO" %>
>>> </formlet-submit>
>>> </div>
>>> </formlet>
>>> On Jun 24, 8:05 pm, kevinpfromnm <[email protected]> wrote:
>>>> If it's based off a hobo tag, just make sure you're using the a new
>>>> item in the association as the context. Otherwise, you can include
>>>> hidden inputs with the appropriate values. There's probably a better/
>>>> cleaner way but that's a quick way.
>>>> On Jun 24, 5:36 pm, Montgomery Kosma <[email protected]> wrote:
>>>>> quick update: looks like a new ProjectCustodian is being created when
>>>>> I hit the Add button. Here's the log text. The issue appears to be
>>>>> that custodian_id and project_id are both set to NULL. So ... maybe
>>>>> my question (on the update piece, if not the autocomplete) is how to
>>>>> make myformletpick up these attributes?
>>>>> Processing ProjectCustodiansController#create (for 127.0.0.1 at
>>>>> 2009-06-24 19:30:01) [POST]
>>>>> Parameters: {"page_path"=>"projects/edit",
>>>>> "authenticity_token"=>"vN9DChlVzt4U2ndcUVEbUTiFAolngw3AYzocccNuunU="}
>>>>> [4;36;1mUser Load (1.0ms) [0m [0;1mSELECT * FROM `users` WHERE
>>>>> (`users`.`id` = 5) [0m
>>>>> [4;36;1mProjectCustodian Create (0.0ms) [0m [0;1mINSERT INTO
>>>>> `project_custodians` (`created_at`, `updated_at`, `custodian_id`,
>>>>> `project_id`) VALUES('2009-06-24 23:30:01', '2009-06-24 23:30:01',
>>>>> NULL, NULL) [0m
>>>>> [4;35;1mSQL (0.0ms) [0m [0mBEGIN [0m
>>>>> [4;35;1mSQL (62.0ms) [0m [0mCOMMIT [0m
>>>>> Completed in 73ms (View: 3, DB: 63) | 200 OK [http://localhost/
>>>>> project_custodians]
>>>>> On Jun 24, 1:07 pm, Montgomery Kosma <[email protected]> wrote:
>>>>>> Bryan -- hope you can spare a couple minutes to answer this and my
>>>>>> prior question that's preventing me from gettingformletto work.
>>>>>> I thought maybe the missing ingredient in my example below was that
>>>>>> formletneeded the update="project-custodians" tag. However, when I
>>>>>> added part="project-custodian" to my section tag, that caused an
>>>>>> error. Same thing if I put it in its own <div>, and it doesn't matter
>>>>>> what I name the part:
>>>>>> <div part="project-custodian">
>>>>>> ...
>>>>>> </div>
>>>>>> generates
>>>>>> NoMethodError in ProjectsController#edit
>>>>>> undefined method `all_parameters' for #<ActionView::Base:0x11618d78>
>>>>>> RAILS_ROOT: C:/DataLibrarian
>>>>>> Application Trace | Framework Trace | Full Trace
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:605:in `send'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:605:in `method_missing'
>>>>>> app/views/projects/form.dryml:61:in `project_custodians_part'
>>>>>> app/views/projects/form.dryml:13:in `project_custodians_part'
>>>>>> app/views/projects/form.dryml:13:in `form__for_project'
>>>>>> app/views/projects/form.dryml:13:in `form__for_project'
>>>>>> app/views/projects/form.dryml:2:in `form__for_project'
>>>>>> app/views/projects/form.dryml:2:in `form__for_project'
>>>>>> app/views/projects/form.dryml:1:in `form__for_project'
>>>>>> app/views/taglibs/auto/rapid/pages.dryml:1265:in
>>>>>> `edit_page__for_project'
>>>>>> app/views/taglibs/auto/rapid/pages.dryml:1264:in
>>>>>> `edit_page__for_project'
>>>>>> app/views/taglibs/auto/rapid/pages.dryml:1264:in
>>>>>> `edit_page__for_project'
>>>>>> app/views/taglibs/auto/rapid/pages.dryml:1258:in
>>>>>> `edit_page__for_project'
>>>>>> app/views/taglibs/themes/clean/clean.dryml:2:in
>>>>>> `page_without_a7588f4881f5'
>>>>>> app/views/taglibs/themes/clean/clean.dryml:1:in
>>>>>> `page_without_a7588f4881f5'
>>>>>> app/views/taglibs/application.dryml:13:in `page'
>>>>>> app/views/taglibs/application.dryml:12:in `page'
>>>>>> app/views/taglibs/auto/rapid/pages.dryml:1254:in
>>>>>> `edit_page__for_project'
>>>>>> app/views/taglibs/auto/rapid/pages.dryml:1253:in
>>>>>> `edit_page__for_project'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:605:in `send'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:605:in `method_missing'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:248:in `new_context'
>>>>>> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_view/
>>>>>> helpers/capture_helper.rb:129:in `with_output_buffer'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:248:in `new_context'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:159:in `send'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:159:in `call_part'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:248:in `new_context'
>>>>>> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_view/
>>>>>> helpers/capture_helper.rb:129:in `with_output_buffer'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:248:in `new_context'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:157:in `call_part'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:248:in `new_context'
>>>>>> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_view/
>>>>>> helpers/capture_helper.rb:129:in `with_output_buffer'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:248:in `new_context'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:248:in `new_context'
>>>>>> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_view/
>>>>>> helpers/capture_helper.rb:129:in `with_output_buffer'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:248:in `new_context'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:457:in `call'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:457:in `override_and_call_tag'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> tag_parameters.rb:21:in `call'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> tag_parameters.rb:21:in `method_missing'
>>>>>> vendor/plugins/hobo/hobo/taglibs/rapid_forms.dryml:169:in `form__base'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:338:in `with_form_context'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> scoped_variables.rb:20:in `new_scope'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:337:in `with_form_context'
>>>>>> vendor/plugins/hobo/hobo/taglibs/rapid_forms.dryml:167:in `form__base'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:328:in `_tag_context'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:248:in `new_context'
>>>>>> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_view/
>>>>>> helpers/capture_helper.rb:129:in `with_output_buffer'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:248:in `new_context'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:328:in `_tag_context'
>>>>>> vendor/plugins/hobo/hobo/taglibs/rapid_forms.dryml:123:in `form__base'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:464:in `send'
>>>>>> C:/DataLibrarian/vendor/plugins/hobo/hobo/lib/hobo/dryml/
>>>>>> template_environment.rb:464:in `override_and_call_tag'
>> ...
>>
>> read more ยป
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---