title: Get data from related tables, rails
body: <p>some fields tables City</p>
  
  <pre><code>create_table "cities", force: :cascade do |t|
  t.string "name"
  </code></pre>
  
  <p>some fields tables Order</p>
  
  <pre><code>create_table "orders", force: :cascade do |t|
  t.integer "count"
  t.integer "first_city_id"
  t.integer "last_city_id"
  </code></pre>
  
  <p>model Order</p>
  
  <pre><code>class Order &lt; ActiveRecord::Base
  belongs_to :city, inverse_of: :city
  end
  </code></pre>
  
  <p>model City</p>
  
  <pre><code>class City &lt; ActiveRecord::Base
  has_many :orders, inverse_of: :order
  end
  </code></pre>
  
  <p>working output data from Order in view</p>
  
  <pre><code>&lt;% @order.each do |orders| %&gt;
  &lt;p&gt; &lt;%= orders.count %&gt; &lt;/p&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Method in controller</p>
  
  <pre><code>def edit
  @orders= Order.all
  @order=Order.where(:user_id == current_user)
  end
  </code></pre>
  
  <p>How to get the value from the name Sity table if first_city_id or last_city_id in the Order table contains id required entry of City Table?</p>