Created
February 3, 2011 11:56
-
-
Save andrellima/809392 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
before_filter :load_generos | |
def index | |
@livros = Livro.all | |
@generos = Genero.all | |
@livros = @genero.livros | |
respond_to do |format| | |
format.html # index.html.erb | |
format.xml { render :xml => @livros } | |
end | |
end | |
# GET /livros/1 | |
# GET /livros/1.xml | |
def show | |
@livro = Livro.find(params[:id]) | |
@livro = @genero.livros.find(params[:id]) | |
def load_genero | |
@generos = Genero.all | |
@Genero = Genero.find(params[:genero_id]) if params[:genero_id] | |
end | |
<h3>Generos</h3> | |
<ul class="squared"> | |
<% @generos.each do |genero| %> | |
<li><%= link_to_unless_current genero.nome, livros_path(:genero_id => genero.id) %></li> | |
<% end %> | |
</ul> | |
Livraria::Application.routes.draw do | |
devise_for :users | |
resources :dvds | |
resources :cds | |
resources :livros | |
resource :generos | |
resources :generos do | |
resources :livros | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment