in fact, I don’t use the login_controller which uses the admin layout.
What’s in a name.
There is a difference between a list of the movies from the login view
and the movies view.
The admin layout includes the following lines:
<% if session[ :user_id ] %>
<% gebruiker = User.find_by_id( session[ :user_id]).naam -
%>
<%= gebruiker -%>
<%= link_to( ‘overzicht films’, :action => ‘list_movies’ )
-%>
<% else %>
no user
<% end %>
In the login controller I have
def list_movies
@all_movies = Movie.find( :all)
@all_movies = [] if !@all_movies
end
and in the views/login list_movies.html.erb contains
Overzicht van films
<% if flash[ :notice ] %>
<%= flash[ :notice ] -%>
<% end %>
<% i = 0
for movie in @all_movies %>
<%= i += 1
(i % 2 == 0 ? ‘
’ : ‘’) -%>
<td><img src="images/<%= movie.one_sheet_url %>"/></td>
<td class='titel'>
<b><%= movie.title %></b><br>
<%=h movie.description %>
</td>
<td>
<table>
<tr><td class='actie'><%= link_to( 'toon', {
:controller => 'movies',
:action => 'show',
:id => movie}) -%></td></
tr>
</
tr>
|
beschrijving |
acties |
<%= link_to
‘bewerk’, edit_movie_path(movie) %> |
<%= link_to 'verwijder', movie, :confirm =>
'Zeker weten?',
:method => :delete %> |
<% end %>
-----------------------------------
Following the link ‘list users’ from the admin layout, I get a table
in the browser, without the images displayed. Webrick says
http://localhost:3000/login/list_movies → /login/images/shrekI.png
127.0.0.1 - - [26/Feb/2008:13:14:08 CET] “GET /login/images/
shrekII.png HTTP/1.1” 404 571
http://localhost:3000/login/list_movies → /login/images/shrekII.png
127.0.0.1 - - [26/Feb/2008:13:14:09 CET] “GET /login/images/
shrekIII.png HTTP/1.1” 404 571
http://localhost:3000/login/list_movies → /login/images/shrekIII.png
127.0.0.1 - - [26/Feb/2008:13:14:09 CET] “GET /login/images/BtoF.png
HTTP/1.1” 404 571
The images are in public/images, so that explains why they are not
displayed
Now, if I go to localhost:3000/movies, I get a listing of the movies
too;
movies/index.html.erb contains
Listing movies
<% if flash[ :notice ] %>
<%= flash[ :notice ] -%>
<% end %>
<% i = 0
for movie in @movies %>
<%= i += 1
(i % 2 == 0 ? ‘
’ : ‘’) -%>
<td><img src="images/<%= movie.one_sheet_url %>"/></td>
<td class='titel'>
<b><%= movie.title %></b><br>
<%=h movie.description %>
</td>
<td>
<table>
<tr><td class='actie'><%= link_to 'bewerk',
edit_movie_path(movie) %>
</
tr>
<%= button_to( “doe in winkelmand”, { :action
=> :add_to_cart,
:id => movie })
%>
|
beschrijving |
acties |
<%= link_to ‘verwijder’,
movie, :confirm => ‘Zeker weten?’,
:method => :delete %> |
<% end %>
<%= button_to( "leeg winkelmand", { :action => :empty_cart } ) -%>
<%= link_to 'Nieuwe film', new_movie_path() %>
--------------------------------
As you can see, it is almost the same as list_movies.html.erb.
But now, the images ARE displayed and webrick says
127.0.0.1 - - [26/Feb/2008:13:14:08 CET] “GET /login/images/shrekI.png
HTTP/1.1” 404 571
http://localhost:3000/login/list_movies → /login/images/shrekI.png
127.0.0.1 - - [26/Feb/2008:13:14:08 CET] “GET /login/images/
shrekII.png HTTP/1.1” 404 571
http://localhost:3000/login/list_movies → /login/images/shrekII.png
127.0.0.1 - - [26/Feb/2008:13:14:09 CET] “GET /login/images/
shrekIII.png HTTP/1.1” 404 571
http://localhost:3000/login/list_movies → /login/images/shrekIII.png
I am puzzled. If you can shine a light on this I’d be very grateful.
Let me now if I have to provide extra information…
Ruud