Created
March 19, 2017 01:34
-
-
Save schoolmeister/01f663a1adf0481bc078ac4cc8b9fdee 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
class EventsController < ApplicationController | |
def index | |
@events = Event.all | |
end | |
def show | |
@event = Event.find(params[:id]) | |
end | |
def new | |
@event = Event.new | |
end | |
def edit | |
@event = Event.find(params[:id]) | |
end | |
def create | |
@event = Event.new(event_params) | |
@event.save | |
redirect_to @event | |
end | |
def update | |
@event = Event.find(params[:id]) | |
if @event.update(event_params) | |
redirect_to @event | |
else | |
render 'edit' | |
end | |
end | |
def destroy | |
@event = Event.find(params[:id]) | |
@event.destroy | |
redirect_to events_path | |
end | |
private | |
def event_params | |
params.require(:event).permit(:title, :description, :minimumage, :maximumage, :starttime, :endtime) | |
end | |
end |
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
<%= link_to 'New event', new_event_path %> | |
<table> | |
<tr> | |
<th>Title</th> | |
<th>Description</th> | |
<th>Minimum age</th> | |
<th>Maximum age</th> | |
<th>Start time</th> | |
<th>End time</th> | |
</tr> | |
<% @events.each do |event| %> | |
<tr> | |
<td><%= event.title %></td> | |
<td><%= event.description %></td> | |
<td><%= event.minimumage %></td> | |
<td><%= event.maximumage %></td> | |
<td><%= event.starttime %></td> | |
<td><%= event.endtime %></td> | |
<td><%= link_to 'Show', event_path(event) %></td> | |
<td><%= link_to 'Edit', edit_event_path(event) %></td> | |
<td><%= link_to 'Destroy', event_path(event), | |
method: :delete, | |
data: { confirm: 'Are you sure?' } %></td> | |
</tr> | |
<% end %> | |
</table> | |
<%= link_to 'Home', root_path %> |
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
NameError in EventsController#index | |
uninitialized constant EventsController::Event | |
Extracted source (around line #4): | |
2 | |
3 def index | |
4 @events = Event.all | |
5 end | |
6 | |
7 def show | |
application trace: | |
app/controllers/events_controller.rb:4:in `index' | |
framework trace: | |
actionpack (5.0.2) lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action' | |
actionpack (5.0.2) lib/abstract_controller/base.rb:188:in `process_action' | |
actionpack (5.0.2) lib/action_controller/metal/rendering.rb:30:in `process_action' | |
actionpack (5.0.2) lib/abstract_controller/callbacks.rb:20:in `block in process_action' | |
activesupport (5.0.2) lib/active_support/callbacks.rb:126:in `call' | |
activesupport (5.0.2) lib/active_support/callbacks.rb:506:in `block (2 levels) in compile' | |
activesupport (5.0.2) lib/active_support/callbacks.rb:455:in `call' | |
activesupport (5.0.2) lib/active_support/callbacks.rb:101:in `__run_callbacks__' | |
activesupport (5.0.2) lib/active_support/callbacks.rb:750:in `_run_process_action_callbacks' | |
activesupport (5.0.2) lib/active_support/callbacks.rb:90:in `run_callbacks' | |
actionpack (5.0.2) lib/abstract_controller/callbacks.rb:19:in `process_action' | |
actionpack (5.0.2) lib/action_controller/metal/rescue.rb:20:in `process_action' | |
actionpack (5.0.2) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action' | |
activesupport (5.0.2) lib/active_support/notifications.rb:164:in `block in instrument' | |
activesupport (5.0.2) lib/active_support/notifications/instrumenter.rb:21:in `instrument' | |
activesupport (5.0.2) lib/active_support/notifications.rb:164:in `instrument' | |
actionpack (5.0.2) lib/action_controller/metal/instrumentation.rb:30:in `process_action' | |
actionpack (5.0.2) lib/action_controller/metal/params_wrapper.rb:248:in `process_action' | |
activerecord (5.0.2) lib/active_record/railties/controller_runtime.rb:18:in `process_action' | |
actionpack (5.0.2) lib/abstract_controller/base.rb:126:in `process' | |
actionview (5.0.2) lib/action_view/rendering.rb:30:in `process' | |
actionpack (5.0.2) lib/action_controller/metal.rb:190:in `dispatch' | |
actionpack (5.0.2) lib/action_controller/metal.rb:262:in `dispatch' | |
actionpack (5.0.2) lib/action_dispatch/routing/route_set.rb:50:in `dispatch' | |
actionpack (5.0.2) lib/action_dispatch/routing/route_set.rb:32:in `serve' | |
actionpack (5.0.2) lib/action_dispatch/journey/router.rb:39:in `block in serve' | |
actionpack (5.0.2) lib/action_dispatch/journey/router.rb:26:in `each' | |
actionpack (5.0.2) lib/action_dispatch/journey/router.rb:26:in `serve' | |
actionpack (5.0.2) lib/action_dispatch/routing/route_set.rb:725:in `call' | |
rack (2.0.1) lib/rack/etag.rb:25:in `call' | |
rack (2.0.1) lib/rack/conditional_get.rb:25:in `call' | |
rack (2.0.1) lib/rack/head.rb:12:in `call' | |
rack (2.0.1) lib/rack/session/abstract/id.rb:222:in `context' | |
rack (2.0.1) lib/rack/session/abstract/id.rb:216:in `call' | |
actionpack (5.0.2) lib/action_dispatch/middleware/cookies.rb:613:in `call' | |
activerecord (5.0.2) lib/active_record/migration.rb:553:in `call' | |
actionpack (5.0.2) lib/action_dispatch/middleware/callbacks.rb:38:in `block in call' | |
activesupport (5.0.2) lib/active_support/callbacks.rb:97:in `__run_callbacks__' | |
activesupport (5.0.2) lib/active_support/callbacks.rb:750:in `_run_call_callbacks' | |
activesupport (5.0.2) lib/active_support/callbacks.rb:90:in `run_callbacks' | |
actionpack (5.0.2) lib/action_dispatch/middleware/callbacks.rb:36:in `call' | |
actionpack (5.0.2) lib/action_dispatch/middleware/executor.rb:12:in `call' | |
actionpack (5.0.2) lib/action_dispatch/middleware/remote_ip.rb:79:in `call' | |
actionpack (5.0.2) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call' | |
web-console (3.4.0) lib/web_console/middleware.rb:135:in `call_app' | |
web-console (3.4.0) lib/web_console/middleware.rb:20:in `block in call' | |
web-console (3.4.0) lib/web_console/middleware.rb:18:in `catch' | |
web-console (3.4.0) lib/web_console/middleware.rb:18:in `call' | |
actionpack (5.0.2) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call' | |
railties (5.0.2) lib/rails/rack/logger.rb:36:in `call_app' | |
railties (5.0.2) lib/rails/rack/logger.rb:24:in `block in call' | |
activesupport (5.0.2) lib/active_support/tagged_logging.rb:69:in `block in tagged' | |
activesupport (5.0.2) lib/active_support/tagged_logging.rb:26:in `tagged' | |
activesupport (5.0.2) lib/active_support/tagged_logging.rb:69:in `tagged' | |
railties (5.0.2) lib/rails/rack/logger.rb:24:in `call' | |
sprockets-rails (3.2.0) lib/sprockets/rails/quiet_assets.rb:13:in `call' | |
actionpack (5.0.2) lib/action_dispatch/middleware/request_id.rb:24:in `call' | |
rack (2.0.1) lib/rack/method_override.rb:22:in `call' | |
rack (2.0.1) lib/rack/runtime.rb:22:in `call' | |
activesupport (5.0.2) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call' | |
actionpack (5.0.2) lib/action_dispatch/middleware/executor.rb:12:in `call' | |
actionpack (5.0.2) lib/action_dispatch/middleware/static.rb:136:in `call' | |
rack (2.0.1) lib/rack/sendfile.rb:111:in `call' | |
railties (5.0.2) lib/rails/engine.rb:522:in `call' | |
/usr/lib/ruby/vendor_ruby/phusion_passenger/rack/thread_handler_extension.rb:97:in `process_request' | |
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:152:in `accept_and_process_next_request' | |
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:113:in `main_loop' | |
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler.rb:416:in `block (3 levels) in start_threads' | |
/usr/lib/ruby/vendor_ruby/phusion_passenger/utils.rb:113:in `block in create_thread_and_abort_on_exception' | |
env dump: | |
HTTP_ACCEPT: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" | |
HTTP_ACCEPT_ENCODING: "gzip, deflate, sdch, br" | |
HTTP_ACCEPT_LANGUAGE: "nl,en-US;q=0.8,en;q=0.6,fr-FR;q=0.4,fr;q=0.2,ko;q=0.2" | |
HTTP_VERSION: "HTTP/1.1" | |
ORIGINAL_SCRIPT_NAME: "" | |
REMOTE_ADDR: "(removed)" | |
SERVER_NAME: "(removed)" | |
SERVER_PROTOCOL: "HTTP/1.1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment