Ruby on Rails Friday, May 22, 2015

On 22 May 2015 at 20:28, Elizabeth McGurty <emcgurty2@gmail.com> wrote:
> Walter, Stewart.... Many thanks to you. Definitely making so much progress
> here.
>
> All seems to be going really well, but I remain stumped at a critical point
>
> Given the model, I pass from the controller @parent = Parent.object
>
> All of the field_for aspects are working really beautifully. But in the
> view I need to test for a parent/child value. I know that this code is
> wrong:
>
> <% unless @lenders.state_id_string.blank? %> ## @lenders is the parent
> model, and only the fields within that model are being returned. I thought
> that if I define all parent associations in the AR, then the object @lenders
> would be aware..

Is @lenders a single parent or an array? Presumable an array since it
is plural. In which case you can't just test state_id_string.
Possibly you need something like @lenders.where(some condition on
state_id_string), assuming that state_id_string is a database field.
Alternatively perhaps you want to use @lenders.each to select and test
them one at a time.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLupThBcyQV6%2BPz4rE_vLRoqmSbhui7FWLpc6w7Z0Zp0gQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment