Note that there are some explanatory texts on larger screens.

plurals
  1. POrails 3 controller select models
    primarykey
    data
    text
    <p>i have something not working like i want in my controller.</p> <p>my controller</p> <pre><code> if params[:commit] @search = Building.select('buildings.id, buildings.slug, floors.id, spaces.id, buildings.name, floors.floor_number, spaces.space_number').joins('INNER JOIN floors ON floors.building_id = buildings.id INNER JOIN spaces ON spaces.floor_id = floors.id') @search = @search.where("buildings.name like '%#{params[:building_name]}%'") if !params[:building_name].blank? #@search = @search.where("buildings.name like ?", params[:building_name]) if !params[:building_name].blank? if params[:space_type].present? @search = @search.where("spaces.space_type_id = ?", params[:space_type][:space_type_id]) if !params[:space_type][:space_type_id].blank? end @search = @search.where("floors.min_net_rent &gt;= #{params[:floor_min_rent]}") if !params[:floor_min_rent].blank? @search = @search.where("floors.max_net_rent &lt;= #{params[:floor_max_rent]}") if !params[:floor_max_rent].blank? @building = @search else @building = '' end </code></pre> <p>my models</p> <pre><code>class Building &lt; ActiveRecord::Base has_many :floors end class Floor &lt; ActiveRecord::Base belongs_to :building has_many :space end class Space &lt; ActiveRecord::Base belongs_to :floor end </code></pre> <p>the debug &lt;%= debug @building %> return me</p> <pre><code>[#&lt;Building id: 9, name: "234234", slug: nil&gt;] (as example) </code></pre> <p>But i want to get information about floors and spaces.</p> <p>Someone have an idea how to resolv this?</p> <p>thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload