0

I have a Rails 3 project in Aptana Studio 3 with a html.erb view file containing the following code:

<% if @books.blank? %>
<p>
    There are not any books currently in the system.
</p>
<% else %>
<p>
    These are the current books in our system
</p>
<ul id="books">
    <% @books.each do |c| %>
    <li>
        <%= link_to c.title, {:action => 'show', :id => c.id} -%>
    </li>
    <% end %>
</ul>
<% end %>
<p>
    <%= link_to "Add new Book", {:action => 'new' }%>
</p>

Then in the embedded terminal, I run rails server, click the "Run with Firefox Server" button in Aptana which opens the application with firefox, and directs me to this link: http://127.0.0.1:8020/library/app/views/book/book.html.erb

The problem is that I get this output:

<% if @books.blank? %>

There are not any books currently in the system.
<% else %>

These are the current books in our system

    <% @books.each do |c| %>
    <%= link_to c.title, {:action => 'show', :id => c.id} -%>
    <% end %> 

<% end %>

<%= link_to "Add new Book", {:action => 'new' }%> 

Seems like the ruby code isn't getting evaluated but rather printed, however the syntax looks alright to me... Does anyone know what might be the problem?

1 Answer 1

2

Aptana doesn't open the right page. If you're just using the default server, then you probably want to open localhost:3000.

Some more info: look at the url, it's just the path to a file, not the url for the books index.

Your file path (http://127.0.0.1:8020/library/app/views/book/book.html.erb) also seems strange...

First, the book folder name should be plural (app/views/books). And second, your view code seems like it's the books index page, so it probably should be in app/views/books/index.html.erb.

Sign up to request clarification or add additional context in comments.

6 Comments

Then I get the standard "Welcome to Rails" home page... But I also noticed this error during the startup: ActionController::RoutingError (No route matches [GET] "/library"). The name of the project is "library" so could that be the problem?
Delete the index.html file in /public.
This error now shows up on the page: No route matches [GET] "/"
Just find any tutorial to set up a RoR web application and start over. It seems you just skipped too many steps.
I agree with @oldergod... Show us your routes file.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.