Skip to content

Instantly share code, notes, and snippets.

@camkidman
Last active December 18, 2015 18:39
Show Gist options
  • Save camkidman/5827248 to your computer and use it in GitHub Desktop.
Save camkidman/5827248 to your computer and use it in GitHub Desktop.
class DeckController < ApplicationController
def index
end
def new
@deck = Deck.new
end
def create
@deck = Deck.new
if @deck.save
redirect_to user_decks(@user) #added @user 20130619, not sure if it's right
else
render "new"
end
end
def edit
@deck = Deck.find(params[:id])
end
def showcards
end
def addcard
@deck = Deck.find(params[:id])
@card = @deck.card # Not sure if this is right
end
def removecard
end
def update
end
def destroy
end
end
undefined method `decks_index_path' for #<#<Class:0x007f842c3bbde0>:0x007f842cb2f8b0>
Extracted source (around line #3):
1: # To create a new deck
2:
3: <%= form_for(@deck) do |f| %>
4: <%= f.label :name %>
5: <%= f.text_field :name %>
6: <%= f.submit %>
Rails.root: /home/sp33k3rph433k/pokemonapp
Application Trace | Framework Trace | Full Trace
app/views/decks/new.html.erb:3:in `_app_views_decks_new_html_erb___3075103149099613798_20941760'
new form:
<%= form_for(@deck) do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.submit %>
<% end %>
# To create a new deck
<%= form_for(@deck) do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.submit %>
<% end %>
<%= link_to "Add New Card", new_user_deck_card(@deck) %>
# Since trying to rename my model from "decks" to "deck"
Routing Error
uninitialized constant User::DecksController
Try running rake routes for more information on available routes.
Pokemonapp::Application.routes.draw do
# The priority is based upon order of creation:
# first created -> highest priority.
namespace :user do
resources :decks do
member do
get 'addcard'
get 'showcards'
end
resources :cards, :controller => 'deck/cards'
end
end
# resources :users do
# resources :decks, :controler => 'users/decks'
# end
# resources :decks do
# resources :cards, :controller => 'decks/cards'
# end
resources :users
match "user" => 'user#index'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment