I’m making a website for newspaper.
While implemeting ARCHIVE function, I met a problem.
I expect that “…/main/archive/volume_number” is redirected to
“…/volume_number/index”.
However, there are so many volumes in archives and I can’t make all
controllers manually, each for one volume.
So, in “main” controller, in “archive” method, I want to dynamically
create a controller named volume_number(probably specified by
params[:id]) and redirect to the controller.
Please help =)
If you have another idea for implementing archives, please tell me.
I’m using Mysql and articles are categorized by volume number.
Are these archives in separate databases? I don’t see you needing to
create
separate controllers for each archive. You might have to juggle some
table
naming features but nothing terribly insane. [I do it for a multi-site
app
I’m working on where each site has their own content db.] Without
knowing
more about the particular constraints you’re under I can’t/won’t hazard
any
further speculation but I wouldn’t give up just yet.
RSL
Thank you for your attention.
Archives are not in separate databases.
All articles are in one database(named ‘entries’), and the database just
has the attribute named ‘volume’.
The main page shows the lastest volume, that is newest.
When someone clicks the ‘archives’ button and choose the volume number,
then screen changes and shows that volume in the same way as the lastest
volume is shown.(I don’t mean that each volume has just one page. You
can think one volume is one group of many pages.)
Therefore, each volume must be distinguishable but must have the same
structure on screen.
Thanks.
Russell N. wrote:
Are these archives in separate databases? I don’t see you needing to
create
separate controllers for each archive. You might have to juggle some
table
naming features but nothing terribly insane. [I do it for a multi-site
app
I’m working on where each site has their own content db.] Without
knowing
more about the particular constraints you’re under I can’t/won’t hazard
any
further speculation but I wouldn’t give up just yet.
RSL
As I see it you’re just wanting to index them by volume which is
snaptastically easy. First you’ll need to make your routing aware of the
the
volume parameter. map.connect “/main/archive/:volume” will give you
@volume
[as a String, mind you] to use in your controller. In the controller
just do
something like Entry.find(:all, :conditions => [“volume = ?”, @volume]).
You
might need to change that @volume to @volume.to_i but might not. This
isn’t
the whole solution [since 1) I don’t know the rest of your code and 2)
you’re the one getting paid for it – hopefully] but should get you
moving
in the right direction.
RSL
Thank you very much.
It’s a very great solution for me.
Thanks =)
Russell N. wrote:
As I see it you’re just wanting to index them by volume which is
snaptastically easy. First you’ll need to make your routing aware of the
the
volume parameter. map.connect “/main/archive/:volume” will give you
@volume
[as a String, mind you] to use in your controller. In the controller
just do
something like Entry.find(:all, :conditions => [“volume = ?”, @volume]).
You
might need to change that @volume to @volume.to_i but might not. This
isn’t
the whole solution [since 1) I don’t know the rest of your code and 2)
you’re the one getting paid for it – hopefully] but should get you
moving
in the right direction.
RSL
Hi~
On Feb 17, 2007, at 8:23 AM, Russell N. wrote:
RSL
Actually /main/archive/:volume will not give you @volume, it will
give you params[:volume]
-Ezra
then screen changes and shows that volume in the same way as the
Are these archives in separate databases? I don’t see you needing to
any
– Ezra Z.
– Lead Rails Evangelist
– [email protected]
– Engine Y., Serious Rails Hosting
– (866) 518-YARD (9273)
D’oh! You’re right! Now I’m scratching my head trying to figure out why
I
wrote [and thought] that when I do know better. Perhaps some brainfart
about the long-deprecated @params variable? Sure, let’s blame that.
[Shame
on me.]
RSL