Hi!
I can't seem to guess how I should specify the join between these two tables, to have the category name added to the output.
The tables are
create_table "message_categories", :force => true do |t|
t.column "name", :string, :null => false
end
create_table "messages", :force => true do |t|
t.column "message_category_id", :integer, :default => 0, :null => false
t.column "name", :string, :null => false
t.column "sort", :integer, :null => false
end
|
the code I tried to add is
def component
@show_wrapper = true if @show_wrapper.nil?
@sort_sql = Message.scaffold_columns_hash[current_sort(params)].sort_sql rescue nil
@sort_by = @sort_sql.nil? ? "#{Message.table_name}.#{Message.primary_key} asc" : @sort_sql + " " + current_sort_direction(params)
@paginator, @messages = paginate :messages, :per_page => 40, :order => 'sort DESC, name', :joins => "#{MessageCategory.name}"
render :action => "component", :layout => false
end
|
In particular, I added
:joins => "#{MessageCategory.name}", but I cannot find any example and I'm definitely doubtful about the syntax. Last but not least,
I'm using ajax_scaffold, which is one of the greatest things I ever saw (and in 28 years of work I saw a lot of them).
Any hint is extremely welcome.