Created
May 1, 2013 02:53
-
-
Save telagraphic/5493474 to your computer and use it in GitHub Desktop.
This file contains 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
class CategoriesController < ApplicationController | |
def new | |
@category = current_user.categories.build | |
@categories = current_user.categories | |
end | |
end |
This file contains 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
Started GET "/categories/new" for 127.0.0.1 at 2013-04-30 22:32:15 -0400 | |
Processing by CategoriesController#new as HTML | |
[1m[36mUser Load (0.5ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1[0m | |
Rendered shared/_error_messages.html.erb (0.0ms) | |
Rendered categories/_form.html.erb (1.8ms) | |
[1m[35m (0.3ms)[0m SELECT COUNT(*) FROM "categories" WHERE "categories"."user_id" = 1 | |
[1m[36mCategory Load (0.3ms)[0m [1mSELECT "categories".* FROM "categories" WHERE "categories"."user_id" = 1[0m | |
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' |
This file contains 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
<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