Topic: Renaming routes 3.1.1

I'm new to this, so I'm not expecting that anyone tell me how to do it, just whether it's possible. If so, I'll continue to melt my brain with the docs.

I've been asked to change /markets/4/articles/32
to markets/111111/articles/999999 where 111111 is in the remoteID field of the markets table and 999999 is in the remoteID field of the articles table.

From what I've seen, it can't be done. Maybe I'm just not looking hard enough?

Thanks,
Kelp

Re: Renaming routes 3.1.1

Not sure exactly what you are asking.

Are you dealing with some kind of legacy database that was set up outside of RoR, and you are trying to make it work the RoR way?????

Who created the attribute names RemoteID???

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: Renaming routes 3.1.1

Brad,

Yes, I will be dealing with legacy data, but the old system isn't going away. It will still be used for updating records - it's tied to a print process, which is why the data will be modified there. The records will then be curl'd to the RoR app for syndication via an API.

Renaming the routes would allow the process to happen without a lookup.

The attribute names haven't been created yet. But I thought that made sense.

Re: Renaming routes 3.1.1

Still not sure of the basic problem,  but it's not that tough to coerce legacy databases to conform to the Rails way.

For example, I deal with legacy data.  In Rails the main reference key is assumed to be an integer auto incremented field in the database called 'id' .  My legacy database has a table with a primary key that is a text field of a different name,  so to make it conform,  I have to do this:

in my database.yml:

aim:
  adapter: sqlserver
  mode: ODBC
  username: web
  password: xxxxxxx
  dsn: AIM

That establishes a basic connection to my legacy MS SQLServer database.  Now I define an active record model that uses that connection:

class Aim < ActiveRecord::Base
  establish_connection ('aim')
end

Now I define a model based on the legacy connection

class Broker < Aim
  set_table_name "Producer"
  set_primary_key "ProducerID"
end

So now I have a model Broker,  but instead of looking for a database table called 'brokers', it looks for a database table called 'Producer', I've overridden the rails default.  Then I tell Rails that the primary key is NOT 'id',  but a field called 'ProcuderID'.  So for example, when I do:

@broker = Broker.find(params[:id])

It just works,  even though params[:id] contains a string and not an integer value.

Am I understanding your dilemma?

Last edited by BradHodges (2011-12-06 01:00:00)

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.