Skip to content

Instantly share code, notes, and snippets.

@telagraphic
Created May 1, 2013 02:53
Show Gist options
  • Save telagraphic/5493474 to your computer and use it in GitHub Desktop.
Save telagraphic/5493474 to your computer and use it in GitHub Desktop.
class CategoriesController < ApplicationController
def new
@category = current_user.categories.build
@categories = current_user.categories
end
end
Started GET "/categories/new" for 127.0.0.1 at 2013-04-30 22:32:15 -0400
Processing by CategoriesController#new as HTML
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Rendered shared/_error_messages.html.erb (0.0ms)
Rendered categories/_form.html.erb (1.8ms)
 (0.3ms) SELECT COUNT(*) FROM "categories" WHERE "categories"."user_id" = 1
Category Load (0.3ms) SELECT "categories".* FROM "categories" WHERE "categories"."user_id" = 1
Rendered categories/new.html.erb within layouts/application (5.8ms)
Completed 500 Internal Server Error in 10ms
ActionController::RoutingError (No route matches {:action=>"edit", :controller=>"categories", :id=>#<Category id: nil, name: nil, created_at: nil, updated_at: nil, user_id: 1>}):
app/views/categories/new.html.erb:9:in `block in _app_views_categories_new_html_erb__3219152364255558243_70124608600680'
app/views/categories/new.html.erb:7:in `_app_views_categories_new_html_erb__3219152364255558243_70124608600680'
<h1>New Category</h1>
<%= form_for @category do |f| %>
<%= render 'shared/error_messages', object: f.object %><br>
<%= f.label :name %><br>
<%= f.text_field :name %><br>
<%= f.submit "+category" %><br>
<% end %>
<% if @categories.any? %>
<ul>
<% @categories.each do |category| %>
<li>
<%= category.name %> | <%= link_to 'Change', edit_category_path(category) %>
</li>
<% end %>
</ul>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment