Forum: Ruby on Rails Different controllers placement

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Timur (Guest)
on 2005-12-09 00:31
request: /blog
controller placed at /app/controllers/test/blog_controller.rb:

class Test::BlogController < ApplicationController
 def index
  render :text => 'Hello, World!'
 end
end

What the write map.connect shoud I use? Any Idias?

I see that    map.connect '/blog', :controller => 'test/blog' working
correctly, but what about more complex example such a  map.connect
':controller/:action/:id?
wnorrix (Guest)
on 2005-12-09 01:02
(Received via mailing list)
On Dec 8, 2005, at 3:31 PM, Timur wrote:

> I see that    map.connect '/blog', :controller => 'test/blog' working
> correctly, but what about more complex example such a  map.connect
> ':controller/:action/:id?

You can find examples here:
	http://typo.leetsoft.com/trac/file/trunk/config/routes.rb

Routes are pretty easy to grasp. There is a tutorial floating around
somewhere too. You could always join #rubyonrails for more support.

- Warren
phil (Guest)
on 2005-12-09 04:13
(Received via mailing list)
I have written some reporting queries using Active Record such as:

addresses = address.find_by_sql("select name, street, city, state, zip
from
address")
The queries are actually much more complex than this with aggregation,
joins, etc... that's why I'm using the find_by_sql method.

I am converting the output of my report queries to CSV.... unfortunately
I
can't figure out a generic way to get the report queries to preserve the
column order (name, stree, city, zip)

Addresses[0].attributes.keys returns the columns, but not in the
selected
order

Addresses.column_names returns the column in alphabetical order.

Any suggestions?
ara.t.howard (Guest)
on 2005-12-09 04:21
(Received via mailing list)
On Thu, 8 Dec 2005, Phil Swenson wrote:

> Addresses[0].attributes.keys returns the columns, but not in the selected
> order
>
> Addresses.column_names returns the column in alphabetical order.
>
> Any suggestions?

   columns = %w( name street city state zip )

   sql = <<-sql

     select #{ columns.join ', ' }

     from addresses

   sql

   addresses = address.find_by_sql sql

   csv = CSV::Writer::new 'somefile.csv'

   csv << columns  # add header

   addresses.each do |address|
     row = columns.map{|col| address.send col}
     csv << row
   end

hth.

-a
--
===============================================================================
| ara [dot] t [dot] howard [at] noaa [dot] gov
| all happiness comes from the desire for others to be happy.  all misery
| comes from the desire for oneself to be happy.
| -- bodhicaryavatara
===============================================================================
This topic is locked and can not be replied to.