Forum: Ruby on Rails another quick question, or two

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.
Mk 2. (Guest)
on 2009-05-21 20:28
If I want to link from/redirect via the index page (which I notice will
not process as erb), what's the local relative path I should use to the
the view (object/method don't work)?

I am getting to like rails so I will probably stick with it.  Does
anyone have anything to say (pro and contra, please) about the various
"Ruby on Rails" books that are available?
Marnen L. (Guest)
on 2009-05-21 20:35
Mk 27 wrote:
> If I want to link from/redirect via the index page (which I notice will
> not process as erb)

Huh?  *What* won't process as ERb?

> , what's the local relative path I should use to the
> the view (object/method don't work)?

Let Rails build the path for you.  Take a look at url_for and/or named
routes.  It's uncommon to need to specify literal URLs in a Rails app.

>
> I am getting to like rails so I will probably stick with it.

Cool!

> Does
> anyone have anything to say (pro and contra, please) about the various
> "Ruby on Rails" books that are available?

Even though many of the books out there seem to be excellent, book
publishing moves slowly, and Rails core development moves very fast, so
books can get obsolete pretty quickly.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
removed_email_address@domain.invalid
Mk 2. (Guest)
on 2009-05-21 22:15
Marnen Laibow-Koser wrote:
> Mk 27 wrote:
>> If I want to link from/redirect via the index page (which I notice will
>> not process as erb)
>
> Huh?  *What* won't process as ERb?

public/index.html

I copied my (working) application.html.erb from app/layouts, made some
appropriate modifications, and named it "index.html.erb".  When I start
the server and go to localhost:3000, it does read the page but it spits
out the <%ruby%> unparsed, like I suppose it would if I used apache.

Anyway, I am sure I will get to know all the rails commands eventually,
but since all the paths are absolute relative to one another, I would
actually PREFER to know what they are/should be -- you cannot get
simpler than typing a relative url, eg. it would literally be
"app/views/section/list" (although this does not work).  Ease of use is
one thing, pointless opacity is another.

So, can I ask that question again in the hopes of getting a real answer?
I will investigate url_for and routes as well...
Marnen L. (Guest)
on 2009-05-21 22:29
Mk 27 wrote:
> Marnen Laibow-Koser wrote:
>> Mk 27 wrote:
>>> If I want to link from/redirect via the index page (which I notice will
>>> not process as erb)
>>
>> Huh?  *What* won't process as ERb?
>
> public/index.html

Right.  The public directory is for static assets.  If you want a
dynamic index page, then use map.root in routes.rb.
[...]
> Anyway, I am sure I will get to know all the rails commands eventually,
> but since all the paths are absolute relative to one another, I would
> actually PREFER to know what they are/should be -- you cannot get
> simpler than typing a relative url, eg. it would literally be
> "app/views/section/list" (although this does not work).

This is a bad idea.  I know it may seem simpler, but it really isn't.
The reason is that Rails controls URL mapping through the routes.rb
file, so the URLs are not necessarily directly related to the object
structure of the application.  Specifying literal URLs will bypass a lot
of the routing logic, which is generally not what you want.

>  Ease of use is
> one thing, pointless opacity is another.

This is not pointless opacity.  It exists so you can provide nice URLs
to your users without having to expose implementation details that users
shouldn't see.
>
> So, can I ask that question again in the hopes of getting a real answer?

Learn how routing works in Rails (the rdoc is excellent on this topic).
That's the only real answer that I or anyone else can give you.

> I will investigate url_for and routes as well...

Please do.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
removed_email_address@domain.invalid
Mk 2. (Guest)
on 2009-05-21 22:46
Marnen Laibow-Koser wrote:

> Learn how routing works in Rails (the rdoc is excellent on this topic).
> That's the only real answer that I or anyone else can give you.

Okay...thanks for the explanation
This topic is locked and can not be replied to.