3 Replies Latest reply on Feb 14, 2014 11:56 AM by Lars Burgess

    How to write a table

    Jiri Sverak

      I have a problem (again). I have a category, which belongs to account. So I can select in grouptitle an account. But what if I want to write it in show? In Rails: @category.account.name

       

      But it doesn't work in Rhomobile. This is my code: Account.find(@category.account_id).name. It's really so dumb or did I missed anything?

        • Re: How to write a table
          This is my code: Account.find(@category.account_id).name.

          That's a simple enough code snippet that should work as far as I can tell.  I recommend that you inspect what `@category` actually is, maybe `@category.account_id` is returning nil or empty string?  Maybe your `Account` records don't have IDs that match `@category.account_id`?

            • Re: How to write a table
              Jiri Sverak

              @category.account_id


              I think it returns me id.

                • Re: Re: How to write a table

                  Let's walk through this, let's say you print out `@category.account_id`:

                   

                  puts "category account: #{@category.account_id.inspect}"
                  

                   

                  Then let's see if Account model has some IDs that look like it:

                   

                  puts "Accounts: #{Account.find(@category.account_id).inspect}"
                  

                   

                  My guess is the @category.account_id doesn't exactly match what the IDs look like for Account model.  You could check what they look like with:


                  puts "Some account: #{Account.find(:all).inspect}"
                  
                  

                   

                  And see if these accounts have IDs or `object` attributes that look like what you're searching for.